How to Run NUnit Tests from C# Code
Posted
by Dror Helper
on Stack Overflow
See other posts from Stack Overflow
or by Dror Helper
Published on 2010-05-13T10:11:22Z
Indexed on
2010/05/16
14:50 UTC
Read the original article
Hit count: 269
I'm trying to write a simple method that receives a file and runs it using NUnit. The code I managed to build using NUnit's source does not work:
if(openFileDialog1.ShowDialog() != DialogResult.OK)
{
return;
}
var builder = new TestSuiteBuilder();
var testPackage = new TestPackage(openFileDialog1.FileName);
var directoryName = Path.GetDirectoryName(openFileDialog1.FileName);
testPackage.BasePath = directoryName;
var suite = builder.Build(testPackage);
TestResult result = suite.Run(new NullListener(), TestFilter.Empty);
The problem is that I keep getting an exception thrown by builder.Build stating that the assembly was not found.
What am I missing? Is there some other way to run the test from the code (without using Process.Start)?
© Stack Overflow or respective owner