Creating a class library project in my solution, dropped nunit, tests are not recognized
I have a simple solution where I put in a c# class library project, and referenced nunit dll etc.
I created a .cs file, added [testfixture] and a simple [test]
If I go to Test -> Run -> Test in current context (or even all in solution)
I get the error:
开发者_C百科No tests were run b/c no tests are loaded or the selected tests are disabled.
I did compile the project.
SomeTest.cs
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
[TestFixture]
public class SomeTest
{
[Test]
public void Test1()
{
Assert.AreEqual(1, 1);
}
}
- In case of NUnit, I doubt whether VisualStudio support by default for running tests. Your problem might be simplified if you use VisualStudio.TestTools.UnitTesting (in case you dont actually need nUnit)
If you do require nUnit, try looking here
I figured out the problem. The problem is that you have added the test project as a class library. There is a template available with VisualStudio that goes 'Test Project' that creates a test project. But I am guessing that it does something behind the screens to enable you to run the tests from Visual studio. I verified this by creating two projects - one of type Test Project and one of type Class Library.
I had the same test class in both projects, but I was able to run the test only in the 'Test Project'. But this worked only for Microsoft's inbuilt unit testing framework. Nunit doesn't seem to work still(even if you create a test project and add a nunit test there).
You could try VisualNUnit, which is a test runner for Visual Studio 2010.
Are test class and test method public?
Per default template classes are private and test classes and methods have to be private, non static and non abstract.
Some code would be nice ;)
精彩评论