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 { }
After a bunch of research and experimentation, I’ve found the answer. For the record, the current release of nUnit 2.5 Alpha does not seem to contain templates for test projects in Visual Studio 2008. I followed the directions here which describe how to create your own project templates and then add appropriate registry entries that … Read more
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 prevent tests from running in parallel by adding the [NonParallelizable] attribute, which can be added in test, class and assembly level.
There’s another similar question here on Stack Overflow, where I posted my answer with what worked for me. I can set breakpoints and start NUnit directly from Visual Studio 2010 with Debug -> Start New Instance (which I think is your goal). I set nunit.exe as the external program in project -> Properties -> Debugging … Read more
No, the closest you will get is with the [Ignore] attribute. However, MSTest offers other ways of disabling or enabling tests using Test Lists. Whether you like them or not, Test Lists are the recommended way to select tests in MSTest.
Use an environment variable to pass the information. Use set from the command-line or <setenv> from NAnt. Then read the value using Environment.GetEnvironmentVariable().