After 3 years of not having touched Java, I decided to have a quick look at JUnit 4 [1] and I must say that they changed a lot to the positive.
I look at I have the impression that this is rather complex. With the after before ( I can understand that you want to have a setup shared by a bunch of tests of the same test case but more...) I think that the descriptions in SUnit are good.
I find it rather cool to be able to put tests anywhere I want: In Magritte/Pier I was forced to duplicate most of the model hierarchy for the test-cases (some tests are designed to run on whole hierarchies), what is rather annoying to maintain. Being able to put the tests anywhere would make it much easier to navigate, browse and maintain the tests.
I think the way JUnit is doing the tests is simpler than the one of SUnit, naming conventions and declarations are rather difficult to understand. Basically JUnit know 3 different kinds of annotations, translated to Smalltalk this would look like:
- test-methods can be implemented anywhere in the system and are taged with the annotation <test>.
- setUp- and tearDown-methods can be implemented anywhere in the system and are taged with the annotation <setUp> and <tearDown>.
- resources are being implemented anywhere in the system and are taged with the annotation <begin> and <end> (it took me 3 years to understand how resources work in the current implementation).
Of course one could implement a facade to make the tests run the old way. And subclassing TestCase would still work, for those tests that need a more complex object setup for the tests.
Lukas
-- Lukas Renggli http://www.lukas-renggli.ch