com.aventstack.extentreports.ExtentTest Java Examples

The following examples show how to use com.aventstack.extentreports.ExtentTest. 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 vote down vote up
@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: RawEntityConverter.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
public void convertAndApply(File jsonFile) throws IOException {
    if (!jsonFile.exists()) {
        return;
    }
    extent.setReportUsesManualConfiguration(true);
    List<Test> tests = new JsonDeserializer(jsonFile).deserialize();
    for (Test test : tests) {
        try {
            if (test.getBddType() == null) {
                createDomain(test, extent.createTest(test.getName(), test.getDescription()));
            } else {
                ExtentTest extentTest = extent.createTest(new GherkinKeyword(test.getBddType().toString()),
                        test.getName(), test.getDescription());
                createDomain(test, extentTest);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
 
Example #3
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 6 votes vote down vote up
private synchronized void createScenarioOutline(ScenarioOutline scenarioOutline) {
    if (scenarioOutlineMap.containsKey(scenarioOutline.getName())) {
        scenarioOutlineThreadLocal.set(scenarioOutlineMap.get(scenarioOutline.getName()));
        return;
    }
    if (scenarioOutlineThreadLocal.get() == null) {
        ExtentTest t = featureTestThreadLocal.get()
                .createNode(com.aventstack.extentreports.gherkin.model.ScenarioOutline.class, scenarioOutline.getName(), scenarioOutline.getDescription());
        scenarioOutlineThreadLocal.set(t);
        scenarioOutlineMap.put(scenarioOutline.getName(), t);
        List<String> featureTags = scenarioOutlineThreadLocal.get().getModel()
        		.getParent().getCategoryContext().getAll()
        		.stream()
        		.map(x -> x.getName())
        		.collect(Collectors.toList());
        scenarioOutline.getTags()
        	.stream()
        	.map(x -> x.getName())
        	.filter(x -> !featureTags.contains(x))
        	.forEach(scenarioOutlineThreadLocal.get()::assignCategory);
    }
}
 
Example #4
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 6 votes vote down vote up
private void addFeatures(ExtentReports extentReports, List<Feature> features) {
    final ExtentTest featureNode = createBddTest(extentReports, features.get(0).getName());

    features.forEach(feature -> {
        if (feature.getScenarios().size() > 1) {
            addFeatureStartAndEndTime(featureNode, feature);
        }

        for (Scenario scenario : feature.getScenarios()) {
            if (scenario.getKeyword().startsWith("Scenario")) {
                addScenario(featureNode, scenario);
                addScenarioStartAndEndTime(featureNode, scenario);
            }
        }
    });
}
 
Example #5
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 6 votes vote down vote up
private synchronized void createTestStep(PickleStepTestStep testStep) {
    String stepName = testStep.getStepText();
    TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile.get(), testStep.getStepLine());
    if (astNode != null) {
        Step step = (Step) astNode.node;
        try {
            String name = stepName == null || stepName.isEmpty() 
                    ? step.getText().replace("<", "&lt;").replace(">", "&gt;")
                    : stepName;
            ExtentTest t = scenarioThreadLocal.get()
                    .createNode(new GherkinKeyword(step.getKeyword().trim()), step.getKeyword() + name, testStep.getCodeLocation());
            stepTestThreadLocal.set(t);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    if (!testStep.getStepArgument().isEmpty()) {
        Argument argument = testStep.getStepArgument().get(0);
        if (argument instanceof PickleString) {
            createDocStringMap((PickleString)argument);
        } else if (argument instanceof PickleTable) {
            List<PickleRow> rows = ((PickleTable) argument).getRows();
            stepTestThreadLocal.get().pass(MarkupHelper.createTable(getPickleTable(rows)).getMarkup());
        }
    }
}
 
Example #6
Source File: MyExtentTestNgFormatter.java    From Java-API-Test-Examples with Apache License 2.0 6 votes vote down vote up
public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) {
    if (iInvokedMethod.isTestMethod()) {
        ExtentTest test = (ExtentTest) iTestResult.getAttribute("test");
        List<String> logs = Reporter.getOutput(iTestResult);
        for (String log : logs) {
            test.info(log);
        }

        int status = iTestResult.getStatus();
        if (ITestResult.SUCCESS == status) {
            test.pass("Passed");
        } else if (ITestResult.FAILURE == status) {
            test.fail(iTestResult.getThrowable());
        } else {
            test.skip("Skipped");
        }

        for (String group : iInvokedMethod.getTestMethod().getGroups()) {
            test.assignCategory(group);
        }
    }
}
 
Example #7
Source File: MyExtentTestNgFormatter.java    From Java-API-Test-Examples with Apache License 2.0 6 votes vote down vote up
public void onStart(ISuite iSuite) {
    if (iSuite.getXmlSuite().getTests().size() > 0) {
        ExtentTest suite = reporter.createTest(iSuite.getName());
        String configFile = iSuite.getParameter("report.config");

        if (!Strings.isNullOrEmpty(configFile)) {
            htmlReporter.loadXMLConfig(configFile);
        }

        String systemInfoCustomImplName = iSuite.getParameter("system.info");
        if (!Strings.isNullOrEmpty(systemInfoCustomImplName)) {
            generateSystemInfo(systemInfoCustomImplName);
        }

        iSuite.setAttribute(REPORTER_ATTR, reporter);
        iSuite.setAttribute(SUITE_ATTR, suite);
    }
}
 
Example #8
Source File: MyExtentTestNgFormatter.java    From Java-API-Test-Examples with Apache License 2.0 6 votes vote down vote up
public void onStart(ISuite iSuite) {
    if (iSuite.getXmlSuite().getTests().size() > 0) {
        ExtentTest suite = reporter.createTest(iSuite.getName());
        String configFile = iSuite.getParameter("report.config");

        if (!Strings.isNullOrEmpty(configFile)) {
            htmlReporter.loadXMLConfig(configFile);
        }

        String systemInfoCustomImplName = iSuite.getParameter("system.info");
        if (!Strings.isNullOrEmpty(systemInfoCustomImplName)) {
            generateSystemInfo(systemInfoCustomImplName);
        }

        iSuite.setAttribute(REPORTER_ATTR, reporter);
        iSuite.setAttribute(SUITE_ATTR, suite);
    }
}
 
Example #9
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 6 votes vote down vote up
private synchronized void createFeature(TestCase testCase) {
    Feature feature = testSources.getFeature(testCase.getUri());
    if (feature != null) {
        if (featureMap.containsKey(feature.getName())) {
            featureTestThreadLocal.set(featureMap.get(feature.getName()));
            return;
        }            
        if (featureTestThreadLocal.get() != null && featureTestThreadLocal.get().getModel().getName().equals(feature.getName())) {
            return;
        }
        ExtentTest t = ExtentService.getInstance()
                .createTest(com.aventstack.extentreports.gherkin.model.Feature.class, feature.getName(), feature.getDescription());
        featureTestThreadLocal.set(t);
        featureMap.put(feature.getName(), t);
        List<String> tagList = createTagsList(feature.getTags());
        tagList.forEach(featureTestThreadLocal.get()::assignCategory);
    }
}
 
Example #10
Source File: ExtentTestManager.java    From extentreports-testng-adapter with Apache License 2.0 6 votes vote down vote up
public static synchronized ExtentTest createMethod(ITestResult result) {
    String methodName = result.getMethod().getMethodName();
    if (result.getParameters().length > 0) {
        if (methodTest.get() != null && methodTest.get().getModel().getName().equals(methodName)) {
        } else {
            createTest(result, null);
        }
        String paramName = Arrays.asList(result.getParameters()).toString();
        ExtentTest paramTest = methodTest.get().createNode(paramName);
        dataProviderTest.set(paramTest);
    } else {
        dataProviderTest.set(null);
        createTest(result, null);
    }
    return methodTest.get();
}
 
Example #11
Source File: MyExtentTestNgFormatter.java    From Java-API-Test-Examples with Apache License 2.0 6 votes vote down vote up
public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) {
    if (iInvokedMethod.isTestMethod()) {
        ExtentTest test = (ExtentTest) iTestResult.getAttribute("test");
        List<String> logs = Reporter.getOutput(iTestResult);
        for (String log : logs) {
            test.info(log);
        }

        int status = iTestResult.getStatus();
        if (ITestResult.SUCCESS == status) {
            test.pass("Passed");
        } else if (ITestResult.FAILURE == status) {
            test.fail(iTestResult.getThrowable());
        } else {
            test.skip("Skipped");
        }

        for (String group : iInvokedMethod.getTestMethod().getGroups()) {
            test.assignCategory(group);
        }
    }
}
 
Example #12
Source File: ExtentIReporterSuiteListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 6 votes vote down vote up
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 #13
Source File: ExtentIReporterSuiteListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 6 votes vote down vote up
@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 #14
Source File: ExtentTestCommons.java    From extentreports-testng-adapter with Apache License 2.0 6 votes vote down vote up
public static void assignGroups(ExtentTest test, String[] groups) {
    if (groups.length > 0) {
        for (String g : groups) {
            if (g.startsWith("d:") || g.startsWith("device:")) {
                String d = g.replace("d:", "").replace("device:", "");
                test.assignDevice(d);
            } else if (g.startsWith("a:") || g.startsWith("author:")) {
                String a = g.replace("a:", "").replace("author:", "");
                test.assignAuthor(a);
            } else if (g.startsWith("t:") || g.startsWith("tag:")) {
                String t = g.replace("t:", "").replace("tag:", "");
                test.assignCategory(t);
            } else {
                test.assignCategory(g);
            }
        }
    }
}
 
Example #15
Source File: GherkinKeywordTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testGermanGherkinKeywords() throws ClassNotFoundException, UnsupportedEncodingException {
    ExtentReports extent = extent();
    extent.setGherkinDialect("de");
    
    ExtentTest feature = extent.createTest(new GherkinKeyword("Funktionalität"), "Refund item VM");
    ExtentTest scenario = feature.createNode(new GherkinKeyword("Szenario"), "Jeff returns a faulty microwave");
    ExtentTest given = scenario.createNode(new GherkinKeyword("Angenommen"), "Jeff has bought a microwave for $100").skip("skip");
    ExtentTest and = scenario.createNode(new GherkinKeyword("Und"), "he has a receipt").pass("pass");
    ExtentTest when = scenario.createNode(new GherkinKeyword("Wenn"), "he returns the microwave").pass("pass");
    ExtentTest then = scenario.createNode(new GherkinKeyword("Dann"), "Jeff should be refunded $100").skip("skip");
    
    Assert.assertEquals(feature.getModel().getBddType(), Feature.class);
    Assert.assertEquals(scenario.getModel().getBddType(), Scenario.class);
    Assert.assertEquals(given.getModel().getBddType(), Given.class);
    Assert.assertEquals(and.getModel().getBddType(), And.class);
    Assert.assertEquals(when.getModel().getBddType(), When.class);
    Assert.assertEquals(then.getModel().getBddType(), Then.class);
}
 
Example #16
Source File: GherkinKeywordTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnglishGherkinKeywords() throws ClassNotFoundException, UnsupportedEncodingException {
    ExtentReports extent = extent();
    extent.setGherkinDialect("en");
    
    ExtentTest feature = extent.createTest(new GherkinKeyword("Feature"), "Refund item VM");
    ExtentTest scenario = feature.createNode(new GherkinKeyword("Scenario"), "Jeff returns a faulty microwave");
    ExtentTest given = scenario.createNode(new GherkinKeyword("Given"), "Jeff has bought a microwave for $100").skip("skip");
    ExtentTest and = scenario.createNode(new GherkinKeyword("And"), "he has a receipt").pass("pass");
    ExtentTest when = scenario.createNode(new GherkinKeyword("When"), "he returns the microwave").pass("pass");
    ExtentTest then = scenario.createNode(new GherkinKeyword("Then"), "Jeff should be refunded $100").skip("skip");
    
    Assert.assertEquals(feature.getModel().getBddType(), Feature.class);
    Assert.assertEquals(scenario.getModel().getBddType(), Scenario.class);
    Assert.assertEquals(given.getModel().getBddType(), Given.class);
    Assert.assertEquals(and.getModel().getBddType(), And.class);
    Assert.assertEquals(when.getModel().getBddType(), When.class);
    Assert.assertEquals(then.getModel().getBddType(), Then.class);
}
 
Example #17
Source File: MyExtentTestNgFormatter.java    From TestHub with MIT License 6 votes vote down vote up
public void onStart(ISuite iSuite) {
    if (iSuite.getXmlSuite().getTests().size() > 0) {
        ExtentTest suite = reporter.createTest(iSuite.getName());
        String configFile = iSuite.getParameter("report.config");

        if (!Strings.isNullOrEmpty(configFile)) {
            htmlReporter.loadXMLConfig(configFile);
        }

        String systemInfoCustomImplName = iSuite.getParameter("system.info");
        if (!Strings.isNullOrEmpty(systemInfoCustomImplName)) {
            generateSystemInfo(systemInfoCustomImplName);
        }

        iSuite.setAttribute(REPORTER_ATTR, reporter);
        iSuite.setAttribute(SUITE_ATTR, suite);
    }
}
 
Example #18
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 6 votes vote down vote up
@org.testng.annotations.Test
public void exceptionContext() {
    String msg = "An exception has occurred.";
    RuntimeException ex = new RuntimeException(msg);
    ExtentReports extent = extent();
    ExtentTest test = extent.createTest("Test");
    NamedAttributeContextManager<ExceptionInfo> context = extent.getReport().getExceptionInfoCtx();
    Assert.assertFalse(context.hasItems());
    test.fail(ex);
    test.assignDevice("x");
    Assert.assertTrue(context.hasItems());
    Assert.assertTrue(
            context.getSet().stream().anyMatch(x -> x.getAttr().getName().equals("java.lang.RuntimeException")));
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getTestList().size() == 1));
    Assert.assertTrue(context.getSet().stream()
            .flatMap(x -> x.getTestList().stream())
            .anyMatch(x -> x.getName().equals("Test")));
}
 
Example #19
Source File: MyExtentTestNgFormatter.java    From TestHub with MIT License 6 votes vote down vote up
public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) {
    if (iInvokedMethod.isTestMethod()) {
        ExtentTest test = (ExtentTest) iTestResult.getAttribute("test");
        List<String> logs = Reporter.getOutput(iTestResult);
        for (String log : logs) {
            test.info(log);
        }

        int status = iTestResult.getStatus();
        if (ITestResult.SUCCESS == status) {
            test.pass("Passed");
        } else if (ITestResult.FAILURE == status) {
            test.fail(iTestResult.getThrowable());
        } else {
            test.skip("Skipped");
        }

        for (String group : iInvokedMethod.getTestMethod().getGroups()) {
            test.assignCategory(group);
        }
    }
}
 
