@Override public boolean getEnabled() { return testNGMethod.getEnabled(); }
private static int getDisabledTestCount(Set<ITestNGMethod> methods) { int count = 0; for (ITestNGMethod method : methods) { if (!method.getEnabled()) { count = count + 1; } } return count; }
private static int getDisabledTestCount(Set<ITestNGMethod> methods) { int count = 0; for (ITestNGMethod method : methods) { if (!method.getEnabled()) { count = count + 1; } } return count; }
@Override public boolean getEnabled() { return testNGMethod.getEnabled(); }
/** * Remove the method from this map and returns true if it is the last * of its class. */ public boolean removeAndCheckIfLast(ITestNGMethod m, Object instance) { Collection<ITestNGMethod> l = classMap.get(instance); if (l == null) { throw new AssertionError("l should not be null"); } l.remove(m); // It's the last method of this class if all the methods remaining in the list belong to a // different class for (ITestNGMethod tm : l) { if (tm.getEnabled() && tm.getTestClass().equals(m.getTestClass())) { return false; } } return true; }
private void addMapping(SetMultiMap<Class<?>, ITestNGMethod> mapping, Collection<ITestNGMethod> methods) { for (ITestNGMethod method : methods) { if (! method.getEnabled()) { mapping.put(method.getRealClass(), method); } } } }
/** Remove the method from this map and returns true if it is the last of its class. */ public boolean removeAndCheckIfLast(ITestNGMethod m, Object instance) { Collection<ITestNGMethod> l = classMap.get(instance); if (l == null) { throw new AssertionError("l should not be null"); } l.remove(m); // It's the last method of this class if all the methods remaining in the list belong to a // different class for (ITestNGMethod tm : l) { if (tm.getEnabled() && tm.getTestClass().equals(m.getTestClass())) { return false; } } return true; }
private void addMapping( SetMultiMap<Class<?>, ITestNGMethod> mapping, Collection<ITestNGMethod> methods) { for (ITestNGMethod method : methods) { if (!method.getEnabled()) { mapping.put(method.getRealClass(), method); } } } }
@Override public boolean getEnabled() { return delegate.getEnabled(); }
@Override public boolean getEnabled() { return delegate.getEnabled(); }
@Override public boolean getEnabled() { return method.getEnabled(); }
private void checkMethodAnnotations(List<String> errors, ITestNGMethod m) { if (!m.getEnabled()) return;
private boolean isPriorityUnique(IInvokedMethod method) { // Logic to check priorities of all test methods are unique. This is used in Session Sharing. Set<Integer> check = new HashSet<Integer>(); int length = method.getTestMethod().getTestClass().getTestMethods().length; int expectedSize = 0; for (int i = 0; i < length; i++) { //ignore @Test(enabled = false) methods if (!method.getTestMethod().getTestClass().getTestMethods()[i].getEnabled()) { continue; } check.add(method.getTestMethod().getTestClass().getTestMethods()[i].getPriority()); expectedSize += 1; if (check.size() != expectedSize) { return false; } } return true; }
private boolean isLowPriority(IInvokedMethod method) { int low = method.getTestMethod().getPriority(); for (ITestNGMethod test : method.getTestMethod().getTestClass().getTestMethods()) { // ensures all test methods have the @Test annotation. Throw exception if that's not the case if (!isAnnotatedWithTest(test.getConstructorOrMethod().getMethod())) { throw new IllegalStateException( "Session sharing requires all test methods to define a priority via the @Test annotation."); } if (test.getEnabled() && test.getPriority() < low) { return false; } } Test t = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class); // If there is an existing session and the test method has a DP then don't create a session // For a data driven test method with the first data the session must be created // Hence return true if currentInvocationCount is 1 otherwise utilize the same session // by returning false int currentInvocationCount = method.getTestMethod().getCurrentInvocationCount(); if (!t.dataProvider().isEmpty()) { return currentInvocationCount == 0; } return true; }
private boolean isHighPriority(IInvokedMethod method) { if (!isAnnotatedWithTest(method)) { // Abort. There will already be an exception thrown in isLowPriority for this case. return true; } int high = method.getTestMethod().getPriority(); for (ITestNGMethod test : method.getTestMethod().getTestClass().getTestMethods()) { if (test.getEnabled() && test.getPriority() > high) { return false; } } Test t = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class); // For a test method with a data provider if (!(t.dataProvider().isEmpty())) { int currentInvocationCount = method.getTestMethod().getCurrentInvocationCount(); int parameterInvocationCount = method.getTestMethod().getParameterInvocationCount(); // If the data set from the data provider is exhausted // It means its the last method with the data provider- this is the exit condition return (currentInvocationCount == parameterInvocationCount); } return true; }
private void addPendingMethods(ITestContext iTestContext) { for (ITestNGMethod method : iTestContext.getExcludedMethods()) { if (method.isTest() && !method.getEnabled() && isInActiveGroup(method, iTestContext)) { Description description = new Description().withValue(method.getDescription()); String suiteUid = getSuiteUid(iTestContext); TestCaseStartedEvent event = new TestCaseStartedEvent(suiteUid, method.getMethodName()); if (description.getValue() != null) { event.setDescription(description); } Annotation[] annotations = method.getConstructorOrMethod().getMethod().getAnnotations(); AnnotationManager am = new AnnotationManager(annotations); am.setDefaults(method.getInstance().getClass().getAnnotations()); am.update(event); getLifecycle().fire(event); getLifecycle().fire(new TestCasePendingEvent()); fireFinishTest(); } } }