能否构建一个Visual Studio Test Explorer搜索表达式,使其能够实际根据 名称和价值 的属性?例如,像 Trait:TestSize=Large
. 我似乎不知道如何让这个工作,经过几个小时的搜索,它不清楚我应该从Visual Studio,NUnit或NUnit测试适配器寻找文档。
[TestFixture]
public class SampleTestFixture {
[Test]
[Property("TestSize", "Large")]
public void Test1() { ... }
}
更多的细节。
我不确定我的理解是否正确,但如果你想基于TestCaseName过滤测试运行你想要的东西,你应该使用TestEngineAPI.了解更多信息。https:/github.comnunitdocswikiTest-Engine-API。
ITestEngine engine = TestEngineActivator.CreateInstance();
TestPackage package = new TestPackage("my.test.assembly.dll");
ITestRunner runner = engine.GetRunner(package);
// Run all the tests in the assembly
XmlNode testResult = runner.Run(this, TestFilter.Empty);
其中TestFilter.Empty可以是这样的。new TestFilter($"<filter><or><name>Test1</name></or></filter>");