Unit tests failing when run all together with FakeItEasy

While running my tests, I noticed that if I ran my test suite all together, some would fail, giving the exception:

API restriction: The assembly has already loaded from a different location

This issue was happening both in ReSharper test runner, and using the NUnit test runner

Debugging, the exception was being thrown on my SetUp methods like:

[SetUp]
public void SetUp()
{
_myFake = A.Fake<ISomething>();

I posted about this on StackOverflow, and tweeted contributors of the FakeItEasy project.

At the time of writing, there is an immediate workaround:

Run tests in parallel.

To do this for the ReSharper test runner, do the following:

Options -> Unit Testing -> Run up to x assemblies in parallel.
(Set to anything greater than 1)

How to run tests in parallel with resharper

 

An issue has been created on GitHub for this:

https://github.com/FakeItEasy/FakeItEasy/issues/189

2 responses to “Unit tests failing when run all together with FakeItEasy”

  1. adamralph avatar

    Thanks for posting this. Just one small mistake, the GitHub issue is https://github.com/FakeItEasy/FakeItEasy/issues/189

    For readers benefit – the issue has been fixed and will form part of the next release of FakeItEasy – version 1.15.

    1. Alex Brown avatar

      Thanks, I have updated it.

Leave a Reply

Your email address will not be published. Required fields are marked *