Well, funny you should mention this... I had a thought a few weeks ago about starting a blog to show how I have been doing TDD with Wicket. It seems like it is quite easy to do, but there were not many posts discussing ways do do some testing or examples of testing things ajax components etc

I have a couple of posts, just getting some of the basics set up... http://empty-your-cup.blogspot.com/

Hopefully I can get some time to demonstrate some simple page and component tests soon. Page testing can be fairly easy because you can just use the WicketTester to start the page. Testing a component can be a bit trickier sometimes because you need to use something like the TestPageSource.

Tests generally cover behaviour, for example "if I press this button a panel X should be shown", "The name text field should contain the name of the user", "Changing the first name updates the name in the model", "Errors should have a CSS class of 'error' added". All of these things are quite straight forward to test. We rely on some components working correctly eg that the TextField will generate a valid html textfield, so we shouldn't have to test that. We can test the behaviour of ajax calls - as long as the behaviour is something simple like the component should be updated/hidden/shown by checking it is in the ajax response.

The unit tests won't check that the CSS class 'error' shows the text in red with twinkling lights, but that isn't a behaviour. So we still have perhaps some manual testing, in various browsers, to make sure it looks ok. If someone changes some java code which stops a component displaying our unit tests should be able to fail and show us the cause. If someone changes the CSS and makes errors appear green... well, hopefully someone will notice that quickly.

I hope that gives you a hint. Stay tuned for more in the blog... today was my first day back at work in the new year so it might have to wait a short time!

ZedroS wrote:

Jason Lea wrote:
We decided to do Test Driven Development because we could use the WicketTester to help in development of our pages/components.

Hum, very interesting : the wicket testers classes are really functional and
efficient. I didn't look deep into them, considering (wrongly apparently)
that even if the tests would pass I couldn't be sure that the page would be
rendered fine. What's your feedback on this point ?

 Furthermore, is it easy as well to test only components ? Or do you have to
do "unit component tests" ?

To sum up my mail, I would love to have more insight of Wicket and TDD... :$

Thanks in advance ;)


Jason Lea

Reply via email to