A month or two ago I was thinking about test-driven development and what a pain it is to write test cases. Or, well, test at all for that matter. Who needs testing when you have users to do that for you?
At work we have this fairly complicated UI that eventually interacts with stateless session beans in the whole wizbang J2EE world. Usually, I spend most of my debugging time tickling the backend rather than fooling with the UI so all tasks of logging in, navigating windows, setting up data and so forth are just overhead.
One previous company I worked at had an excellent solution to automating all of that without winrunner or other similar crap: everything in the GUI created a command string that was then fed to a command parser to perform the task. You could use these command strings exactly as a script to control the app. Had a crash? Just replay the customer’s log to see the segfault.
So I had the rather obvious idea: use an EJB 3 interceptor with XStream to record method calls, their parameters and return values to the server logs. Later, we can execute these logs to replay all the SLSB calls and check the return values. Ta-da, we have some automated tests without even trying. Not full coverage of course, but better than nothing at all.
Another developer got the lucky task of implementing it, but I’ve just started using it today. Very slick. Now we just need a Lisp interpreter and an email client.
Re: Meh
2001… weren’t people still writing CGI apps in COBOL back then?
Heh, yeah, it’s obvious, but still a lot of value for a day’s worth of code.