Ignore all NUnit tests in a file
[TestFixture, Ignore(“reason”)] public class YourTestFixture { } Or if you prefer to break your attributes out to one per line: [TestFixture] [Ignore(“reason”)] public class YourTestFixture { }
[TestFixture, Ignore(“reason”)] public class YourTestFixture { } Or if you prefer to break your attributes out to one per line: [TestFixture] [Ignore(“reason”)] public class YourTestFixture { }
There is no direct equivalent of [TestFixtureSetUp] in XUnit, but you can achieve similar functionality. This page lays out the translation between NUnit and XUnit (as well as a couple other C#/.NET test frameworks). However, XUnit largely got rid of setups/teardowns (this article explains why that decision was made). Instead, you need the test suite … Read more
Here is a simple example using TestInitialize and TestCleanup. [TestClass] public class UnitTest1 { private NorthwindEntities context; [TestInitialize] public void TestInitialize() { this.context = new NorthwindEntities(); } [TestMethod] public void TestMethod1() { Assert.AreEqual(92, this.context.Customers.Count()); } [TestCleanup] public void TestCleanup() { this.context.Dispose(); } }
I respect Mike Two’s response, but I would assert that the NUnit team got this very wrong, and the use of [TestFixture] is a semantic wart on the face of NUnit. A test class is not a fixture. From what I’ve dug into with regard to JUnit, I have not found any reference to a … Read more
You can add both NUnit Framework and NUnit Test Adapter using NuGet Packages. To do that, right click on your project in Solution Explorer, go to Manage NuGet packages…, in the Browse section type nunit, install NUnit package and the corresponding version adapter (NUnitTestAdapter for NUnit 2.x or NUnit3TestAdapter for NUnit 3.x).
Use some code in your test or fixture set up method that detects if the simulation software is installed or not and calls Assert.Ignore() if it isn’t. [SetUp] public void TestSetUp() { if (!TestHelper.SimulationFilesExist()) { Assert.Ignore( “Simulation files are not installed. Omitting.” ); } } or [TestFixtureSetUp] public void FixtureSetUp() { if (!TestHelper.SimulationFilesExist()) { Assert.Ignore( … Read more
NUnit contains a [TestCase] attribute that allows implementing parametrized tests. This does not exist out of the box in MSTest – it can be done via extensibility though. MsTest’s ExpectedException attribute has a bug where the expected message is never really asserted even if it’s wrong – the test will pass. NUnit ships with an … Read more
You don’t provide enough information to diagnose what is wrong with your project file, but it 3.9.0 of the NUnit Adapter does work with .NET Standard 2.0 and F#. I think that your test project is targeting .NET Standard. It needs to target .NET Core or .NET 4.6.1+. Test projects are treated like executables, they … Read more
As mentioned in the accepted answer, ReSharper 9 does not support NUnit 3. The solution as stated does work (i.e. update to ReSharper 10), however, for those who do not have this option (e.g. licensing), you can downgrade your version of NUnit by following the below steps: Open Nuget Package Manager Console by going to … Read more