Running NUnit through Resharper 8 tests fail when crossing between projects due to AppDomain
Asked Answered
P

3

48

I recently updated to Resharper 8, and when I tried to run a suite of projects. These tests contain two suites of integration tests that both use IISExpress to run a website, make web requests and check the responses.

Running them in isolation is successful, and running all the tests would previously succeed. However, after the upate the second set of tests to run would fail.

Investigation has revealed the AppDomain.CurrentDomain.BaseDirectory is staying as the first test to run instead of changing. Since the integration tests are composed of two projects, this is causing the second project to fail since it cannot find any of the configuration files needed.

I cannot find any option to disable this different behaviour in Resharper 8, which appears to be the behaviour of the /domain:Single nunit flag. Short of downgrading to Resharper 7, does anybody know a solution to this? And is it an intended behaviour of Resharper 8 or a bug?

Placentation answered 26/7, 2013 at 9:17 Comment(0)
F
55

The Workaround:

Have you tried in Visual Studio going to ReSharper -> Options -> Tools -> Unit Testing

Change the setting "Run up to 1 assemblies in parallel" to a higher number. I tried one for each test project. Max is number of cores, I think.

Counterintuitive I know, but it worked for me and I am using AppDomain.CurrentDomain.BaseDirectory in the failing tests

The Cause A caching optimization bug in ReSharper 8. Working Directory is not set properly. Perhaps running in parallel creates a separate process for each test, so they don't trip over each other's settings.

The Fix JetBrains claim that this will be fixed in version 8.0.1

Update: There is a new unit testing option added in Resharper 8.1 to accomodate this scenario. Find it at ReSharper -> Options -> Tools -> Unit Testing -> "Use Separate AppDomain for each assembly with tests.

From answered 7/8, 2013 at 13:22 Comment(4)
+1 Same issue here. Your suggested setting change works for me too.Irtysh
Thanks, that helped me too. This issue isn't fixed in 8.0.1 BTW. Might be fixed in a later version though.Dodder
See @Paul Stuart's answer below for a more specific setting to target this error. (This workaround does work, though).Eliezer
Thanks for this fix. Fortunately you can save this setting in your "team shared" settings, that way you don't have to get every team member to make this change.Lathrope
H
9

We see the same issue. I think it's a bug. See: http://youtrack.jetbrains.com/issue/RSRP-380761

Homologize answered 26/7, 2013 at 17:48 Comment(0)
S
6

This has now been fixed in Resharper 8.0.2: http://youtrack.jetbrains.com/issue/RSRP-374143#comment=27-572929

Do not forget to tick new option ReSharper | Options | Tools | Unit Testing | "Use separate AppDomain for each assembly with test" to get it works.

i.e. There is now a new option in the Unit Testing settings.

Schapira answered 29/11, 2013 at 1:39 Comment(2)
This fixes the problem for me in Resharper 8.1Oringas
Reproduced and fixed but MUST check the new option in the ReSharper settings.Glisson

© 2022 - 2024 — McMap. All rights reserved.