Unit tests failing when run all together with FakeItEasy

U

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