Java Code Examples for org.testng.ITestResult#getStatus()
The following examples show how to use
org.testng.ITestResult#getStatus() .
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: JUnitXMLReporter.java From olat with Apache License 2.0 | 5 votes |
private static int getErrors(List<ITestResult> results) { int retval = 0; for (ITestResult result : results) { if (result != null && result.getStatus() != ITestResult.SUCCESS && result.getStatus() != ITestResult.SUCCESS_PERCENTAGE_FAILURE && result.getStatus() != ITestResult.FAILURE) retval++; } return retval; }
Example 2
Source File: ImageValidatorE2ETest.java From cloudbreak with Apache License 2.0 | 5 votes |
@AfterMethod public void setImageId(Object[] data, ITestResult result) { TestContext testContext = (TestContext) data[0]; if (result.getStatus() == ITestResult.SUCCESS) { LOG.info("The test was successful with this image: " + getImageId(testContext)); writeImageIdToFile(testContext); } }
Example 3
Source File: MyCoursesTestSuiteBase.java From edx-app-android with Apache License 2.0 | 5 votes |
/** * Recovery Scenario for all the screens if any of the test case fails * * @throws Throwable */ @AfterMethod(alwaysRun = true) public void recoveryScenario(ITestResult rs) throws Throwable { if (rs.getStatus() == 2) { gotoMyCoursesView(); Reporter.log("Failed Test: " + rs.getTestName()); } }
Example 4
Source File: JUnitXMLReporter.java From jgroups-raft with Apache License 2.0 | 5 votes |
protected void addTest(Class<?> clazz, ITestResult result) { try { TestCase test_case=new TestCase(result.getStatus(), clazz.getName(), getMethodName(result), result.getStartMillis(), result.getEndMillis()); switch(result.getStatus()) { case ITestResult.FAILURE: case ITestResult.SKIP: Throwable ex=result.getThrowable(); if(ex != null) { String failure_type=ex.getClass().getName(); String failure_msg=ex.getMessage(); String stack_trace=printException(ex); test_case.setFailure(failure_type, failure_msg, stack_trace); } else test_case.setFailure("exception", "SKIPPED", null); break; } synchronized(this) { // handle concurrent access by different threads, if test methods are run in parallel DataOutputStream output=tests.get(clazz); test_case.writeTo(output); } } catch(Exception e) { error(e.toString()); } }
Example 5
Source File: FindCourseTestSuiteBase.java From edx-app-android with Apache License 2.0 | 5 votes |
/** * Recovery Scenario for Find Courses screen if any of the test case fails * * @throws Throwable */ @AfterMethod(alwaysRun = true) public void recoveryScenario(ITestResult rs) throws Throwable { if (rs.getStatus() == 2) { Reporter.log("Failed Test: " + rs.getTestName()); } }
Example 6
Source File: TestHarness.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@AfterMethod public void printError(ITestResult result) { if (result.getStatus() == ITestResult.FAILURE) { String clsName = result.getTestClass().getName(); clsName = clsName.substring(clsName.lastIndexOf(".") + 1); System.out.println("Test " + clsName + "." + result.getName() + " FAILED"); } }
Example 7
Source File: JUnitXMLReporter.java From olat with Apache License 2.0 | 5 votes |
private static int getFailures(List<ITestResult> results) { int retval = 0; for (ITestResult result : results) { if (result != null && result.getStatus() == ITestResult.FAILURE) retval++; } return retval; }
Example 8
Source File: UITestRunner.java From frameworkium-bdd with Apache License 2.0 | 5 votes |
private void logResult(ITestResult result) { switch (result.getStatus()) { case ITestResult.FAILURE: logger.error("FAIL {}", scenarioName.get()); break; case ITestResult.SKIP: logger.warn("SKIP {}", scenarioName.get()); break; case ITestResult.SUCCESS: logger.info("PASS {}", scenarioName.get()); break; default: logger.warn("Unexpected result status: {}", result.getStatus()); } }
Example 9
Source File: Helpers.java From AppiumTestDistribution with GNU General Public License v3.0 | 5 votes |
protected String getStatus(ITestResult result) { switch (result.getStatus()) { case ITestResult.SUCCESS: return "Pass"; case ITestResult.FAILURE: return "Fail"; case ITestResult.SKIP: return "Skip"; default: return "Unknown"; } }
Example 10
Source File: APITestRunner.java From frameworkium-bdd with Apache License 2.0 | 5 votes |
private void logResult(ITestResult result) { switch (result.getStatus()) { case ITestResult.FAILURE: logger.error("FAIL {}", scenarioName.get()); break; case ITestResult.SKIP: logger.warn("SKIP {}", scenarioName.get()); break; case ITestResult.SUCCESS: logger.info("PASS {}", scenarioName.get()); break; default: logger.warn("Unexpected result status: {}", result.getStatus()); } }
Example 11
Source File: JUnitXMLReporter.java From olat with Apache License 2.0 | 5 votes |
private static int getErrors(List<ITestResult> results) { int retval = 0; for (ITestResult result : results) { if (result != null && result.getStatus() != ITestResult.SUCCESS && result.getStatus() != ITestResult.SUCCESS_PERCENTAGE_FAILURE && result.getStatus() != ITestResult.FAILURE) retval++; } return retval; }
Example 12
Source File: TestHarness.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@AfterMethod public void printError(ITestResult result) { if (result.getStatus() == ITestResult.FAILURE) { String clsName = result.getTestClass().getName(); clsName = clsName.substring(clsName.lastIndexOf(".") + 1); System.out.println("Test " + clsName + "." + result.getName() + " FAILED"); } }
Example 13
Source File: LoginTestSuiteBase.java From edx-app-android with Apache License 2.0 | 5 votes |
/** * Recovery Scenario for all the screens if any of the test case fails * * @throws Throwable */ @AfterMethod(alwaysRun = true) public void recoveryScenario(ITestResult rs) throws Throwable { if (rs.getStatus() == 2) { Reporter.log("Test case "+rs.getTestName()+" failed"); driver.launchApp(); } }
Example 14
Source File: TestHarness.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@AfterMethod public void printError(ITestResult result) { if (result.getStatus() == ITestResult.FAILURE) { String clsName = result.getTestClass().getName(); clsName = clsName.substring(clsName.lastIndexOf(".") + 1); System.out.println("Test " + clsName + "." + result.getName() + " FAILED"); } }
Example 15
Source File: TestHarness.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@AfterMethod public void printError(ITestResult result) { if (result.getStatus() == ITestResult.FAILURE) { String clsName = result.getTestClass().getName(); clsName = clsName.substring(clsName.lastIndexOf(".") + 1); System.out.println("Test " + clsName + "." + result.getName() + " FAILED"); } }
Example 16
Source File: TestHarness.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@AfterMethod public void printError(ITestResult result) { if (result.getStatus() == ITestResult.FAILURE) { String clsName = result.getTestClass().getName(); clsName = clsName.substring(clsName.lastIndexOf(".") + 1); System.out.println("Test " + clsName + "." + result.getName() + " FAILED"); } }
Example 17
Source File: EarlReporter.java From teamengine with Apache License 2.0 | 4 votes |
/** * Creates EARL statements from the given test results. A test result is * described by an Assertion resource. The TestResult and TestCase resources * are linked to the Assertion in accord with the EARL schema; the latter is * also linked to a TestRequirement. * * @param earl * An RDF Model containing EARL statements. * @param results * The results of invoking a collection of test methods. */ void processTestResults(Model earl, IResultMap results) { for (ITestResult tngResult : results.getAllResults()) { // create earl:Assertion long endTime = tngResult.getEndMillis(); GregorianCalendar calTime = new GregorianCalendar(TimeZone.getDefault()); calTime.setTimeInMillis(endTime); Resource assertion = earl.createResource("assert-" + ++this.resultCount, EARL.Assertion); assertion.addProperty(EARL.mode, EARL.AutomaticMode); assertion.addProperty(EARL.assertedBy, this.assertor); assertion.addProperty(EARL.subject, this.testSubject); // link earl:TestResult to earl:Assertion Resource earlResult = earl.createResource("result-" + this.resultCount, EARL.TestResult); earlResult.addProperty(DCTerms.date, earl.createTypedLiteral(calTime)); switch (tngResult.getStatus()) { case ITestResult.FAILURE: earlResult.addProperty(DCTerms.description, getDetailMessage(tngResult)); if (AssertionError.class.isInstance(tngResult.getThrowable())) { earlResult.addProperty(EARL.outcome, EARL.Fail); } else { // an exception occurred earlResult.addProperty(EARL.outcome, EARL.CannotTell); } processResultAttributes(earlResult, tngResult); break; case ITestResult.SKIP: earlResult.addProperty(DCTerms.description, getDetailMessage(tngResult)); earlResult.addProperty(EARL.outcome, EARL.NotTested); break; default: earlResult.addProperty(EARL.outcome, EARL.Pass); break; } assertion.addProperty(EARL.result, earlResult); // link earl:TestCase to earl:Assertion and earl:TestRequirement String testMethodName = tngResult.getMethod().getMethodName(); String testClassName = tngResult.getTestClass().getName().replaceAll("\\.", "/"); StringBuilder testCaseId = new StringBuilder(testClassName); testCaseId.append('#').append(testMethodName); Resource testCase = earl.createResource(testCaseId.toString(), EARL.TestCase); testCase.addProperty(DCTerms.title, breakIntoWords(testMethodName)); String testDescr = tngResult.getMethod().getDescription(); if (null != testDescr && !testDescr.isEmpty()) { testCase.addProperty(DCTerms.description, testDescr); } assertion.addProperty(EARL.test, testCase); String testReqName = tngResult.getTestContext().getName().replaceAll("\\s", "-"); earl.createResource(testReqName).addProperty(DCTerms.hasPart, testCase); } }
Example 18
Source File: VerboseReporter.java From brooklyn-server with Apache License 2.0 | 4 votes |
/** * Log meaningful message for passed in arguments. * Message itself is of form: * $status: "$suiteName" - $methodDeclaration ($actualArguments) finished in $x ms ($run of $totalRuns) * * @param st status of passed in itr * @param itr test result to be described * @param isConfMethod is itr describing configuration method */ private void logTestResult(Status st, ITestResult itr, boolean isConfMethod) { StringBuilder sb = new StringBuilder(); String stackTrace = ""; switch (st) { case STARTED: sb.append("INVOKING"); break; case SKIP: sb.append("SKIPPED"); stackTrace = itr.getThrowable() != null ? Utils.stackTrace(itr.getThrowable(), false)[0] : ""; break; case FAILURE: sb.append("FAILED"); stackTrace = itr.getThrowable() != null ? Utils.stackTrace(itr.getThrowable(), false)[0] : ""; break; case SUCCESS: sb.append("PASSED"); break; case SUCCESS_PERCENTAGE_FAILURE: sb.append("PASSED with failures"); break; default: //not happen throw new RuntimeException("Unsupported test status:" + itr.getStatus()); } if (isConfMethod) { sb.append(" CONFIGURATION: "); } else { sb.append(": "); } ITestNGMethod tm = itr.getMethod(); int identLevel = sb.length(); sb.append(getMethodDeclaration(tm)); Object[] params = itr.getParameters(); Class<?>[] paramTypes = tm.getConstructorOrMethod().getParameterTypes(); if (null != params && params.length > 0) { // The error might be a data provider parameter mismatch, so make // a special case here if (params.length != paramTypes.length) { sb.append("Wrong number of arguments were passed by the Data Provider: found "); sb.append(params.length); sb.append(" but expected "); sb.append(paramTypes.length); } else { sb.append("(value(s): "); for (int i = 0; i < params.length; i++) { if (i > 0) { sb.append(", "); } sb.append(Utils.toString(params[i], paramTypes[i])); } sb.append(")"); } } if (Status.STARTED != st) { sb.append(" finished in "); sb.append(itr.getEndMillis() - itr.getStartMillis()); sb.append(" ms"); if (!Utils.isStringEmpty(tm.getDescription())) { sb.append("\n"); for (int i = 0; i < identLevel; i++) { sb.append(" "); } sb.append(tm.getDescription()); } if (tm.getInvocationCount() > 1) { sb.append(" ("); sb.append(tm.getCurrentInvocationCount()); sb.append(" of "); sb.append(tm.getInvocationCount()); sb.append(")"); } if (!Utils.isStringEmpty(stackTrace)) { sb.append("\n").append(stackTrace.substring(0, stackTrace.lastIndexOf(System.getProperty("line.separator")))); } } else { if (!isConfMethod && tm.getInvocationCount() > 1) { sb.append(" success: "); sb.append(tm.getSuccessPercentage()); sb.append("%"); } } log(sb.toString()); }
Example 19
Source File: CarinaListener.java From carina with Apache License 2.0 | 4 votes |
private void onTestFinish(ITestResult result) { try { // clear all kind of temporary properties R.CONFIG.clearTestProperties(); R.TESTDATA.clearTestProperties(); R.DATABASE.clearTestProperties(); R.EMAIL.clearTestProperties(); R.REPORT.clearTestProperties(); R.ZAFIRA.clearTestProperties(); LOGGER.debug("Test result is : " + result.getStatus()); // result status == 2 means failure, status == 3 means skip. We need to quit driver anyway for failure and skip if ((automaticDriversCleanup && !hasDependencies(result)) || result.getStatus() == 2 || result.getStatus() == 3) { quitDrivers(Phase.BEFORE_METHOD, Phase.METHOD); } // TODO: improve later removing duplicates with AbstractTestListener // handle Zafira already passed exception for re-run and do nothing. // maybe return should be enough if (result.getThrowable() != null && result.getThrowable().getMessage() != null && result.getThrowable().getMessage().startsWith(SpecialKeywords.ALREADY_PASSED)) { // [VD] it is prohibited to release TestInfoByThread in this // place.! return; } // handle CarinaListener->SkipExecution if (result.getThrowable() != null && result.getThrowable().getMessage() != null && result.getThrowable().getMessage().startsWith(SpecialKeywords.SKIP_EXECUTION)) { // [VD] it is prohibited to release TestInfoByThread in this // place.! return; } List<String> tickets = Jira.getTickets(result); result.setAttribute(SpecialKeywords.JIRA_TICKET, tickets); Jira.updateAfterTest(result); // we shouldn't deregister info here as all retries will not work // TestNamingUtil.releaseZafiraTest(); } catch (Exception e) { LOGGER.error("Exception in CarinaListener->onTestFinish!", e); } }
Example 20
Source File: SeleniumTestHandler.java From che with Eclipse Public License 2.0 | 4 votes |
/** Is invoked when test or configuration is finished. */ private void onTestFinish(ITestResult result) { // do not treat SeleniumTestHandler error as test failure if (testsWithFailure.containsKey(result.getTestClass().getRealClass().getName()) && testsWithFailure .get(result.getTestClass().getRealClass().getName()) .getMethod() .equals(result.getMethod()) && result.getMethod().getCurrentInvocationCount() == 1) { // restore initial test exception result.setThrowable( testsWithFailure.get(result.getTestClass().getRealClass().getName()).getThrowable()); return; } if (result.getStatus() == ITestResult.FAILURE || result.getStatus() == ITestResult.SKIP) { switch (result.getStatus()) { case ITestResult.FAILURE: if (result.getMethod().isTest()) { String errorDetails = result.getThrowable() != null ? " Error: " + result.getThrowable().getLocalizedMessage() : ""; LOG.error("Test {} failed.{}", getCompletedTestLabel(result.getMethod()), errorDetails); LOG.debug(result.getThrowable().getLocalizedMessage(), result.getThrowable()); testsWithFailure.put(result.getTestClass().getRealClass().getName(), result); } captureWebDriver(result); captureTestWorkspaceLogs(result); break; case ITestResult.SKIP: String skipReasonDetails = result.getThrowable() != null ? " The reason: " + result.getThrowable().getLocalizedMessage() : ""; if (result.getMethod().isTest()) { LOG.warn( "Test {} skipped.{}", getCompletedTestLabel(result.getMethod()), skipReasonDetails); } // don't capture test data if test is skipped because of previous test with higher // priority failed if (testsWithFailure.containsKey(result.getMethod().getInstance().getClass().getName())) { return; } break; default: } } }