use of com.qasymphony.ci.plugin.model.AutomationTestStepLog in project jenkin-qtest-plugin by QASymphony.
the class MavenJunitParseTests method testParseMavenProject.
@LocalData
@Test
public void testParseMavenProject() throws InterruptedException, ExecutionException, TimeoutException, IOException {
project = j.createFreeStyleProject("maven-project");
automationTestResultList = null;
project.getBuildersList().add(new MavenParseTestMavenProject());
FreeStyleBuild build = project.scheduleBuild2(0).get(100, TimeUnit.MINUTES);
assertNotNull("Build is: ", build);
assertEquals("", 8, automationTestResultList.size());
AutomationTestResult calculateTest = null;
for (AutomationTestResult automationTestResult : automationTestResultList) {
if (automationTestResult.getName().equalsIgnoreCase("sample.junit.CalculateTest")) {
calculateTest = automationTestResult;
break;
}
}
assertNotNull("Calculate test is:", calculateTest);
assertEquals("Test log size is ", 4, calculateTest.getTestLogs().size());
AutomationTestStepLog first = calculateTest.getTestLogs().get(0);
assertEquals("Description 1 is ", "testSum_second", first.getDescription());
assertEquals("Status 1 is ", "FAILED", first.getStatus());
AutomationTestStepLog second = calculateTest.getTestLogs().get(1);
assertEquals("Description 2 is ", "testSum_one", second.getDescription());
assertEquals("Status 2 is ", "PASSED", second.getStatus());
}
use of com.qasymphony.ci.plugin.model.AutomationTestStepLog in project jenkin-qtest-plugin by QASymphony.
the class CommonParsingUtils method useTestMethodAsTestCase.
/**
* Each method as a testCase in qTest
*
* @param request parse request
* @param testResults testResults
* @param startTime start build time
* @return
* @throws Exception
*/
private static List<AutomationTestResult> useTestMethodAsTestCase(ParseRequest request, List<TestResult> testResults, Date startTime) throws Exception {
Map<String, AutomationTestResult> map = new HashMap<>();
int currentTestLogOrder = 0;
for (TestResult testResult : testResults) {
for (SuiteResult suite : testResult.getSuites()) {
if (suite.getCases() == null) {
continue;
}
Date startDate = JsonUtils.parseTimestamp(suite.getTimestamp());
startDate = startDate == null ? startTime : startDate;
for (CaseResult caseResult : suite.getCases()) {
String automationContent = caseResult.getClassName() + "#" + caseResult.getName();
if (!map.containsKey(automationContent)) {
AutomationTestResult testLog = new AutomationTestResult();
testLog.setOrder(currentTestLogOrder++);
testLog.setAutomationContent(automationContent);
testLog.setExecutedStartDate(startDate);
testLog.setExecutedEndDate(computeEndTime(startDate, caseResult.getDuration()));
testLog.addTestStepLog(new AutomationTestStepLog(caseResult), request.getOverwriteExistingTestSteps());
if (caseResult.isFailed()) {
try {
AutomationAttachment attachment = new AutomationAttachment(caseResult);
attachment.setData(Base64.encodeBase64String(attachment.getData().getBytes()));
testLog.addAttachment(attachment);
} catch (Exception e) {
LoggerUtils.formatError(request.getListener().getLogger(), "Error while build attachment: %s, %s", e.getMessage(), e.getStackTrace());
}
}
map.put(automationContent, testLog);
}
}
}
}
return new ArrayList<>(map.values());
}
use of com.qasymphony.ci.plugin.model.AutomationTestStepLog in project jenkin-qtest-plugin by QASymphony.
the class CommonParsingUtils method useClassNameAsTestCase.
/**
* Class name as a testCase in qTest
*
* @param request parse request
* @param testResults testResults
* @param startTime start build time
* @return
* @throws Exception
*/
private static List<AutomationTestResult> useClassNameAsTestCase(ParseRequest request, List<TestResult> testResults, Date startTime) throws Exception {
Map<String, AutomationTestResult> map = new HashMap<>();
int currentTestLogOrder = 0;
for (TestResult testResult : testResults) {
for (SuiteResult suite : testResult.getSuites()) {
if (suite.getCases() == null) {
continue;
}
Date startDate = JsonUtils.parseTimestamp(suite.getTimestamp());
startDate = startDate == null ? startTime : startDate;
for (CaseResult caseResult : suite.getCases()) {
AutomationTestResult testLog = null;
if (map.containsKey(caseResult.getClassName())) {
testLog = map.get(caseResult.getClassName());
} else {
testLog = new AutomationTestResult();
testLog.setOrder(currentTestLogOrder++);
testLog.setAutomationContent(caseResult.getClassName());
testLog.setExecutedStartDate(startDate);
testLog.setExecutedEndDate(computeEndTime(startDate, suite.getDuration()));
map.put(caseResult.getClassName(), testLog);
}
testLog.addTestStepLog(new AutomationTestStepLog(caseResult), request.getOverwriteExistingTestSteps());
if (caseResult.isFailed()) {
testLog.addAttachment(new AutomationAttachment(caseResult));
}
}
}
}
map = processAttachment(map);
return new ArrayList<>(map.values());
}
Aggregations