com.aventstack.extentreports.Status Java Examples
The following examples show how to use
com.aventstack.extentreports.Status.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtentIReporterSuiteClassListenerAdapter.java From extentreports-testng-adapter with Apache License 2.0 | 7 votes |
@Override public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { ExtentService.getInstance().setReportUsesManualConfiguration(true); ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE); for (ISuite suite : suites) { Map<String, ISuiteResult> result = suite.getResults(); for (ISuiteResult r : result.values()) { ITestContext context = r.getTestContext(); ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName()); buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL); buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP); buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS); } } for (String s : Reporter.getOutput()) { ExtentService.getInstance().setTestRunnerOutput(s); } ExtentService.getInstance().flush(); }
Example #2
Source File: ExtentIReporterSuiteListenerAdapter.java From extentreports-testng-adapter with Apache License 2.0 | 6 votes |
@Override public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { ExtentService.getInstance().setReportUsesManualConfiguration(true); ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE); for (ISuite suite : suites) { Map<String, ISuiteResult> result = suite.getResults(); for (ISuiteResult r : result.values()) { ITestContext context = r.getTestContext(); ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName()); buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL); buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP); buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS); } } for (String s : Reporter.getOutput()) { ExtentService.getInstance().setTestRunnerOutput(s); } ExtentService.getInstance().flush(); }
Example #3
Source File: ReportEntityTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@org.testng.annotations.Test public void reportTestHasStatus() { Test test = TestService.createTest("Test"); Log skip = Log.builder().status(Status.SKIP).build(); Log pass = Log.builder().status(Status.PASS).build(); Report report = Report.builder().build(); report.getTestList().add(test); Assert.assertTrue(report.anyTestHasStatus(Status.PASS)); Assert.assertFalse(report.anyTestHasStatus(Status.SKIP)); test.addLog(skip); Assert.assertFalse(report.anyTestHasStatus(Status.PASS)); Assert.assertTrue(report.anyTestHasStatus(Status.SKIP)); test.addLog(pass); Assert.assertFalse(report.anyTestHasStatus(Status.PASS)); Assert.assertTrue(report.anyTestHasStatus(Status.SKIP)); }
Example #4
Source File: SparkReporterTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@Test public void statusFilterable() { ExtentReports extent = new ExtentReports(); String path = path(); ExtentSparkReporter spark = new ExtentSparkReporter(path) .filter() .statusFilter() .as(new Status[]{Status.FAIL}) .apply(); extent.attachReporter(spark); extent.createTest(PARENT).pass("Pass"); extent.createTest(CHILD).fail("Fail"); extent.flush(); assertFileExists(path); Assert.assertEquals(spark.getReport().getTestList().size(), 1); Assert.assertEquals(spark.getReport().getTestList().get(0).getName(), CHILD); }
Example #5
Source File: ReportFilterService.java From extentreports-java with Apache License 2.0 | 6 votes |
public static Report filter(Report report, Set<Status> statusList) { if (report.getTestList().isEmpty()) return report; Report filtered = Report.builder().build(); filtered.getLogs().addAll(report.getLogs()); filtered.setStartTime(report.getStartTime()); filtered.setEndTime(report.getEndTime()); List<Test> list = report.getTestList().stream() .filter(x -> statusList.contains(x.getStatus())) .collect(Collectors.toList()); list.forEach(filtered.getTestList()::add); filtered.getStats().update(list); Set<NamedAttributeContext<Author>> authorCtx = new NamedAttributeTestContextFilter<Author>() .filter(report.getAuthorCtx(), statusList); authorCtx.stream().forEach(x -> filtered.getAuthorCtx().addContext(x.getAttr(), x.getTestList())); Set<NamedAttributeContext<Category>> categoryCtx = new NamedAttributeTestContextFilter<Category>() .filter(report.getCategoryCtx(), statusList); categoryCtx.stream().forEach(x -> filtered.getCategoryCtx().addContext(x.getAttr(), x.getTestList())); Set<NamedAttributeContext<Device>> deviceCtx = new NamedAttributeTestContextFilter<Device>() .filter(report.getDeviceCtx(), statusList); deviceCtx.stream().forEach(x -> filtered.getDeviceCtx().addContext(x.getAttr(), x.getTestList())); return filtered; }
Example #6
Source File: ReportStats.java From extentreports-java with Apache License 2.0 | 6 votes |
private final void update(final List<? extends RunResult> list, final Map<Status, Long> countMap, final Map<Status, Float> percentageMap) { if (list == null) return; Map<Status, Long> map = list.stream().collect( Collectors.groupingBy(RunResult::getStatus, Collectors.counting())); Arrays.asList(Status.values()).forEach(x -> map.putIfAbsent(x, 0L)); countMap.putAll(map); if (list.isEmpty()) { percentageMap.putAll( map.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> Float.valueOf(e.getValue())))); return; } Map<Status, Float> pctMap = map.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> Float.valueOf(e.getValue() * 100 / list.size()))); percentageMap.putAll(pctMap); }
Example #7
Source File: SparkReporterTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@Test public void statusFilterableNode() { ExtentReports extent = new ExtentReports(); String path = path(); ExtentSparkReporter spark = new ExtentSparkReporter(path) .filter() .statusFilter() .as(new Status[]{Status.FAIL}) .apply(); extent.attachReporter(spark); extent.createTest(PARENT).pass("Pass"); extent.createTest(CHILD).pass("Pass") .createNode(GRANDCHILD).fail("Fail"); extent.flush(); assertFileExists(path); Assert.assertEquals(spark.getReport().getTestList().size(), 1); Assert.assertEquals(spark.getReport().getTestList().get(0).getName(), CHILD); Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().size(), 1); Assert.assertEquals(spark.getReport().getTestList().get(0).getChildren().get(0).getName(), GRANDCHILD); }
Example #8
Source File: ExtentIReporterSuiteListenerAdapter.java From extentreports-testng-adapter with Apache License 2.0 | 6 votes |
private void buildTestNodes(ExtentTest suiteTest, IResultMap tests, Status status) { ExtentTest node; if (tests.size() > 0) { for (ITestResult result : tests.getAllResults()) { node = suiteTest.createNode(result.getMethod().getMethodName(), result.getMethod().getDescription()); String groups[] = result.getMethod().getGroups(); ExtentTestCommons.assignGroups(node, groups); if (result.getThrowable() != null) { node.log(status, result.getThrowable()); } else { node.log(status, "Test " + status.toString().toLowerCase() + "ed"); } node.getModel().getLogContext().getAll().forEach(x -> x.setTimestamp(getTime(result.getEndMillis()))); node.getModel().setStartTime(getTime(result.getStartMillis())); node.getModel().setEndTime(getTime(result.getEndMillis())); } } }
Example #9
Source File: ReportStatsTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@org.testng.annotations.Test public void statsAll() { Report report = Report.builder().build(); report.getStats().update(report.getTestList()); // check if all Status fields are present Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getParent().containsKey(x))); Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getChild().containsKey(x))); Arrays.asList(Status.values()) .forEach(x -> Assert.assertTrue(report.getStats().getGrandchild().containsKey(x))); Assert.assertEquals(report.getStats().getParent().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getParent().get(Status.FAIL).longValue(), 0); Assert.assertEquals(report.getStats().getParent().get(Status.SKIP).longValue(), 0); Assert.assertEquals(report.getStats().getParent().get(Status.WARNING).longValue(), 0); Assert.assertEquals(report.getStats().getParent().get(Status.INFO).longValue(), 0); Assert.assertEquals(report.getStats().getChild().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getChild().get(Status.FAIL).longValue(), 0); Assert.assertEquals(report.getStats().getChild().get(Status.SKIP).longValue(), 0); Assert.assertEquals(report.getStats().getChild().get(Status.WARNING).longValue(), 0); Assert.assertEquals(report.getStats().getChild().get(Status.INFO).longValue(), 0); Assert.assertEquals(report.getStats().getGrandchild().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getGrandchild().get(Status.FAIL).longValue(), 0); Assert.assertEquals(report.getStats().getGrandchild().get(Status.SKIP).longValue(), 0); Assert.assertEquals(report.getStats().getGrandchild().get(Status.WARNING).longValue(), 0); Assert.assertEquals(report.getStats().getGrandchild().get(Status.INFO).longValue(), 0); }
Example #10
Source File: ReportStatsTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@org.testng.annotations.Test public void statsTestStatus() { Test test = TestService.createTest("Test"); Report report = Report.builder().build(); report.getTestList().add(test); report.getStats().update(report.getTestList()); // check if all Status fields are present Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getParent().containsKey(x))); Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getChild().containsKey(x))); Arrays.asList(Status.values()) .forEach(x -> Assert.assertTrue(report.getStats().getGrandchild().containsKey(x))); test.setStatus(Status.FAIL); report.getStats().update(report.getTestList()); Assert.assertEquals(report.getStats().getParent().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getParent().get(Status.FAIL).longValue(), 1); }
Example #11
Source File: ExtentTestManager.java From extentreports-testng-adapter with Apache License 2.0 | 6 votes |
public static synchronized void log(ITestResult result, Boolean createTestAsChild) { String msg = "Test "; Status status = Status.PASS; switch (result.getStatus()) { case ITestResult.SKIP: status = Status.SKIP; msg += "skipped"; break; case ITestResult.FAILURE: status = Status.FAIL; msg += "failed"; break; default: msg += "passed"; break; } if (ExtentTestManager.getTest(result) == null) { ExtentTestManager.createMethod(result, createTestAsChild); } if (result.getThrowable() != null) { ExtentTestManager.getTest(result).log(status, result.getThrowable()); return; } ExtentTestManager.getTest(result).log(status, msg); }
Example #12
Source File: ReportStatsTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@org.testng.annotations.Test public void statsChildStatus() { Test test = TestService.createTest("Test"); Test node = TestService.createTest("Node"); node.setStatus(Status.SKIP); test.addChild(node); Report report = Report.builder().build(); report.getTestList().add(test); report.getStats().update(report.getTestList()); // check if all Status fields are present Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getParent().containsKey(x))); Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getChild().containsKey(x))); Arrays.asList(Status.values()) .forEach(x -> Assert.assertTrue(report.getStats().getGrandchild().containsKey(x))); Assert.assertEquals(report.getStats().getParent().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getParent().get(Status.SKIP).longValue(), 1); Assert.assertEquals(report.getStats().getChild().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getChild().get(Status.SKIP).longValue(), 1); }
Example #13
Source File: ReportStatsTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@org.testng.annotations.Test public void statsGrandchildStatus() { Test test = TestService.createTest("Test"); Test node = TestService.createTest("Node"); Test grandchild = TestService.createTest("Grandchild"); grandchild.setStatus(Status.FAIL); node.addChild(grandchild); test.addChild(node); Report report = Report.builder().build(); report.getTestList().add(test); report.getStats().update(report.getTestList()); // check if all Status fields are present Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getParent().containsKey(x))); Arrays.asList(Status.values()).forEach(x -> Assert.assertTrue(report.getStats().getChild().containsKey(x))); Arrays.asList(Status.values()) .forEach(x -> Assert.assertTrue(report.getStats().getGrandchild().containsKey(x))); Assert.assertEquals(report.getStats().getParent().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getParent().get(Status.FAIL).longValue(), 1); Assert.assertEquals(report.getStats().getChild().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getChild().get(Status.FAIL).longValue(), 1); Assert.assertEquals(report.getStats().getGrandchild().get(Status.PASS).longValue(), 0); Assert.assertEquals(report.getStats().getGrandchild().get(Status.FAIL).longValue(), 1); }
Example #14
Source File: NamedAttributeContext.java From extentreports-java with Apache License 2.0 | 5 votes |
private synchronized void refresh(Test test) { if (test.getStatus() == Status.PASS) passed++; else if (test.getStatus() == Status.FAIL) failed++; else if (test.getStatus() == Status.SKIP) skipped++; else others++; }
Example #15
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testEntities(Method method) { Test test = TestService.createTest(method.getName()); Assert.assertEquals(test.getAuthorSet().size(), 0); Assert.assertEquals(test.getDeviceSet().size(), 0); Assert.assertEquals(test.getCategorySet().size(), 0); Assert.assertEquals(test.getChildren().size(), 0); Assert.assertTrue(test.isLeaf()); Assert.assertEquals(test.getLevel().intValue(), 0); Assert.assertEquals(test.getStatus(), Status.PASS); Assert.assertNull(test.getDescription()); }
Example #16
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void addLogToTest() { Test test = getTest(); Log log = Log.builder().build(); test.addLog(log); Assert.assertEquals(log.getSeq().intValue(), 0); Assert.assertEquals(test.getLogs().size(), 1); Assert.assertEquals(test.getStatus(), Status.PASS); Assert.assertEquals(log.getStatus(), Status.PASS); }
Example #17
Source File: TestServiceTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testHasScreenCaptureDeepNodeLog() { Test test = getTest(); Test node = getTest(); test.getChildren().add(node); Log log = Log.builder().status(Status.PASS).details("").build(); log.addMedia(ScreenCapture.builder().path("/img.png").build()); node.addLog(log); Assert.assertFalse(test.hasScreenCapture()); Assert.assertTrue(TestService.testHasScreenCapture(test, true)); }
Example #18
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void addSkipLogToTest() { Test test = getTest(); Log log = Log.builder().status(Status.SKIP).build(); test.addLog(log); Assert.assertEquals(test.getStatus(), Status.SKIP); Assert.assertEquals(log.getStatus(), Status.SKIP); }
Example #19
Source File: ReportStatsTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void statsSize() { Test test = TestService.createTest("Test"); Report report = Report.builder().build(); report.getTestList().add(test); Assert.assertEquals(report.getStats().getParent().size(), 0); report.getStats().update(report.getTestList()); Assert.assertEquals(report.getStats().getParent().size(), Status.values().length); }
Example #20
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void addFailLogToTest() { Test test = getTest(); Log log = Log.builder().status(Status.FAIL).build(); test.addLog(log); Assert.assertEquals(test.getStatus(), Status.FAIL); Assert.assertEquals(log.getStatus(), Status.FAIL); }
Example #21
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testHasLog() { Test test = getTest(); Assert.assertFalse(test.hasLog()); Log log = Log.builder().status(Status.FAIL).build(); test.addLog(log); Assert.assertTrue(test.hasLog()); }
Example #22
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testStatusWithLog() { Test test = getTest(); Assert.assertEquals(test.getStatus(), Status.PASS); Log log = Log.builder().status(Status.FAIL).build(); test.addLog(log); Assert.assertEquals(test.getStatus(), Status.FAIL); }
Example #23
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testStatusWithLogStatusChanged() { Test test = getTest(); Assert.assertEquals(test.getStatus(), Status.PASS); Log log = Log.builder().status(Status.SKIP).build(); test.addLog(log); Assert.assertEquals(test.getStatus(), Status.SKIP); log.setStatus(Status.FAIL); test.updateResult(); Assert.assertEquals(test.getStatus(), Status.FAIL); }
Example #24
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void computeTestStatusSkipLog() { Test test = getTest(); test.getLogs().add(Log.builder().status(Status.SKIP).build()); test.updateResult(); Assert.assertEquals(test.getStatus(), Status.SKIP); }
Example #25
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void computeTestStatusSkipAndFailLog() { Test test = getTest(); test.getLogs().add(Log.builder().status(Status.SKIP).build()); test.getLogs().add(Log.builder().status(Status.FAIL).build()); test.updateResult(); Assert.assertEquals(test.getStatus(), Status.FAIL); }
Example #26
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void computeTestStatusNode() { Test parent = getTest(); Test node = getTest(); parent.addChild(node); node.getLogs().add(Log.builder().status(Status.SKIP).build()); parent.updateResult(); Assert.assertEquals(parent.getStatus(), Status.SKIP); Assert.assertEquals(node.getStatus(), Status.SKIP); node.getLogs().add(Log.builder().status(Status.FAIL).build()); parent.updateResult(); Assert.assertEquals(parent.getStatus(), Status.FAIL); Assert.assertEquals(node.getStatus(), Status.FAIL); }
Example #27
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void generatedLog() { Test test = getTest(); Log log = Log.builder().status(Status.SKIP).details("details").build(); test.addGeneratedLog(log); Assert.assertEquals(test.getGeneratedLog().size(), 1); Assert.assertEquals(test.getLogs().size(), 0); Assert.assertEquals(test.getStatus(), Status.SKIP); }
Example #28
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testHasAngLogWithLog() { Test test = getTest(); Log log = Log.builder().status(Status.SKIP).details("details").build(); test.addLog(log); Assert.assertTrue(test.hasAnyLog()); }
Example #29
Source File: TestEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@org.testng.annotations.Test public void testHasAngLogWithGeneratedLog() { Test test = getTest(); Log log = Log.builder().status(Status.SKIP).details("details").build(); test.addGeneratedLog(log); Assert.assertTrue(test.hasAnyLog()); }
Example #30
Source File: LogEntityTest.java From extentreports-java with Apache License 2.0 | 5 votes |
@Test public void changedStatus() { Log log = new Log(); log.setStatus(Status.FAIL); Assert.assertEquals(log.getStatus(), Status.FAIL); log.setStatus(Status.PASS); Assert.assertEquals(log.getStatus(), Status.PASS); }