I have heard that Java EE unit testing is much harder than standard Java applications. The testing for my company’s application stays at User Acceptance testing. We verify UI and functions behave as they are supposed to. Does it make sense to do unit testing on Java EE applications? If yes, what are some good starting points?
Share
Of course it makes sense.
Let me guess: in the case of your company, when you make a minor change to a central component, I suppose that you’ll repeat once and again your User Acceptance Tests. A real PITA, and overboring for a development team, in my opinion.
Unit testing allows you to develop in a consistent way the different layers of your Java EE app (i.e. view, business and model), AND, moreover, it allows you to do regression testing. The magic with regression testing is that in a long life application, this provides you a way to be sure that a new patch, code refactoring, or evolution doesn’t break the current system behaviour. And it can be done automatically if you use a continuous integration tool.
So, you can write unit test for business and model layer in a direct way using, as an example, jUnit. And here comes the problem with Unit testing in Java EE apps: What do we do with the view layer?
Well, for the view layer you can use an automated test tool, say Apache jMeter, to check the expected behaviour of your Webapps, check your data validation, your system stability (programing long tests with a regular number of users) and scalability (with increasing and decreasing concurrent users), stress testing, etc. (I know it’s not Unit testing, but it can be used in a similar way for regression testing).
I think it’s a capital part of every software project, and I invite you to apply it to some of your project, and compare by yourself the final result.