Note: I am using TestDriven.NET 3.0.2749 and NUnit 2.6.0.12051 for this project.
I have installed both TestDriven.NET and NUnit and am trying to get TestDriven.NET to run all tests in a test class via the right-click context menu.
From the TestDriven.NET documentation:
If the code editor window is selected, the test(s) to execute will be determined by the position of the caret; individual tests are executed by right-clicking anywhere inside a test method and selecting 'Run Test(s)' as shown in Figure 2; all tests in a test fixture are executed by right-clicking inside a class (but outside of any method) and selecting 'Run Test(s)'; all tests in a namespace are executed by right-clicking inside a namespace and selecting 'Run Test(s)'.
I can successfully run a specific test method using the right-click context menu and the NUnit GUI runner will successfully run all test for a given class, but I would like to use the quick access TestDriven.NET provides for this tasks while I'm developing.
I receive the follow error when I place the caret outside of test method:
The target type doesn't contain tests from a known test framework or a 'Main' method.
Updated 1: Added example code.
Example code to test:
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));
}
}
}
To run all the tests in a default group, choose the Run icon and then choose the group on the menu. Select the individual tests that you want to run, open the right-click menu for a selected test and then choose Run Selected Tests (or press Ctrl + R, T).
TestDriven.NET makes it easy to run unit tests with a single click, anywhere in your Visual Studio solutions. It supports all versions of Microsoft Visual Studio and it integrates with the best . NET development tools. Latest release.
TDD stands for Test Driven Development, and it's a design process in software development. It relies on the repetition of a very short development cycle, and the requirements are turned into very specific test cases. There are a couple of steps in the TDD process: Write a unit test that fails.
I just encountered this exact problem when using the same versions of TestDriven.NET and NUnit (3.0.2749 and 2.6.0.12051).
The issue is that TestDriven.NET 3.0 doesn't support NUnit 2.6, so it won't recognize the NUnit [Test] and [TestFixture] attributes. Thus, TestDriven.NET will still run your individual test functions, but as Ad Hoc (as displayed at the end of the Pass/Fail/Skip message when testing).
I was able to solve the issue by installing a newer 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 the tests in the fixture at once and see (NUnit 2.6.0) displayed at the end of the test output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With