YaK:: WebLog #535 Topic : 2006-04-24 17.19.31 matt : NUnitForms, continuous integration, and modal dialogs [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
  [Back to weblog: pretention]  
[mega_changes]
[photos]

NUnitForms, continuous integration, and modal dialogs

A landmine to watch out for when using NUnitForms with continuous integration environments like CruiseControl.NET, Draco.NET, etc.


A heads up (and request for comments) for anyone who will be using NUnitForms (http://nunitforms.sourceforge.net/) in continuous integration (or plain old automated build/test) environments like CruiseControl.NET (http://ccnet.thoughtworks.com). If you are running the build process from a *service* like CC.NET does, NUnitForms will not be able to test any modal dialogs.

NUnitForms has a way to test modal dialogs very effectively, and if you run it as a non-service in nunit-gui or nunit-console, it works just fine. The problem comes when it tries to *display* a modal dialog inside of a service context. Service here means a standard Windows service -- nothing special. You see, you can't create modal dialogs from a program running as a service.

You might be thinking, "What keeps me from creating them when running under a service?" The answer is that you will get an exception if you try:

"System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."

This is a blessing and a curse at the same time. Back in NT 4.0 days, some jackasses used to actually display modal dialogs on a service running on a server. Admins would think something was hung, reboot the box (if an option) or go crazy since you can't get rid of a modal dialog being displayed in lala-land. There is actually an option to work around this exception using MessageBoxOptions, but we aren't using a MessageBox -- this is a Form.

I ran into this last week at work (http://www.imeem.com) when some NUnitForms tests we wrote passed on our machine, but not on the build machine. It turns out this was the problem. Crap. There's a couple of options -- when unit testing the form, make it non-modal; or, run the CC.NET service as a commandline app on a logged in desktop.

I don't like either of those options, anyone have other suggestions?

Discussion:

showing all 1 messages     [Show 3 7 *10* 14 30 100 999 days or *10* 30 50 100 999 messages]

2006-04-25

by robmyers:
Nice find. I don't know enough about NUnitForms to comment technically, but of your two choices, I suspect I'd choose the latter: Run the tests from the command line. Changing code just for testing is always an icky proposition.

Post a new message:

   

(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2006-04-24)       [Login]
(No back references.)