Commenting Functional Tests Comments



A few nice people commented on my posts on functional tests and suggested a few other alternatives:

  • Canoo Webtest. It’s XML-based which makes it go right out my window. Sorry about that. We are a small company where programmers have to do their share of test time. This means that we are not afraid of code, in fact we prefer it.
  • Jameleon. I had not seen this one, but looking at the tutorial it seems a lot more complex than the stuff we use now.
  • PureTest. This is a very competent scenario recorder/player, and I do like the guys at Minq. But as I stated earlier, recording HTTP will not test your page the way HttpUnit does with JavaScript and all.

I am truly happy with the way we do it now. We have a base testcase class that provides methods like clickButton(). These methods are implemented as Strategies by both a remote HTTP implementation and a local in-process mock implementation.

Writing the tests are really easy. All you have to do is:


public void testLoginWithCorrectNameSucceeds() {
  setFormText("Name", "foo");
  setFormTest("Password", "foo");

After a while you can start pushing common higher level functions such as login to the base class for easier reuse.

Since we use a object oriented web API all test fields with labels are rendered in the same way. This means that we can find the form by the labe which is a good thing, since it eliminates the need for artificial id’s.