diff options
Diffstat (limited to 'asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/run/ExtentReporterNG.java')
-rw-r--r-- | asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/run/ExtentReporterNG.java | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/run/ExtentReporterNG.java b/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/run/ExtentReporterNG.java deleted file mode 100644 index 5119263032..0000000000 --- a/asdc-tests/src/main/java/org/openecomp/sdc/ci/tests/run/ExtentReporterNG.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.ci.tests.run; - -import java.io.File; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.testng.IReporter; -import org.testng.IResultMap; -import org.testng.ISuite; -import org.testng.ISuiteResult; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.xml.XmlSuite; - -import com.relevantcodes.extentreports.ExtentReports; -import com.relevantcodes.extentreports.ExtentTest; -import com.relevantcodes.extentreports.LogStatus; - -public class ExtentReporterNG implements IReporter { - private ExtentReports extent; - - @Override - public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { - extent = new ExtentReports(outputDirectory + File.separator + "ExtentReportsTestNG.html", true); - - for (ISuite suite : suites) { - Map<String, ISuiteResult> result = suite.getResults(); - - for (ISuiteResult r : result.values()) { - ITestContext context = r.getTestContext(); - - buildTestNodes(context.getPassedTests(), LogStatus.PASS); - buildTestNodes(context.getFailedTests(), LogStatus.FAIL); - buildTestNodes(context.getSkippedTests(), LogStatus.SKIP); - } - } - - extent.flush(); - extent.close(); - } - - private void buildTestNodes(IResultMap tests, LogStatus status) { - ExtentTest test; - - if (tests.size() > 0) { - for (ITestResult result : tests.getAllResults()) { - test = extent.startTest(result.getMethod().getMethodName()); - - test.getTest().setStartedTime(getTime(result.getStartMillis())); - test.getTest().setEndedTime(getTime(result.getEndMillis())); - - for (String group : result.getMethod().getGroups()) - test.assignCategory(group); - - String message = "Test " + status.toString().toLowerCase() + "ed"; - - if (result.getThrowable() != null) - message = result.getThrowable().getMessage(); - - test.log(status, message); - - extent.endTest(test); - } - } - } - - private Date getTime(long millis) { - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(millis); - return calendar.getTime(); - } -} |