We spend several months in a project with green fields to remake the logical and business levels of our product. Using MEF (dependency injection), we have achieved a high level of code coverage, and I believe that we have a pretty solid product. As we work on more complex logic, the unit test has become increasingly difficult for me.
We use the CompositionContainer to query the types required by these complex algorithms. My unit tests are sometimes difficult to complete due to the lengthy installation process of the mock object that needs to take place, in order to be able to verify certain circumstances. My unit tests often take longer to write than the code I'm trying to test.
I understand that this is not only a problem with dependency injection, but with the design as a whole. Is the method design poor or lack of guilt for my overly complex tests? I tried base class tests, creating commonly used breadboard objects and ensuring that I use the container as much as possible to alleviate this problem, but my tests always end up being quite complicated and difficult to debug. What are some tips you saw to make these tests concise, readable, and effective?
Adam driscoll
source share