Things I like about it:
- It uses real browsers to run the tests, quirks and all
- It's got a literate testing interface based on Hamcrest and inspired by LiFT.
public class HomePageTest extends HamcrestWebDriverTestCase {
@Override
protected WebDriver createDriver() {
return new HtmlUnitDriver();
}
public void testHomePageHasTitleAndHeading()
throws Exception {
goTo("http://test.intranet");
assertPresenceOf(title()
.with(text(startsWith("Agile"))));
assertPresenceOf(title()
.with(text(containsString("Cocking and Co."))));
assertPresenceOf(heading(1)
.with(text(equalTo("Agile Application Development"))));
}
}
This won't quite work out of the box, as there is no heading finder, but adding one is easy:
public class HeadingFinder extends HtmlTagFinder {
private final int level;
public HeadingFinder(int level) {
this.level = level;
}
@Override
protected String tagDescription() {
return "heading level "+level;
}
@Override
protected String tagName() {
return "h"+level;
}
public static HeadingFinder heading(int level) {
return new HeadingFinder(level);
}
}
It's fairly new, but there are now pre-built binaries available.