简体   繁体   中英

VS2010 doesn't “see” any of the tests in a new test class

I've created a class of Unit tests in an existing project (as opposed to creating a whole new test project)

When trying to run the tests via the Test menu VS claims that no tests are loaded..

How do I solve this ? (except for rewriting all the unit tests in Nunit, that is )

Editing to answer the questions: the class and methods are public, [TestClass] and [TestMethod] annotations are all there

[TestClass]
    public class FunctionalTests
    {        

        [ClassInitialize()]
        public void ClassInit()
        {
            //do init stuff
        }


        [TestMethod]
        public void TestSomething()
        {
           //testing stuff
        }

Check that the class has the [TestClass] attribute and that the tests methods has the [TestMethod] attribute. It happened to me once and this was the problem.

我放弃了尝试使用VS2010的尝试,而是为测试创建了一个新的单独项目,一切都很好。

The ClassInitialize and ClassCleanup methods need to be static .

    [ClassInitialize()]
    public static void ClassInit()
    {
    }

    [ClassCleanup]
    public static void ClassCleanup()
    {
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM