I'm setting up a UnitTest Suite using MSTest for an existing application.
The application supports two different databases (SQLServer and MSAccess), so we want each Unit Test to run against both databases.
I have kind of achieved this functionality with the following class construct
namespace SQLServer {
[TestClass] public class SQLServer : TestCases { }
}
namespace MSAccess {
[TestClass] public class MSAccess : TestCases { }
}
public abstract partial class TestCases {
//Tests for Module1
[TestMethod] public void Module1_Test1() { }
}
public abstract partial class TestCases {
//Tests for Module2
[TestMethod] public void Module2_Test1() { }
}
This works more or less as expected, but of course it's not very nice because all TestMethod
s must be in the same class. It also has the downside that two TestMethod
s for different modules cannot have the same name, making the names of the methods unnecessarily long.
My main problem is however that I lose the grouping of TestMethod
s by module. The grouping in Test Explorer that I achieve with this is:
UnitTestProject (Project name)
UnitTestProject.SQLServer (Namespace name)
SQLServer (Class name)
Module1_Test1 (Function name)
Module2_Test1
UnitTestProject.MSAcccess
MSAccess
Module1_Test1
Module2_Test1
What I actually want is:
UnitTestProject
SQLServer
Module1
Module1_Test1
Module2
Module2_Test1
MSAccess
Module1
Module1_Test1
Module2
Module2_Test1
Is there a way to achieve this?
使用TestCategory
属性,并确保在“测试资源管理器”窗口中按“特质”对测试进行分组。
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.