Reputation: 485
using System;
using System.Collections;
using NUnit.Framework;
namespace Tests.MyTest
{
public class SpikeSuite
{
[Suite]
public static IEnumerable Suite
{
get
{
var suite = new ArrayList
{
new SpikeTest(),
};
return suite;
}
}
}
[TestFixture]
public class SpikeTest
{
[SetUp]
public void Setup()
{
Console.WriteLine("Test setup");
}
[TestFixtureSetUp]
public void FixtureSetup()
{
Console.WriteLine("Test fixture setup");
}
[Test]
public void TestMethod()
{
Console.WriteLine("Test method");
}
}
}
When I run the above mentioned fixture the output I get is:
Test fixture setup
.Test setup
Test method
Test fixture setup
.Test setup
Test method
How is it that the test setup, fixture setup and test method being executed twice?
Upvotes: 4
Views: 1343
Reputation: 136
Uninstalling the NUnit Test Adapter and re-installing fixed this issue for me.
In Visual Studio > Tools > Extensions and Updates > Remove NUnit Test Adapter then re-install it
Upvotes: 0
Reputation: 201
Check that your test project is not referenced by another test project. In that case it will appear in two bin folders and be run twice.
Upvotes: 1