Launch NUNIT with NUnit.Gui.AppEntry.Main

Asked by Andrew Walker

I am using NUNIT 2.5.8.10295 on Windows XP to run some Unit Test. As a convenience for my user, I let them Launch NUNIT from a WPF C# application. Following a suggestion on StackOverflow (http://stackoverflow.com/questions/195061/how-to-run-nunit-programmatically), I use:
NUnit.Gui.AppEntryMain(new string[] { @"MyNunitTestFixtures.dll"});

Everything works fine. The user hits the button, NUnit is launch. The user picks the test(s) he wants and runs them and gets his familiar green(or red) status bars. The problem occurs when the user dismisses NUNIT, goes back to the WPF app and then launchs NUnit again. On the second time an exception is thrown of type:
{"Object reference not set to an instance of an object."}
I've printed the stack trace last. Any ideas what's going on? Is it unreasonable to launch NUNIT from my main apps GUI? Is there a better way?

   at NUnit.Util.SettingsGroup.GetSetting(String settingName)
   at NUnit.Util.SettingsGroup.GetSetting(String settingName, Boolean defaultValue)
   at NUnit.UiKit.TestSuiteTreeView..ctor()
   at NUnit.UiKit.TestTree.InitializeComponent()
   at NUnit.UiKit.TestTree..ctor()
   at NUnit.Gui.NUnitForm.InitializeComponent()
   at NUnit.Gui.NUnitForm..ctor(GuiOptions guiOptions)
   at NUnit.Gui.AppEntry.Main(String[] args)
   at Tools.TransmitterCommTool.MainWindow.m_ctrlBtnNUnit_Click(Object sender, RoutedEventArgs e) in C:\Projects\TransmitterSoftware\TransmitterCommunicationTool\MainWindow_Serial.cs:line 525

Question information

Language:
English Edit question
Status:
Answered
For:
NUnit V2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Charlie Poole (charlie.poole) said :
#1

My guess is that NUnit is still residing in memory after you execute it and that
some of the initialization code is not dealing well with a second invocation.
You might try launching it as a process.

Charlie

On Tue, Nov 16, 2010 at 1:38 PM, Andrew Walker
<email address hidden> wrote:
> New question #134327 on NUnit V2:
> https://answers.launchpad.net/nunitv2/+question/134327
>
> I am using NUNIT 2.5.8.10295 on Windows XP to run some Unit Test.  As a convenience for my user, I let them Launch NUNIT from a WPF C# application.  Following a suggestion on StackOverflow (http://stackoverflow.com/questions/195061/how-to-run-nunit-programmatically), I use:
> NUnit.Gui.AppEntryMain(new string[] { @"MyNunitTestFixtures.dll"});
>
> Everything works fine.  The user hits the button, NUnit is launch. The user picks the test(s) he wants and runs them and gets his familiar green(or red) status bars.  The problem occurs when the user dismisses NUNIT, goes back to the WPF app and then launchs NUnit again.  On the second time an exception is thrown of type:
> {"Object reference not set to an instance of an object."}
> I've printed the stack trace last.  Any ideas what's going on?  Is it unreasonable to launch NUNIT from my main apps GUI?  Is there a better way?
>
>   at NUnit.Util.SettingsGroup.GetSetting(String settingName)
>   at NUnit.Util.SettingsGroup.GetSetting(String settingName, Boolean defaultValue)
>   at NUnit.UiKit.TestSuiteTreeView..ctor()
>   at NUnit.UiKit.TestTree.InitializeComponent()
>   at NUnit.UiKit.TestTree..ctor()
>   at NUnit.Gui.NUnitForm.InitializeComponent()
>   at NUnit.Gui.NUnitForm..ctor(GuiOptions guiOptions)
>   at NUnit.Gui.AppEntry.Main(String[] args)
>   at Tools.TransmitterCommTool.MainWindow.m_ctrlBtnNUnit_Click(Object sender, RoutedEventArgs e) in C:\Projects\TransmitterSoftware\TransmitterCommunicationTool\MainWindow_Serial.cs:line 525
>
>
> --
> You received this question notification because you are an answer
> contact for NUnit V2.
>

Can you help with this problem?

Provide an answer of your own, or ask Andrew Walker for more information if necessary.

To post a message you must log in.