Java Code Examples for org.testng.ITestNGMethod#isAlwaysRun()
The following examples show how to use
org.testng.ITestNGMethod#isAlwaysRun() .
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: SeleniumTestHandler.java From che with Eclipse Public License 2.0 | 6 votes |
/** * Skip test if preceding test with higher priority from the same test class has failed. * * @param result holds result of test execution * @throws SkipException if test should be skipped */ private void skipTestIfNeeded(ITestResult result) { ITestNGMethod testMethodToSkip = result.getMethod(); ITestResult failedTestResult = testsWithFailure.get(testMethodToSkip.getInstance().getClass().getName()); // skip test with lower priority value and if it shouldn't always run if (failedTestResult != null && testMethodToSkip.getPriority() > failedTestResult.getMethod().getPriority() && !testMethodToSkip.isAlwaysRun()) { throw new SkipException( format( "Skipping test %s because it depends on test %s which has failed earlier.", getStartingTestLabel(testMethodToSkip), getCompletedTestLabel(failedTestResult.getMethod()))); } }
Example 2
Source File: MethodHelper.java From qaf with MIT License | 4 votes |
/** * Finds TestNG methods that the specified TestNG method depends upon * @param m TestNG method * @param methods list of methods to search for depended upon methods * @return list of methods that match the criteria */ protected static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, ITestNGMethod[] methods) { String canonicalMethodName = calculateMethodCanonicalName(m); List<ITestNGMethod> vResult = Lists.newArrayList(); String regexp = null; for (String fullyQualifiedRegexp : m.getMethodsDependedUpon()) { boolean foundAtLeastAMethod = false; if (null != fullyQualifiedRegexp) { // Escapes $ in regexps as it is not meant for end - line matching, but inner class matches. regexp = fullyQualifiedRegexp.replace("$", "\\$"); boolean usePackage = regexp.indexOf('.') != -1; Pattern pattern = Pattern.compile(regexp); for (ITestNGMethod method : methods) { ConstructorOrMethod thisMethod = method.getConstructorOrMethod(); String thisMethodName = thisMethod.getName(); String methodName = usePackage ? calculateMethodCanonicalName(method) : thisMethodName; Pair<String, String> cacheKey = Pair.create(regexp, methodName); Boolean match = MATCH_CACHE.get(cacheKey); if (match == null) { match = pattern.matcher(methodName).matches(); MATCH_CACHE.put(cacheKey, match); } if (match) { vResult.add(method); foundAtLeastAMethod = true; } } } if (!foundAtLeastAMethod) { if (m.ignoreMissingDependencies()) { continue; } if (m.isAlwaysRun()) { continue; } Method maybeReferringTo = findMethodByName(m, regexp); if (maybeReferringTo != null) { throw new TestNGException(canonicalMethodName + "() is depending on method " + maybeReferringTo + ", which is not annotated with @Test or not included."); } throw new TestNGException(canonicalMethodName + "() depends on nonexistent method " + regexp); } }//end for return vResult.toArray(new ITestNGMethod[vResult.size()]); }