public class AsciiDocReporterTestCase {
@Test
public void shouldExportReportInAsciiDocFormat() throws Exception {
ReporterConfiguration configuration = new ReporterConfiguration();
Map<String, String> configMap = new HashMap<String, String>();
configMap.put("report", "asciidoc");
configMap.put("file", "report");
configuration.setConfiguration(configMap);
configuration.validate();
Reporter reporter = new ReporterImpl();
reporter.setConfiguration(configuration);
KeyValueEntry kve3 = new KeyValueEntry();
kve3.setKey("key3");
kve3.setValue("value3");
reporter.getReporterCursor().getCursor().getPropertyEntries().add(kve3);
TestSuiteReport testSuiteReport = new TestSuiteReport();
reporter.getReport().getTestSuiteReports().add(testSuiteReport);
reporter.setTestSuiteReport(testSuiteReport);
KeyValueEntry kve = new KeyValueEntry();
kve.setKey("key");
kve.setValue("value");
KeyValueEntry kve2 = new KeyValueEntry();
kve2.setKey("key2");
kve2.setValue("value2");
FileEntry fe = new FileEntry();
fe.setPath("somePath");
fe.setSize("100MB");
reporter.getReporterCursor().getCursor().getPropertyEntries().add(kve);
reporter.getReporterCursor().getCursor().getPropertyEntries().add(kve2);
reporter.getReporterCursor().getCursor().getPropertyEntries().add(fe);
// containers
ContainerReport containerReport = new ContainerReport();
containerReport.setQualifier("wildfly");
containerReport.setConfiguration(new HashMap<String, String>());
reporter.getLastTestSuiteReport().getContainerReports().add(containerReport);
reporter.setContainerReport(containerReport);
// deployment
DeploymentReport deploymentReport = new DeploymentReport();
deploymentReport.setArchiveName("some.war");
deploymentReport.setName("deploymentName");
deploymentReport.setOrder(1);
deploymentReport.setProtocol("someProtocol");
deploymentReport.setTarget("wildfly");
reporter.getLastContainerReport().getDeploymentReports().add(deploymentReport);
TestClassReport testClassReport = new TestClassReport();
testClassReport.setTestClassName(FakeTestClass.class.getName());
reporter.getLastTestSuiteReport().getTestClassReports().add(testClassReport);
reporter.setTestClassReport(testClassReport);
VideoEntry videoEntry = new VideoEntry();
videoEntry.setPath(configuration.getRootDir().getAbsolutePath() + "/some/someVideo.mp4");
videoEntry.setSize("54M");
reporter.getReporterCursor().getCursor().getPropertyEntries().add(videoEntry);
TestMethodReport testMethodReport = new TestMethodReport();
testMethodReport.setName("someTestMethod");
TestResult testResult = new TestResult();
testResult.setStatus(Status.PASSED);
testResult.setStart(System.currentTimeMillis());
testResult.setEnd(testResult.getStart() + 1000);
testMethodReport.setReportMessage("This test should be executed manually too.");
testMethodReport.setStatus(testResult.getStatus());
testMethodReport.setDuration(testResult.getEnd() - testResult.getStart());
reporter.getLastTestClassReport().getTestMethodReports().add(testMethodReport);
reporter.setTestMethodReport(testMethodReport);
TestMethodReport testMethodReport2 = new TestMethodReport();
testMethodReport2.setName("someTestMethod2");
TestResult testResult2 = new TestResult();
testResult2.setStatus(Status.FAILED);
testResult2.setThrowable(new IOException("Exception"));
testResult2.setStart(System.currentTimeMillis());
testResult2.setEnd(testResult2.getStart() + 2000);
testMethodReport2.setStatus(testResult2.getStatus());
testMethodReport2.setDuration(testResult2.getEnd() - testResult2.getStart());
testMethodReport2.setException("some exception");
reporter.getLastTestClassReport().getTestMethodReports().add(testMethodReport2);
reporter.setTestMethodReport(testMethodReport2);
ScreenshotEntry sce = new ScreenshotEntry();
sce.setPath(configuration.getRootDir().getAbsolutePath() + "/niceScreenshot.jpg");
sce.setSize("56kB");
sce.setPhase(When.BEFORE);
ScreenshotEntry sce2 = new ScreenshotEntry();
sce2.setPath(configuration.getRootDir().getAbsolutePath() + "/niceScreenshotBefore.jpg");
sce2.setPhase(When.BEFORE);
reporter.getReporterCursor().getCursor().getPropertyEntries().add(sce);
reporter.getReporterCursor().getCursor().getPropertyEntries().add(sce2);