Spring and Functional Tests
Recently on our project we created a “functional” unit test for some services. The test was designed to check the entire call stack from the service layer to the DAO and return some expected results. We are using Spring for dependency injection through our entire application. This functional test initially only referenced the service DLL’s as this is all we thought that had to be referenced. Upon execution, the test was failing due to “null or empty Context”. We knew that we had referenced the context in the configuration file correctly, but were perplexed at how the spring context were not loading.
We finally realized that it was an issue with Resharper and how the tests were executed differently then when run is Visual Studio using default run (ctrl + r, t)
Once this was solved, we were getting reference exceptions.
To solve this error, it is necessary to reference in your test project all of the DLL’s that are referenced in your Spring xml file. It will not work unless you do so.