Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nunit runs each test twice

I encounter a problem running my tests via NUnit. I dont know why but each test runs twice. The point is that on another laptop it normally runs only one time.

Have anyone the same problem and know how to deal with it?

like image 436
MrPug Avatar asked Sep 02 '15 07:09

MrPug


3 Answers

I had the same problem. In my case, I had both the Visual Studio extension and the NuGet package of the NUnit Test Runner installed. It seems they were both executing the tests, resulting in tests being run twice.

Uninstalling the Visual Studio extension solved the issue.

like image 87
ngm Avatar answered Oct 11 '22 07:10

ngm


I had a similar problem where running the test with the Visual Studio NUnit3 runner, the test would run only once but when running in the command line with NUnit3-Command.exe, the test would run twice. I spent way too long chasing this down. I noticed that the command line runner was reporting 2 tests were run and came to the conclusion it was an issue in the dll. This may sound crazy but I copied all my test code into a new class, deleted the old, compiled and the test now runs just once in both scenarios.

like image 33
john rains Avatar answered Oct 11 '22 07:10

john rains


In my case, it was having a base class and a derived class both having the TestFixture Attribute. All tests from the derived class would run twice.

Fixed it by only putting attribute on base class.

like image 27
SerenityNow Avatar answered Oct 11 '22 08:10

SerenityNow