Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Running NUnit tests programmatically
using System;
using NUnit.Core;
using NUnit.Framework.Constraints;
namespace oneshore.qa.testrunner
{
class TestRunner
{
public static void Main(String[] args)
{
//get from command line args
String pathToTestLibrary = "C:\\dev\\oneshore.Tests.DLL";
TestRunner runner = new TestRunner();
runner.run(pathToTestLibrary);
}
public void run(String pathToTestLibrary)
{
CoreExtensions.Host.InitializeService();
TestPackage testPackage = new TestPackage(@pathToTestLibrary);
testPackage.BasePath = Path.GetDirectoryName(pathToTestLibrary);
TestSuiteBuilder builder = new TestSuiteBuilder();
TestSuite suite = builder.Build(testPackage);
TestResult result = suite.Run(new NullListener(), TestFilter.Empty);
Console.WriteLine("has results? " + result.HasResults);
Console.WriteLine("results count: " + result.Results.Count);
Console.WriteLine("success? " + result.IsSuccess);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment