The following is for the moment only a disertation on the possibility to ease the development of unit testing for the product I am working now. As a preamble I would say that in order to be able to test some parts of the product a developer would need a very long/complex/repetitive fixture. The first solution that came to me was to create unit tests using an IoC solution. Interesting… but this will link my test to a IoC solution (I like Spring Framework very much [smile/], but I don’t like too much dependency). A better solution would be to have a single test base that according to some other configurations to be able to load the required context. But this will not completely solve the dependency problem and may result in time in a large number of different base unit tests (specialized in different initialization types). What if I will remove completely the dependency to the IoC from my tests? How? …. using AOP. As you probably know both TestNG and JUnit provide very clear points where the fixture is (for those who don’t know this: TestNG declares a fixture method using a Configuration annotation; JUnit provides this by means of setUp method in TestCase or by extending TestSetup). Right now all I have to do is to write down some simple aspects that will initialize the test unit with the required info. For the moment the only AOP solution (I might be wrong here [sigh/]) that is able to cover both cases (normal pointcuts and annotation based pointcuts) is AspectWerkz. So starting with a solution that presented a high dependency I have finished with: any IoC solution (Spring, Pico, etc), any unit testing framework (TestNG, JUnit) and AspectWerkz. What do you think about this? (if you see any possible drawbacks don’t let me go a wrong way [smile/]).
Daily Archives: October 26, 2004
Independent IoC-ish unit testing
Filed under Uncategorized