home links tools blog about

AngryPets Blog

home

I broke NUnit


For those of you that haven't used nUnit yet, sorry. I broke it.

So I'm working on a cool new little pet project at home. And i wanted to set it up with a number of spiffy Unit Tests. I also wanted to make sure that exceptions are thrown when the component fires up and can't locate config info correctly.

So, I did something sick... I simulated an AppDomain firing up with incorrect config data. Creating the AppDomain is pretty easy. The trick came from trying to test instantiation of my component/type inside of that domain -- especially because my component is a 'static class' (private constructor with only static methods).

So here's what I did
1) Create the new AppDomain,
2) Remotely load an assembly into that domain (this assembly acts as a relay/proxy/scaffold in the remote domain, where I can further load assemblies and instantiate objects, and then pass references to those objects back to my executing (original) appDomain.
3) Once my scaffolding/proxy/relay is built... load a new assembly (of the type I want to test), instantiate an instance of the type I want to test (using Activator.CreateInstance (and set to use non-public constructors)), and pass a handle back to my calling appDomain.

The good news, it works PERFECTLY. I can step into it, watch the wheels churn, everything works 100% as desired. Makes me feel tough...

The bad news, nUnit chokes on it, and throws serialization errors. Just to make sure, I fired up the test itself (outside of nUnit) and stepped into it there ... worked perfectly there as well. (i.e. fire up a console app, tell it to run my unit test.testxxxmethod() and everything works fine... nUnit just can't handle it.)

Must be something about how nUnit already creates proxies/etc. where it executes the tests to be run. (i.e. I'm probably opening a new appdomain from an app domain created by nUnit -- all that marshalling by ref is probably throwing it for a loop).

*sigh*


posted on Friday, December 03, 2004 6:03 PM
 

Existing Comments:

# The Code that broke NUnit (or the day that all of the clowns died) - Posted: 12/13/2004 8:36 PM - By: AngryPets.com :: Blog
   False Alarm... NUnit is fine. Everyone go back about your business...



Add your own comment:


Go to http://blog.angrypets.com where comments are enabled.