xUnit framework: Equivalent of [TestFixtureSetUp] of NUnit in XUnit?

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

Using MS Test ClassInitialize() and TestInitialize() in VS2010 as opposed to NUnit

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(); } }

Why testFixture instead of TestClass?

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

How do I set up NUnit in Visual Studio 2022?

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).

Ignore Test or TestFixture based on a condition

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

JetBrains Resharper 9 Ultimate Test Runner error: NUnit.Core.UnsupportedFrameworkException: Skipped loading assembly {MyAssembly}

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

tech