use of com.axway.ats.log.autodb.entities.Suite 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.autodb.entities.Suite in project ats-framework by Axway.
the class ReportExtactor method extractRunEntities.
/**
* extract the runs
*
* @param runIds
* @return
*/
private List<RunWrapper> extractRunEntities(int[] runIds) {
StringBuilder whereClause = new StringBuilder();
whereClause.append(" WHERE runId IN (");
for (int runId : runIds) {
whereClause.append(runId).append(", ");
}
whereClause.setLength(whereClause.lastIndexOf(","));
whereClause.append(")");
List<Run> dbRuns;
try {
dbRuns = dbReadAccess.getRuns(0, 10000, whereClause.toString(), "runId", true);
} catch (DatabaseAccessException e) {
throw new ReportExtractorException("Error loading runs " + whereClause, e);
}
List<RunWrapper> runs = new ArrayList<RunWrapper>();
for (Run dbRun : dbRuns) {
// load this run's suites
List<Suite> suites;
try {
suites = dbReadAccess.getSuites(0, 10000, "WHERE runId=" + dbRun.runId, "suiteId", true, false);
} catch (DatabaseAccessException e) {
throw new ReportExtractorException("Error loading suites for run with id " + dbRun.runId, e);
}
RunWrapper run = new RunWrapper(dbRun, suites);
runs.add(run);
}
return runs;
}
use of com.axway.ats.log.autodb.entities.Suite in project ats-framework by Axway.
the class ReportFormatter method getContentAsHTMLTable.
/**
* create just the html table with the test data for the report
*/
public String getContentAsHTMLTable() {
StringBuilder tableBody = new StringBuilder();
tableBody.append("<table width=100% border=0 cellspacing=1 cellpadding=5>");
for (RunWrapper run : runs) {
// START - Run header
tableBody.append(START_TBL_HEADERROW);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Run" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Product" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Version" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Build" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "OS" + END_TBL_CELL);
tableBody.append("<td colspan=4 align=center>" + "Scenarios" + END_TBL_CELL);
tableBody.append("<td colspan=3 align=center>" + "Test cases" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Start" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "End" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Duration" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "User note" + END_TBL_CELL);
tableBody.append(END_TBL_ROW);
tableBody.append(START_TBL_HEADERROW);
tableBody.append(START_TBL_CELL + "total" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "% passed" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "failed" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "skipped" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "total" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "% passed" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "failed" + END_TBL_CELL);
tableBody.append(END_TBL_ROW);
// START - Run data
if (run.scenariosFailed + run.scenariosSkipped + run.testcasesFailed > 0) {
tableBody.append(START_TBL_ROW_FAILED_RUN);
} else {
tableBody.append(START_TBL_ROW_PASSED_RUN);
}
if (this.dbHost != null) {
if (testExplorerWebPort > 0) {
testExplorerURL = "http://" + dbHost + ":" + testExplorerWebPort;
} else {
testExplorerURL = "http://" + dbHost;
}
testExplorerURL += "/" + testExplorerPath + "/suites?runId=" + run.runId + "&dbname=" + dbName;
} else {
ActiveDbAppender dbAppender = ActiveDbAppender.getCurrentInstance();
ReportConfigurator reportConfigurator = ReportConfigurator.getInstance();
if (dbAppender != null && reportConfigurator.getTestExplorerWebPath() != null) {
if (reportConfigurator.getTestExplorerWebPort() != null) {
testExplorerURL = "http://" + dbAppender.getHost() + ":" + reportConfigurator.getTestExplorerWebPort();
} else {
testExplorerURL = "http://" + dbAppender.getHost();
}
testExplorerURL += "/" + reportConfigurator.getTestExplorerWebPath() + "/suites?runId=" + dbAppender.getRunId() + "&dbname=" + dbAppender.getDatabase();
}
}
if (testExplorerURL != null) {
tableBody.append(START_TBL_CELL + "<a href =\"" + testExplorerURL + "\">" + run.runName + "</a>" + END_TBL_CELL);
} else {
tableBody.append(START_TBL_CELL + run.runName + END_TBL_CELL);
}
tableBody.append(START_TBL_CELL + run.productName + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.versionName + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.buildName + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.os + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.scenariosTotal + END_TBL_CELL);
tableBody.append(START_TBL_CELL + (run.scenariosTotal - run.scenariosFailed - run.scenariosSkipped) * 100 / run.scenariosTotal + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.scenariosFailed + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.scenariosSkipped + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.testcasesTotal + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.testcasesPassedPercent + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.testcasesFailed + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.dateStart + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.dateEnd + END_TBL_CELL);
tableBody.append(START_TBL_CELL + run.duration + END_TBL_CELL);
tableBody.append(START_TBL_CELL + (run.userNote == null ? "" : run.userNote) + END_TBL_CELL);
tableBody.append(END_TBL_ROW);
// END - Run data
// put some space between run and its suites
tableBody.append(EMPTY_TBL_ROW);
// START - Suites header
tableBody.append(START_TBL_HEADERROW);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Suites" + END_TBL_CELL);
tableBody.append("<td colspan=4 rowspan=2 align=center>" + END_TBL_CELL);
tableBody.append("<td colspan=4 align=center>" + "Scenarios" + END_TBL_CELL);
tableBody.append("<td colspan=3 align=center>" + "Test cases" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Start" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "End" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "Duration" + END_TBL_CELL);
tableBody.append(START_TBL_CELL_TWO_ROWS + "User note" + END_TBL_CELL);
tableBody.append(END_TBL_ROW);
tableBody.append(START_TBL_HEADERROW);
tableBody.append(START_TBL_CELL + "total" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "% passed" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "failed" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "skipped" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "total" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "% passed" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + "failed" + END_TBL_CELL);
tableBody.append(END_TBL_ROW);
// END - Suites header
// insert some space between run and its suites
tableBody.append(LINE_BREAK);
// START - Suites data
boolean evenRow = false;
for (Suite suite : run.getSuites()) {
if (suite.scenariosFailed + suite.scenariosSkipped + suite.testcasesFailed > 0) {
// the run has failed if contains a failed or skipped
// scenario
tableBody.append(START_TBL_ROW_FAILED_SUITE);
} else {
if (evenRow) {
tableBody.append(START_TBL_EVENROW);
} else {
tableBody.append(START_TBL_ODDROW);
}
}
tableBody.append(START_TBL_CELL + suite.name + END_TBL_CELL);
tableBody.append("<td colspan=4 align=center>" + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.scenariosTotal + END_TBL_CELL);
tableBody.append(START_TBL_CELL + (suite.scenariosTotal - suite.scenariosFailed - suite.scenariosSkipped) * 100 / suite.scenariosTotal + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.scenariosFailed + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.scenariosSkipped + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.testcasesTotal + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.testcasesPassedPercent + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.testcasesFailed + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.dateStart + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.dateEnd + END_TBL_CELL);
tableBody.append(START_TBL_CELL + suite.duration + END_TBL_CELL);
tableBody.append("<td align=center>" + (suite.userNote == null ? "" : suite.userNote) + END_TBL_CELL);
evenRow = !evenRow;
}
// END - Suites data
// insert some space before the next run
tableBody.append("<tr><td colspan=16 style=\"height: 40px;\"></td></tr>");
}
tableBody.append(END_TBL);
return tableBody.toString();
}
use of com.axway.ats.log.autodb.entities.Suite in project ats-framework by Axway.
the class DbReadAccess method getSuites.
@BackwardCompatibility
public List<Suite> getSuites(int startRecord, int recordsCount, String whereClause, String sortColumn, boolean ascending, boolean dateFormatNoYear) throws DatabaseAccessException {
List<Suite> suites = new ArrayList<Suite>();
Connection connection = getConnection();
String sqlLog = new SqlRequestFormatter().add("start record", startRecord).add("records", recordsCount).add("where", whereClause).add("sort by", sortColumn).add("asc", ascending).format();
CallableStatement callableStatement = null;
ResultSet rs = null;
try {
callableStatement = connection.prepareCall("{ call sp_get_suites(?, ?, ?, ?, ?) }");
callableStatement.setString(1, String.valueOf(startRecord));
callableStatement.setString(2, String.valueOf(recordsCount));
callableStatement.setString(3, whereClause);
callableStatement.setString(4, sortColumn);
callableStatement.setString(5, (ascending ? "ASC" : "DESC"));
int numberRecords = 0;
rs = callableStatement.executeQuery();
while (rs.next()) {
Suite suite = new Suite();
suite.suiteId = rs.getString("suiteId");
try {
@BackwardCompatibility int // suite.runId introduced 3.11.0 (internalVersion=3)
dbInternalVersion = getDatabaseInternalVersion();
if (dbInternalVersion >= 3) {
suite.runId = rs.getString("runId");
}
} catch (NumberFormatException nfe) {
suite.runId = "";
log.warn("Error parsing dbInternalVersion. ", nfe);
}
suite.name = rs.getString("name");
if (dateFormatNoYear) {
suite.dateStart = formatDateNoYear(rs.getTimestamp("dateStart"));
suite.dateEnd = formatDateNoYear(rs.getTimestamp("dateEnd"));
} else {
suite.dateStart = formatDate(rs.getTimestamp("dateStart"));
suite.dateEnd = formatDate(rs.getTimestamp("dateEnd"));
}
int duration = rs.getInt("duration");
if (duration < 0) {
// this may happen when the suite is not ended and the time of the log server
// is behind with the time of the test executor host
duration = 0;
}
suite.duration = formatTimeDiffereceFromSecondsToString(duration);
suite.scenariosTotal = rs.getInt("scenariosTotal");
suite.scenariosFailed = rs.getInt("scenariosFailed");
suite.scenariosSkipped = rs.getInt("scenariosSkipped");
suite.testcasesTotal = rs.getInt("testcasesTotal");
suite.testcasesFailed = rs.getInt("testcasesFailed");
suite.testcasesPassedPercent = String.valueOf(rs.getInt("testcasesPassedPercent")) + "%";
suite.testcaseIsRunning = rs.getBoolean("testcaseIsRunning");
suite.total = suite.scenariosTotal + "/" + suite.testcasesTotal;
suite.failed = suite.scenariosFailed + "/" + suite.testcasesFailed;
suite.userNote = rs.getString("userNote");
suite.packageName = "";
try {
@BackwardCompatibility int // suite.packageName introduced 3.5.0 and internalVersion=1 (in 3.10.0)
dbInternalVersion = getDatabaseInternalVersion();
if (dbInternalVersion >= 1) {
suite.packageName = rs.getString("package");
}
} catch (NumberFormatException nfe) {
suite.packageName = "";
log.warn("Error parsing dbInternalVersion. ", nfe);
}
suites.add(suite);
numberRecords++;
}
logQuerySuccess(sqlLog, "suites", numberRecords);
} catch (Exception e) {
throw new DatabaseAccessException("Error when " + sqlLog, e);
} finally {
DbUtils.closeResultSet(rs);
DbUtils.close(connection, callableStatement);
}
return suites;
}
use of com.axway.ats.log.autodb.entities.Suite in project ats-framework by Axway.
the class Test_ReportFormatter method createRun.
private RunWrapper createRun() {
RunWrapper run = new RunWrapper();
run.productName = "product";
run.versionName = "version";
run.buildName = "build";
run.os = "os";
run.scenariosTotal = 1;
Suite suite = new Suite();
suite.scenariosTotal = 1;
run.addSuite(new SuiteWrapper(suite));
return run;
}
Aggregations