Example #20
Source File: ExtentTestManager.java    From extentreports-testng-adapter with Apache License 2.0 5 votes vote down vote up
private static synchronized ExtentTest createTest(ITestResult result, ExtentTest classTest) {
    String methodName = result.getMethod().getMethodName();
    String desc = result.getMethod().getDescription();
    ExtentTest test;
    if (classTest != null) {
        test = classTest.createNode(methodName, desc);
    } else {
        test = ExtentService.getInstance().createTest(methodName, desc);
    }
    methodTest.set(test);
    String[] groups = result.getMethod().getGroups();
    ExtentTestCommons.assignGroups(test, groups);
    return test;
}
 
Example #21
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 5 votes vote down vote up
private void addScenario(ExtentTest featureNode, Scenario scenario) {
    final ExtentTest scenarioNode = createGherkinNode(featureNode, "Scenario", scenario.getName(), false);
    addBeforeOrAfterDetails(scenarioNode, scenario.getBefore());
    addSteps(scenarioNode, scenario);
    addBeforeOrAfterDetails(scenarioNode, scenario.getAfter());
    assignCategoryToScenario(scenarioNode, scenario.getTags());
}
 
Example #22
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 5 votes vote down vote up
private ExtentTest createGherkinNode(ExtentTest parent, String keyword, String name, boolean appendKeyword) {
    try {
        String nodeName = appendKeyword ? (keyword + " " + name) : name;
        return parent.createNode(new GherkinKeyword(keyword), nodeName);
    } catch (ClassNotFoundException e) {
        throw new CourgetteException(e);
    }
}
 
