I am running NUnit tests using RemoteTestRunner. In the end, I get a TestResult object containing the results. The unit test project compiles as a console application.
The problem is, after running the tests, the output gets somehow redirected, and I can’t print the results to the console.
Here’s the code. It doesn’t output anything, not even "Open, sesame!" (although it does run to the end – confirmed in the debugger).
Any suggestions?
Also, is there a built-in way to list the failed results, given the TestResults instance?
public static void Main()
{
TestPackage testPackage = new TestPackage(AssemblyPath);
RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
remoteTestRunner.Load(testPackage);
TestResult testResult = remoteTestRunner.Run(null);
Console.WriteLine(testResult.IsFailure);
Console.WriteLine("Open, sesame!");
}
public static string AssemblyPath
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return path;
}
}
Try to store the current output stream of the Console before running the tests with
Then setting it back once the run has been performed with
I haven’t been able to find any. However, the following piece of code should provide you with some help. It recursively introspects the composed
TestResultstructure and outputs the result of each test to the console.