public TestEngine.TestResults doJobWithResult() throws Exception {
return TestEngine.run(testname);
}
}.now());
response.status = results.passed ? 200 : 500;
Template resultTemplate = TemplateLoader.load("TestRunner/results.html");
Map<String, Object> options = new HashMap<String, Object>();
options.put("test", test);
options.put("results", results);
String result = resultTemplate.render(options);
File testResults = Yalp.getFile("test-result/" + test + (results.passed ? ".passed" : ".failed") + ".html");
IO.writeContent(result, testResults);
try {
// Write xml output
options.remove("out");
resultTemplate = TemplateLoader.load("TestRunner/results-xunit.xml");
String resultXunit = resultTemplate.render(options);
File testXunitResults = Yalp.getFile("test-result/TEST-" + test.substring(0, test.length()-6) + ".xml");
IO.writeContent(resultXunit, testXunitResults);
} catch(Exception e) {
Logger.error(e, "Cannot ouput XML unit output");
}
response.contentType = "text/html";
renderText(result);
}
if (test.endsWith(".test.html.suite")) {
test = test.substring(0, test.length() - 6);
render("TestRunner/selenium-suite.html", test);
}
if (test.endsWith(".test.html")) {
File testFile = Yalp.getFile("test/" + test);
if (!testFile.exists()) {
for(VirtualFile root : Yalp.roots) {
File moduleTestFile = Yalp.getFile(root.relativePath()+"/test/" + test);
if(moduleTestFile.exists()) {
testFile = moduleTestFile;
}
}
}
if (testFile.exists()) {
Template testTemplate = TemplateLoader.load(VirtualFile.open(testFile));
Map<String, Object> options = new HashMap<String, Object>();
response.contentType = "text/html";
renderText(testTemplate.render(options));
} else {
renderText("Test not found, %s", testFile);
}
}
if (test.endsWith(".test.html.result")) {