我正在使用 Selenium 和 C# 进行自动化,我想通过代码调用 NUnit,如下所示:
CoreExtensions.Host.InitializeService();
TestPackage testPackage = new TestPackage(@"D:\Automation\bin\Debug\Test.dll");
RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
remoteTestRunner.Load(testPackage);
//TestFilter filter = new NameFilter(new TestName() { Name = "Test1" });
TestResult testResult = remoteTestRunner.Run(
new NullListener(),
TestFilter.Empty,
false,
LoggingThreshold.Off
);
我可以使用如下的类别过滤器运行测试
remoteTestRunner.Run(
new NullListener(),
new CategoryFilter("MyCat"),
false,
LoggingThreshold.Off
);
但我想执行特定的测试。如何设置套件过滤器?我尝试了以下方法,但它不起作用:
TestFilter filter = new NameFilter(new TestName() { Name = "Test1" });
TestResult testResult = remoteTestRunner.Run(
new NullListener(),
filter,
false,
LoggingThreshold.Off
);
如何运行特定测试以及如何通过代码传递参数?