2

I have two unit test projects that test different Nancy modules. Both projects create a fake bootstrapper with something like this:

protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
   base.ConfigureApplicationContainer(container);
}

protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
   base.ApplicationStartup(container, pipelines);
}

The problem I'm having is when I run the tests individually, they work fine. When I run them all together it seems like one set of the modules gets loaded, and then one or the other set of unit tests pass, depending on the order the modules were loaded in.

This seems to only happen in MS Test running. I'm using NCrunch (another unit test runner framework) and it seems to work there.

So, I'm guessing the issue here is that TinyIoC or Nancy are not being completely refreshed between test assemblies, or because I'm using DefaultNancyBootstrapper and unit tests are all compiling into the same bin folder, it auto-discovers modules in other libraries that are not supposed to be loaded for the test being run (even though they are not referenced by the unit test project.)

Anyone run into something like this before?

Skami
  • 1,506
  • 1
  • 18
  • 29
Ilya
  • 995
  • 1
  • 11
  • 17
  • 3
    Wiring up all dependencies does not look like unit testing, it's more like integration testing. Why not use ConfigurableBootstrapper for your unit tests, and set only the components needed to test the module? If your module is to god-like, and has tons of dependencies which are hard to manually register, probably it's better if you think about splitting it. – Sunny Milenov Dec 23 '13 at 20:43
  • First, you have a good point -- these are integration tests. Second, I am planning to try to use ConfigurableBootstrapper. I've already used it in some tests with good results. Regardless, it seems weird that while one unit testing framework garbage collects objects and app domains as expected, the MS Test doesn't. Even though I set static properties to null and call Dispose on the Bootstrapper object, etc. – Ilya Jan 02 '14 at 15:51

0 Answers0