Running all tests in a test class using TestDriven.NET and NUnit

Note. I am using TestDriven.NET 3.0.2749 and NUnit 2.6.0.12051 for this project.

I installed both TestDriven.NET and NUnit, and am trying to get TestDriven.NET to run all the tests in the test class via the right-click context menu.

From the TestDriven.NET documentation:

If the code editor window is selected, the test for execution will be determined by the position of the carriage; individual tests are performed by right-clicking anywhere in the test method and selecting "Run Test (s)", as shown in Figure 2; all tests in the test device are performed by right-clicking inside the class (but outside of any method) and selecting "Run Test (s)"; all tests in the namespace are performed by right-clicking in the namespace and selecting "Run Test (s)".

I can successfully launch a special test method using the right-click context menu, and the NUnit GUI runner will successfully run the entire test for this class, but I would like to use TestDriven.NET quick access to complete these tasks while I am developing.

I get the following error when I put the caret outside the testing method:

The target type does not contain tests from a known test environment or the Home method.

Updated 1: Added sample code.

Sample code for testing:

namespace TDDN.Framework { public class ExampleClass { public ExampleClass() { } public Int32 Add(Int32 x, Int32 y) { return x + y; } public Int32 Subtract(Int32 x, Int32 y) { return x - y; } } } 

Unit tests:

 using NUnit.Framework; using TDDN.Framework; namespace TDDN.UnitTests { [TestFixture] // Cursor caret placed here results in error above. public class ExampleClassTests { [Test] // Cursor caret placed here works. public void Add_SumTwoIntegers_SumReturned() { ExampleClass exampleClass = new ExampleClass(); Assert.AreEqual(10, exampleClass.Add(5, 5)); } [Test] // Cursor caret placed here works also. public void Subtract_SubtractTwoIntegers_DifferenceReturned() { ExampleClass exampleClass = new ExampleClass(); Assert.AreEqual(5, exampleClass.Subtract(10, 5)); } } } 
+8
unit-testing visual-studio-2010 nunit testdriven.net
source share
2 answers

I ran into this exact problem when using the same versions of TestDriven.NET and NUnit (3.0.2749 and 2.6.0.12051).

The problem is that TestDriven.NET 3.0 does not support NUnit 2.6, so it will not recognize the NUnit [Test] and [TestFixture] attributes. Thus, TestDriven.NET will still run your individual test functions, but as an Ad Hoc (as shown at the end of the Pass / Fail / Skip message when testing).

I managed to solve the problem by installing a new version of TestDriven.NET (3.3 Beta 2), which fully supports NUnit 2.6 (see https://groups.google.com/d/msg/nunit-discuss/pTCDx2_L8jU/TlpULzE36wEJ ) Now you should be able to run all tests in the device at once and see (NUnit 2.6.0) displayed at the end of the test output.

+16
source share

I had exactly the same error message and similar behavior in carriage locations.

I already had the newest version of TestDriven.Net.

My problem was that my new TestClass did not have the specified category and it was filtered out (Tools → TestDriven.Net → General → Categories → Include Tests in Categories).

So, just specifying the correct Category, fixed my problem.

It was the same error message, but a different problem and solution.

0
source share

All Articles