Skip to content

Instantly share code, notes, and snippets.

@fijiaaron
Created November 22, 2011 23:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fijiaaron/1387474 to your computer and use it in GitHub Desktop.
Save fijiaaron/1387474 to your computer and use it in GitHub Desktop.
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);
}
}
@AhlamJelti
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 ?

@fijiaaron
Copy link
Author

fijiaaron commented May 8, 2021 via email

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