STAThreadAttribute RequiresSTAAttribute

NUnit and WatiN

Today a colleague was trying to diagnose why some long neglected UI tests were failing.  He quickly discovered that the tests weren’t failing because of changes to the code under test but because our UI test framework was misbehaving.  Since I’d been involved in developing parts of the framework he came to me to see what I remembered.

Our test framework is essentially a wrapper around WatiN that controls certain application specific tasks like logging in, navigating with our windowing system, or interacting with some of our more complex controls.  These tests were failing because the framework wasn’t able to get a reference to our main application window so a null reference exception was being thrown.  Now, we’ve made quite a few changes to our application but our windowing system certainly isn’t among them so why were the tests failing?