Example #23
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@org.testng.annotations.Test
public void deviceCtx() {
    ExtentReports extent = extent();
    ExtentTest test = extent.createTest("Test");
    NamedAttributeContextManager<Device> context = extent.getReport().getDeviceCtx();
    Assert.assertFalse(context.hasItems());
    test.assignDevice("x");
    Assert.assertTrue(context.hasItems());
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getAttr().getName().equals("x")));
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getTestList().size() == 1));
    Assert.assertTrue(context.getSet().stream()
            .flatMap(x -> x.getTestList().stream())
            .anyMatch(x -> x.getName().equals("Test")));
}
 
Example #24
Source File: ReportEntityTest.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@org.testng.annotations.Test
public void authorCtx() {
    ExtentReports extent = extent();
    ExtentTest test = extent.createTest("Test");
    NamedAttributeContextManager<Author> context = extent.getReport().getAuthorCtx();
    Assert.assertFalse(context.hasItems());
    test.assignAuthor("x");
    Assert.assertTrue(context.hasItems());
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getAttr().getName().equals("x")));
    Assert.assertTrue(context.getSet().stream().anyMatch(x -> x.getTestList().size() == 1));
    Assert.assertTrue(context.getSet().stream()
            .flatMap(x -> x.getTestList().stream())
            .anyMatch(x -> x.getName().equals("Test")));
}
 
