Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I prevent resharper 8 from running parallel tests with nunit?

I was running tests in VS2013 with Resharper 8, which integrated with an external process and redirected its output. I'm not seeking guidance on what qualifies as a unit test, because I find the test runner to be a nicer driver for any test than a console app.

This process was a database and so my SetUp and TearDown methods unsurprisingly did the opposites of each other and would absolutely step on each other if allowed to run concurrently.

They did not get to step on each other, because whenever two tests were started by the running simultaneously, they would lock up.

Latest Version 7 of Resharper did not have this issue.

Tinkering with the unit test settings in Resharper > Options > Unit Testing did not help.

like image 487
nik.shornikov Avatar asked Oct 26 '13 02:10

nik.shornikov


1 Answers

How to run NUnit test fixtures serially? -- is close to working.

On my test fixture base (and I always run base.SetUp() at the beginning of derived SetUp), I added the following:

    [SetUp]
    protected virtual void SetUp()
    {
        FixtureHandle.Wait();
    }

    [TearDown]
    protected virtual void TearDown()
    {
        FixtureHandle.Set();
    }

FixtureHandle is a ManualResetEvent. This prevents NUnit from being too damn good and fast.

like image 137
nik.shornikov Avatar answered Oct 12 '22 11:10

nik.shornikov