directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <>
Subject About unit tests
Date Sun, 27 Dec 2009 23:04:42 GMT

the unit tests are based on annotations to start a DirectoryService or 
to inject LDIFs. It's very convenient, and allows us to focus on the 
test instead of spending time programatically launching the DS. For 
those who are not used to this portion of the server, here is how it works :

we have basically 3 level of tests :
- suites, whch is a list of classes to run
- class containing one to many tests
- tests, which are methods in the previpus class.

When we run the tests, we run either a suite or a class, we can't 
explicitely launch a single test (except in Eclipse, but it's a hack).

The annotations can be set at each level (suite, class, test) so you can 
spare the cost of initialiazing a new DS for every test, assuming we can 
revert changes done at each level (this is currently the case in ADS).

So if we define a DS at the suite level, it can be use by *every* test. 
If we do the same at the class level, then it will hide the suite level 
DS, and be used by every tests in this class. Alll the other classes 
will use the suite DS. Last, not least, a test can define its own DS 
too, masking the class and suite DS. if no DS is declared, then a 
default DS will be used.

So far, so good.

There is still a question though : right now, in order to start the DS 
at the very last moment, we don't create the DS until we run the test. 
I'm not sure it's the right strategy, because it forces the code which 
runs the test to be overly complex, dealing with all the cases.

I think that instanciating the Suite DS at the suite level, the Class DS 
at the class level, and the Method DS at the test level is probably a 
better strategy.

wdyt ?

Emmanuel L├ęcharny

View raw message