// after "Latest Test Result" it should say "no failures"
assertXPathResultsContainText(projectPage, "//td", "(no failures)");
// there should be a test result trend graph
assertXPath(projectPage, "//img[@src='test/trend']");
// the trend graph should be served up with a good http status
Page trendGraphPage = wc.goTo(proj.getUrl() + "/test/trend", "image/png");
assertGoodStatus(trendGraphPage);
// The trend graph should be clickable and take us to a run details page
Object imageNode = projectPage.getFirstByXPath("//img[@src='test/trend']");
assertNotNull("couldn't find any matching nodes", imageNode);
assertTrue("image node should be an HtmlImage object", imageNode instanceof HtmlImage);
// TODO: Check that we can click on the graph and get to a particular run. How do I do this with HtmlUnit?
XmlPage xmlProjectPage = wc.goToXml(proj.getUrl() + "/lastBuild/testReport/api/xml");
assertXPath(xmlProjectPage, "/testResult");
assertXPath(xmlProjectPage, "/testResult/suite");
assertXPath(xmlProjectPage, "/testResult/failCount");
assertXPathValue(xmlProjectPage, "/testResult/failCount", "0");
assertXPathValue(xmlProjectPage, "/testResult/passCount", "4");
assertXPathValue(xmlProjectPage, "/testResult/skipCount", "0");
String[] packages = {"org.jvnet.hudson.examples.small.AppTest", "org.jvnet.hudson.examples.small.MiscTest", "org.jvnet.hudson.examples.small.deep.DeepTest"};
for (String packageName : packages) {
assertXPath(xmlProjectPage, "/testResult/suite/case/className[text()='" + packageName + "']");
}
// Go to a page that we know has a failure
HtmlPage buildPage = wc.getPage(proj.getBuildByNumber(3));
assertGoodStatus(buildPage);
// We expect to see one failure, for com.yahoo.breakable.misc.UglyTest.becomeUglier
// which should link to http://localhost:8080/job/wonky/3/testReport/org.jvnet.hudson.examples.small/MiscTest/testEleanor/
assertXPathResultsContainText(buildPage, "//a", "org.jvnet.hudson.examples.small.MiscTest.testEleanor");
HtmlAnchor failingTestLink = buildPage.getFirstAnchorByText("org.jvnet.hudson.examples.small.MiscTest.testEleanor");
assertNotNull(failingTestLink);
Page failingTestPage = failingTestLink.click();
assertGoodStatus(failingTestPage);
// Go to the xml page for a build we know has failures
XmlPage xmlBuildPage = wc.goToXml(proj.getBuildByNumber(3).getUrl() + "/api/xml");
assertXPathValue(xmlBuildPage, "//failCount", "2");