Example #25
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 5 votes vote down vote up
private void setStepResult(ExtentTest extentTest, Step step, boolean isStrict) {
    if (step.skipped()) {
        extentTest.skip("");
    } else if (step.passed(isStrict)) {
        extentTest.pass("");
    } else {
        extentTest.fail("");
    }
}
 
Example #26
Source File: RawEntityConverter.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
private void addMedia(Test test, ExtentTest extentTest) {
    if (test.getMedia() != null) {
        for (Media m : test.getMedia()) {
            if (m.getPath() != null) {
                extentTest.addScreenCaptureFromPath(m.getPath());
            } else if (m instanceof ScreenCapture) {
                extentTest.addScreenCaptureFromBase64String(((ScreenCapture) m).getBase64());
            }
        }
    }
}
 
Example #27
Source File: RawEntityConverter.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
public void createDomain(Test test, ExtentTest extentTest) throws ClassNotFoundException {
    extentTest.getModel().setStartTime(test.getStartTime());
    extentTest.getModel().setEndTime(test.getEndTime());
    addMedia(test, extentTest);

    // create events
    for (Log log : test.getLogs()) {
        if (log.hasException() && log.hasMedia())
            addMedia(log, extentTest, log.getException().getException());
        else if (log.hasException())
            extentTest.log(log.getStatus(), log.getException().getException());
        else if (log.hasMedia())
            addMedia(log, extentTest, null);
        else
            extentTest.log(log.getStatus(), log.getDetails());
    }

    // assign attributes
    test.getAuthorSet().stream().map(x -> x.getName()).forEach(extentTest::assignAuthor);
    test.getCategorySet().stream().map(x -> x.getName()).forEach(extentTest::assignCategory);
    test.getDeviceSet().stream().map(x -> x.getName()).forEach(extentTest::assignDevice);

    // handle nodes
    for (Test node : test.getChildren()) {
        ExtentTest extentNode = null;
        if (node.getBddType() == null)
            extentNode = extentTest.createNode(node.getName(), node.getDescription());
        else
            extentNode = extentTest.createNode(new GherkinKeyword(node.getBddType().toString()), node.getName(),
                    node.getDescription());
        addMedia(node, extentNode);
        createDomain(node, extentNode);
    }
}
 
