@Override public void testStarted(WikiTestPage test) { String pageName = test.getFullPath(); testHistoryFormatter = new TestXmlFormatter(context, test.getSourcePage(), writerFactory); testHistoryFormatter.testStarted(test); referenceToCurrentTest = new SuiteExecutionReport.PageHistoryReference(pageName, testHistoryFormatter.startedAt()); }
@Override public void testComplete(WikiTestPage test, TestSummary testSummary) throws IOException { testHistoryFormatter.testComplete(test, testSummary); testHistoryFormatter.close(); referenceToCurrentTest.setTestSummary(testSummary); referenceToCurrentTest.setRunTimeInMillis(testHistoryFormatter.runTime()); suiteExecutionReport.addPageHistoryReference(referenceToCurrentTest); suiteExecutionReport.tallyPageCounts( ExecutionResult.getExecutionResult(test.getName(), testSummary)); testHistoryFormatter = null; super.testComplete(test, testSummary); }
@Override public void errorOccurred(Throwable cause) { if (testHistoryFormatter != null) { testHistoryFormatter.errorOccurred(cause); } super.errorOccurred(cause); }
@Override public void close() throws IOException { if (suiteTime == null || suiteTime.isStopped()) return; suiteTime.stop(); totalTimeMeasurement.stop(); suiteExecutionReport.setTotalRunTimeInMillis(totalTimeMeasurement); if (testHistoryFormatter != null) { testHistoryFormatter.close(); } if (PageType.fromWikiPage(getPage()) == PageType.SUITE) { Writer writer = writerFactory.getWriter(context, getPage(), getPageCounts(), suiteTime.startedAt()); try { VelocityContext velocityContext = new VelocityContext(); velocityContext.put("suiteExecutionReport", getSuiteExecutionReport()); VelocityEngine velocityEngine = context.pageFactory.getVelocityEngine(); Template template = velocityEngine.getTemplate("suiteHistoryXML.vm"); template.merge(velocityContext, writer); } finally { writer.close(); } } }
@Override public void testExceptionOccurred(Assertion assertion, ExceptionResult exceptionResult) { testHistoryFormatter.testExceptionOccurred(assertion, exceptionResult); super.testExceptionOccurred(assertion, exceptionResult); }
@Override public void testAssertionVerified(Assertion assertion, TestResult testResult) { testHistoryFormatter.testAssertionVerified(assertion, testResult); super.testAssertionVerified(assertion, testResult); }
@Override public void testOutputChunk(String output) { if (testHistoryFormatter != null) { testHistoryFormatter.testOutputChunk(output); } }