On my way to “debugging” NUnit Tests with Enterprise Architect. I ran into issues with the NUnit Console runner – EA’s Debugger wouldn’t properly attach to it.
So I started investigating how I could make a very very simple NUnit runner to help me on that. During my research I found one helpful thread on Stackoverflow.com
What I did to solve my Issue:
First I converted my Test.dll to a Test.exe
Then I had to add 3 NUnit Refrences to this Project
Now with the hints from the Stackoverflow thread it was very easy to prepare a program.cs that would execute my tests.
The first line is pretty important as it set’s up the NUnit framework:
CoreExtensions.Host.InitializeService();
The rest is pretty straightforward – find the name – add to the Testpackage – and Execute:
SimpleTestRunner runner = new SimpleTestRunner();
TestPackage package = new TestPackage("Test");
string loc = Assembly.GetExecutingAssembly().Location;
package.Assemblies.Add(loc);
if (runner.Load(package))
{
TestResult result = runner.Run(new NullListener());
}
I don’t care about the Results in my Scenario – as I collect the results from a second run with the console runner as described in my other post – for other scenarios it will be necessary to evaluate the results after the Tests are run.
Now running the Test.exe allows me to use Enterprise Architects Debugger just fine.
I just signed up to your blogs rss feed. Will you post more on this subject?
NUnit 4 ever!
Quick question, how do you view the errors/ result after running it?
Quick question, how do you see the results after the test has run?