Example #28
Source File: MyExtentTestNgFormatter.java    From Java-API-Test-Examples with Apache License 2.0 5 votes vote down vote up
public void onStart(ITestContext iTestContext) {
      ISuite iSuite = iTestContext.getSuite();
      ExtentTest suite = (ExtentTest) iSuite.getAttribute(SUITE_ATTR);
      ExtentTest testContext = suite.createNode(iTestContext.getName());
// 自定义报告
// 将MyReporter.report 静态引用赋值为 testContext。
// testContext 是 @Test每个测试用例时需要的。report.log可以跟随具体的测试用例。另请查阅源码。
      MyReporter.report = testContext;
      iTestContext.setAttribute("testContext", testContext);
  }
 
Example #29
Source File: MyExtentTestNgFormatter.java    From TestHub with MIT License 5 votes vote down vote up
/**
 * Marks the given node as failed
 *
 * @param nodeName   The name of the node
 * @param logMessage The message to be logged
 */
public void failTheNode(String nodeName, String logMessage) {
    ITestResult result = Reporter.getCurrentTestResult();
    Preconditions.checkState(result != null);
    ExtentTest test = (ExtentTest) result.getAttribute(nodeName);
    test.fail(logMessage);
}
 
Example #30
Source File: ExtentReportsBuilder.java    From courgette-jvm with MIT License 5 votes vote down vote up
private void addImageEmbeddings(ExtentTest node, List<Embedding> embeddings) {
    embeddings.forEach(embedding -> {
        if (embedding.getMimeType().startsWith("image")) {
            addBase64ScreenCapture(node, embedding.getData());
        }
    });
}