Skip to content

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;
class TestRunner
public static void Main(String[] args)
//get from command line args
String pathToTestLibrary = "C:\\dev\\oneshore.Tests.DLL";
TestRunner runner = new TestRunner();;
public void run(String pathToTestLibrary)
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);
Copy link

AhlamJelti commented May 7, 2021

Hi sir , can i ask u please ? I 'm using nunit 3 and NUnit.Core work just with Nunit 2 .. i isued NUnit .engine.API but i still have problems .. could you help me please ?

Copy link

fijiaaron commented May 8, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment