2013-01-31 88 views
1

如何以編程方式決定在NUnit中運行哪些測試?即使用NUnit類別屬性在dll中運行某些測試?

CoreExtensions.Host.InitializeService(); 
TestPackage testPackage = new TestPackage(pathToSomeDLL); 

// filter by category here?? 

SimpleTestRunner simpleTestRunner = new SimpleTestRunner(); 

// or here? 
simpleTestRunner.Load(testPackage); 

//... maybe here? 
testResult = simpleTestRunner.Run(NullListener.NULL); 

回答

0

您可以提供額外的參數來SimpleTestRunnerRun方法,像這樣:

var filter = new CategoryFilter("MyCategory"); 
simpleTestRunner.Run(NullListener.NULL, filter, false, LoggingThreshold.Off);