Do I need to register dependencies for ALL my NancyModules when testing just one route?

StackOverflow https://stackoverflow.com/questions/8168925

  •  03-03-2021
  •  | 
  •  

Question

Do I need to register dependencies for ALL my NancyModules when testing just one route, or is there a way to JUST register dependencies that apply to the module I want to work with?

I'm using the stuff in Nancy.Testing like the Browser class and the ConfigurableBootsrapper for my tests. But for the actual web project, I'm using the StructureMapNancyBootstrapper and register my dependencies via a StructureMap Registry sub-class.

I'm accustomed to unit testing to build out web interfaces where my test only touches one actual layer/class. This style of testing is more like integration testing where my tests are influenced by the entire stack. What I'm looking for is a way to get a little closer to unit testing.

Was it helpful?

Solution

As long as you only add the one module to the configurable bootstrapper (with.Module) you shouldn't need to. It resolves all modules at startup (to build the route cache), but "all modules" in that case is only the module you've specified - if you're still letting it discover all the modules then you'll need to also register the dependencies for them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top