I'm trying to execute NUnit tests through a Windows Form application with NUnit Engine, but I don't understand how to set the path for the DLL where my tests are (I have already included the DLL in the references). When I click a button, I want the tests to start; however, NUnit opens and then immediately closes without doing anything. Here's what I have:
namespace ATF.GUI
{
public partial class ATF_Main : Form
{
TestPackage package;
ITestEngine engine;
public ATF_Main()
{
InitializeComponent();
}
private void ATF_Main_Load(object sender, EventArgs e)
{
string path = Assembly.GetExecutingAssembly().Location;
package = new TestPackage(path);
package.AddSetting("Working Directory", Environment.CurrentDirectory);
// Prepare the engine
engine = TestEngineActivator.CreateInstance();
}
private void btnStartTests_Click(object sender, EventArgs e)
{
using (ITestRunner runner = engine.GetRunner(package))
{
// Execute the tests
XmlNode result = runner.Run(null, TestFilter.Empty);
}
}
I never got a real answer to this but I figured it out myself.
You could also add the assembly locations to a List if you have multiple test assemblies.