Java Code Examples for com.aventstack.extentreports.ExtentTest#fail()
The following examples show how to use
com.aventstack.extentreports.ExtentTest#fail() .
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: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 6 votes |
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 2
Source File: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 6 votes |
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 3
Source File: MyExtentTestNgFormatter.java From TestHub with MIT License | 6 votes |
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 4
Source File: ReportEntityTest.java From extentreports-java with Apache License 2.0 | 6 votes |
@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 5
Source File: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 5 votes |
public void onFinish(ITestContext iTestContext) { ExtentTest testContext = (ExtentTest) iTestContext.getAttribute("testContext"); if (iTestContext.getFailedTests().size() > 0) { testContext.fail("Failed"); } else if (iTestContext.getSkippedTests().size() > 0) { testContext.skip("Skipped"); } else { testContext.pass("Passed"); } }
Example 6
Source File: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 5 votes |
/** * Marks the given node as failed * * @param nodeName The name of the node * @param t The {@link Throwable} object */ public void failTheNode(String nodeName, Throwable t) { ITestResult result = Reporter.getCurrentTestResult(); Preconditions.checkState(result != null); ExtentTest test = (ExtentTest) result.getAttribute(nodeName); test.fail(t); }
Example 7
Source File: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 5 votes |
/** * 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 8
Source File: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 5 votes |
public void onFinish(ITestContext iTestContext) { ExtentTest testContext = (ExtentTest) iTestContext.getAttribute("testContext"); if (iTestContext.getFailedTests().size() > 0) { testContext.fail("Failed"); } else if (iTestContext.getSkippedTests().size() > 0) { testContext.skip("Skipped"); } else { testContext.pass("Passed"); } }
Example 9
Source File: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 5 votes |
/** * Marks the given node as failed * * @param nodeName The name of the node * @param t The {@link Throwable} object */ public void failTheNode(String nodeName, Throwable t) { ITestResult result = Reporter.getCurrentTestResult(); Preconditions.checkState(result != null); ExtentTest test = (ExtentTest) result.getAttribute(nodeName); test.fail(t); }
Example 10
Source File: MyExtentTestNgFormatter.java From Java-API-Test-Examples with Apache License 2.0 | 5 votes |
/** * 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 11
Source File: MyExtentTestNgFormatter.java From TestHub with MIT License | 5 votes |
public void onFinish(ITestContext iTestContext) { ExtentTest testContext = (ExtentTest) iTestContext.getAttribute("testContext"); if (iTestContext.getFailedTests().size() > 0) { testContext.fail("Failed"); } else if (iTestContext.getSkippedTests().size() > 0) { testContext.skip("Skipped"); } else { testContext.pass("Passed"); } }
Example 12
Source File: MyExtentTestNgFormatter.java From TestHub with MIT License | 5 votes |
/** * Marks the given node as failed * * @param nodeName The name of the node * @param t The {@link Throwable} object */ public void failTheNode(String nodeName, Throwable t) { ITestResult result = Reporter.getCurrentTestResult(); Preconditions.checkState(result != null); ExtentTest test = (ExtentTest) result.getAttribute(nodeName); test.fail(t); }
Example 13
Source File: MyExtentTestNgFormatter.java From TestHub with MIT License | 5 votes |
/** * 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 14
Source File: ExtentReportsBuilder.java From courgette-jvm with MIT License | 5 votes |
private void setStepResult(ExtentTest extentTest, Step step, boolean isStrict) { if (step.skipped()) { extentTest.skip(""); } else if (step.passed(isStrict)) { extentTest.pass(""); } else { extentTest.fail(""); } }