use of com.axway.ats.log.report.model.RunWrapper in project ats-framework by Axway.
the class Test_ReportFormatter method failedRun.
@Test
public void failedRun() throws MessagingException {
RunWrapper run = createRun();
run.scenariosFailed = 1;
Suite passedSuite1 = new Suite();
passedSuite1.scenariosTotal = 1;
run.addSuite(new SuiteWrapper(passedSuite1));
Suite passedSuite2 = new Suite();
passedSuite2.scenariosTotal = 1;
run.addSuite(new SuiteWrapper(passedSuite2));
Suite passedSuite3 = new Suite();
passedSuite3.scenariosTotal = 1;
run.addSuite(new SuiteWrapper(passedSuite3));
Suite failedSuite = new Suite();
failedSuite.scenariosFailed = 1;
failedSuite.scenariosTotal = 1;
run.addSuite(new SuiteWrapper(failedSuite));
ReportFormatter formatter = new ReportFormatter(run);
assertTrue(formatter.getDescription().length() > 0);
assertTrue(formatter.toHtml().length() > 0);
}
use of com.axway.ats.log.report.model.RunWrapper in project ats-framework by Axway.
the class LogReportMailer method send.
/**
* Email the report
*/
@PublicAtsApi
public void send() {
// get runs from log database
ReportExtactor reportExtactor = new ReportExtactor(dbHost, dbName, dbUser, dbPassword);
List<RunWrapper> runs = reportExtactor.extract(runIds);
// format the report
ReportFormatter reportFormatter = new ReportFormatter(runs, mailSubject, dbHost, dbName, testExplorerWebPort, testExplorerInstanceName);
// send report by mail
MailReportSender mailReportSender = new MailReportSender(reportFormatter.getDescription(), reportFormatter.toHtml());
mailReportSender.send();
}
use of com.axway.ats.log.report.model.RunWrapper in project ats-framework by Axway.
the class ReportAppender method append.
/* (non-Javadoc)
* @see org.apache.log4j.AppenderSkeleton#append(org.apache.log4j.spi.LoggingEvent)
*/
@Override
protected void append(LoggingEvent event) {
// All events from all threads come into here.
if (event instanceof AbstractLoggingEvent) {
AbstractLoggingEvent dbLoggingEvent = (AbstractLoggingEvent) event;
switch(dbLoggingEvent.getEventType()) {
case START_RUN:
run = new RunWrapper();
suitesMap = new HashMap<String, SuiteWrapper>();
StartRunEvent startRunEvent = (StartRunEvent) event;
run.productName = startRunEvent.getProductName();
run.versionName = startRunEvent.getVersionName();
run.buildName = startRunEvent.getBuildName();
run.os = startRunEvent.getOsName();
run.runName = startRunEvent.getRunName();
run.dateStart = AbstractDbAccess.DATE_FORMAT_NO_YEAR.format(startRunEvent.getTimeStamp());
break;
case START_SUITE:
StartSuiteEvent startSuiteEvent = (StartSuiteEvent) event;
lastPlayedSuite = startSuiteEvent.getSuiteName();
if (!suitesMap.containsKey(lastPlayedSuite)) {
SuiteWrapper newSuite = new SuiteWrapper();
newSuite.name = startSuiteEvent.getSuiteName();
newSuite.packageName = startSuiteEvent.getPackage();
newSuite.dateStart = AbstractDbAccess.DATE_FORMAT_NO_YEAR.format(startSuiteEvent.getTimeStamp());
suitesMap.put(newSuite.packageName + "." + newSuite.name, newSuite);
run.addSuite(newSuite);
}
break;
case START_TEST_CASE:
StartTestCaseEvent startTestcaseEvent = (StartTestCaseEvent) dbLoggingEvent;
startTestcaseEvent.getSuiteFullName();
Testcase newTestcase = new Testcase();
newTestcase.scenarioName = startTestcaseEvent.getScenarioName();
newTestcase.name = startTestcaseEvent.getTestcaseName();
suitesMap.get(startTestcaseEvent.getSuiteFullName()).addTestcase(newTestcase);
/*
* There are very rare cases when the test harness system does not execute all tests from
* same suite one after another, but there will be some tests from another suite executed
* in between.
*
* That is why the next line navigates to the right suite when starting the test scenario
*/
lastPlayedSuite = startTestcaseEvent.getSuiteFullName();
break;
case END_TEST_CASE:
EndTestCaseEvent endTestCaseEvent = (EndTestCaseEvent) event;
// update the result of the current testcase
suitesMap.get(lastPlayedSuite).getLastTestcase().result = endTestCaseEvent.getTestCaseResult().toInt();
break;
case END_SUITE:
EndSuiteEvent endSuiteEvent = (EndSuiteEvent) event;
SuiteWrapper currentSuite = getCurrentSuite();
if (currentSuite != null) {
currentSuite.calculateFinalStatistics();
currentSuite.dateEnd = AbstractDbAccess.DATE_FORMAT_NO_YEAR.format(endSuiteEvent.getTimeStamp());
currentSuite.duration = calculateDuration(currentSuite.dateStart, currentSuite.dateEnd);
currentSuite.testcasesPassedPercent = "0";
if (currentSuite.testcasesTotal > 0) {
currentSuite.testcasesPassedPercent = String.valueOf((currentSuite.testcasesTotal - currentSuite.testcasesFailed - currentSuite.testcasesSkipped) * 100 / currentSuite.testcasesTotal);
}
}
// we cleanup here in case first Scenario of next Suite has same name
// as last Scenario of current Suite
lastPlayedSuite = "";
break;
case END_RUN:
// The run is over, we want to mail a report about this run
EndRunEvent endRunEvent = (EndRunEvent) event;
run.calculateFinalStatistics();
run.dateEnd = AbstractDbAccess.DATE_FORMAT_NO_YEAR.format(endRunEvent.getTimeStamp());
run.duration = calculateDuration(run.dateStart, run.dateEnd);
run.testcasesPassedPercent = "0";
if (run.testcasesTotal > 0) {
run.testcasesPassedPercent = String.valueOf((run.testcasesTotal - run.testcasesFailed - run.testcasesSkipped) * 100 / run.testcasesTotal);
try {
// format the report
ReportFormatter reportFormatter = new ReportFormatter(run);
// so, just add the test data to the map
if (!combinedHtmlMailReport) {
// send report by mail
MailReportSender mailReportSender = new MailReportSender(generateMailSubject(run, reportFormatter.getRunsState()), reportFormatter.toHtml());
mailReportSender.send();
} else {
// delay report to collect data for all runs
htmlReportsList.add(run);
}
} catch (Exception e) {
errorHandler.error("Error processing/mailing log report", e, ErrorCode.GENERIC_FAILURE);
}
}
break;
}
}
}
use of com.axway.ats.log.report.model.RunWrapper in project ats-framework by Axway.
the class Test_ReportFormatter method noRuns.
@Test(expected = ReportFormatterException.class)
public void noRuns() throws MessagingException {
List<RunWrapper> runs = new ArrayList<RunWrapper>();
String dbHost = "";
String dbName = "";
int port = 0;
String testExplorerPath = "";
ReportFormatter formatter = new ReportFormatter(runs, "descirption", dbHost, dbName, port, testExplorerPath);
formatter.toHtml();
}
use of com.axway.ats.log.report.model.RunWrapper in project ats-framework by Axway.
the class Test_ReportFormatter method passedRun.
@Test
public void passedRun() throws MessagingException {
RunWrapper run = createRun();
ReportFormatter formatter = new ReportFormatter(run);
assertTrue(formatter.getDescription().length() > 0);
assertTrue(formatter.toHtml().length() > 0);
}
Aggregations