I know how to run complete NUnit assemblies from C# Code
TestPackage testPackage = new TestPackage(assemblyName);
RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
remoteTestRunner.Load(testPackage);
TestResult testResult = remoteTestRunner.Run(new NullListener(), TestFilter.Empty, false, LoggingThreshold.Error);
But how can I run single TestFixtures or even Single Tests?
Thanks to @Tony Hopkinson I found the solution.
I just had to create a class inheriting from TestFilter
and overwrite the Match
function in there.
public class SingleTestFilter : TestFilter
{
private string testName;
public SingleTestFilter(string TestName)
{
testName = TestName;
}
public override bool Match(ITest test)
{
return test.TestName.Name.Equals(testName);
}
}
And then call the remoteTestRunner.Run
with it as parameter.
remoteTestRunner.Run(new NullListener(), new SingleTestFilter("MyTest"), false, LoggingThreshold.Error);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With