I have a nunit class library containing test cases. I want to programmatically get a list of all tests in the library, mainly the test names and their test ids. Here is what I have so far:
var runner = new NUnit.Core.RemoteTestRunner();
runner.Load(new NUnit.Core.TestPackage(Request.PhysicalApplicationPath + "bin\\SystemTest.dll"));
var tests = new List<NUnit.Core.TestResult>();
foreach (NUnit.Core.TestResult result in runner.TestResult.Results)
{
tests.Add(result);
}
The issue is that runner.TestResult is null until you actually run the tests. I obviously don't want to run the tests at this point, I just want to get a list of which tests are in the library. After that, I will give users the ability to select a test and run it individually, passing in the test id to the RemoteTestRunner instance.
So how can I get the list of tests without actually running all of them?