|
[XP]
Create them, let them grow healthy and shiny and then replace them with droids
[
theboxx
]
A few days ago I attended a webinar from Agitar on JUnitFactory, that is an experimental test-generation service intended mainly for universities and research institutions. The aim of the service is to generate unit tests automatically starting from the code that requires to be tested. To keep the story short: unit tests retrofitting for legacy code. To be honest I haven't tried JUnitFactory yet, I have got an invitation from a friend of mine, so I was curious to learn more from the webinar. On the other side of the wire there were Alberto Savoia and Kevin Lawrence. The basic capability of JUnit Factory is to analyze your code and generate unit tests according to its semantic. The interesting thing that I have noticed in the webinar is that the tests that are produced are not only an empty scaffolding that you have to manually manage, but a good quality unit tests suite, sophisticated enough to understand for example the appropriate value to feed into a regular expression parser. Beware that the generation is not done on your machine, but on Agitar's servers: your code is uploaded to them and tests are sent back through the plugin. Therefore, you better not use it on your proprietary confidential code, but it's perfectly fine if you are working on an open source project. Other interesting considerations emerged during the webinar:
I have to confess that I have attended the webinar with some prejudice: practicing TDD every day I take great care of my unit tests and it sounds pretty weird to think about them as a disposable artifact, something that you should better automatically generate. It's also worth noticing that, while in the agile community it is by now commonly accepted that TDD is more a design practice rather than a testing practice, where tests are a second order artifact that constitutes your non regression safety net, in the bigger world beyond the agile sphere unit tests are still seen as an ideal practice: everybody talk about it and take it for granted, but in reality they are seldom implemented.
The title of this post is obviously a provocation, a loose and biased metaphor that resembles these doubts. Overall I think that JUnitFactory is darn interesting, also for agile teams, and even though it may not change dramatically your day-to-day practices, it is worth thinking about it. Finally, JUnitFactory uses AgitarOne behind the scenes, Agitar's product in support for unit testing practices. I think that this is a very smart move for Agitar: by releasing the technology to the public in a different way, they are getting good publicity and having a lot of feedback at the same time. Of course, if you are really serious about this approach, your company should consider buying AgitarOne's license. Hi, Thank you for the taking the time to write this blog and for the encouraging feedback and positive comments. It's nice to see someone who understands why and how test-after can come in handy ... even though it's always best to have more developer participation in testing upfront. Making our technology widely and freely available with JUnitFactory has been a lot of fun, and we look forward to more users and more feedback to make it even more useful going forward. Alberto --Alberto Savoia, February 10, 2007 05:46 PM
I don't see why generating a test necessitates throwing the old one away. Hand-written tests have their virtues, as you mention, and another is that they become imprinted in your brain--just like it's harder to drive back to a place if you rode there than if you drove there, it's just easier to grok a test that was written by you or someone who works closely with you. I am experimenting with using generated tests as another layer, much like system tests and acceptance tests augment unit tests. They tend to be at a slightly lower level than what I tend to write by hand, in a way being truer "unit" tests, and are fast enough to run before all check-ins. --Scott Vachalek, February 11, 2007 07:10 AM
Thanks for the comments & clarifications, they all make great sense. There has been also an interesting thread about this post in the XP mailing list, you may want to check it out (same subject as this post). --TheBox, February 11, 2007 09:04 PM
Post a comment
|