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)); } } }
unit-testing visual-studio-2010 nunit testdriven.net
Noren
source share