Java Code Examples for org.testng.ITestNGMethod#isBeforeClassConfiguration()

The following examples show how to use org.testng.ITestNGMethod#isBeforeClassConfiguration() . 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: MethodHelper.java    From qaf with MIT License 6 votes vote down vote up
private static List<ITestNGMethod> sortMethods(boolean forTests,
    List<ITestNGMethod> allMethods, IAnnotationFinder finder) {
  List<ITestNGMethod> sl = Lists.newArrayList();
  List<ITestNGMethod> pl = Lists.newArrayList();
  ITestNGMethod[] allMethodsArray = allMethods.toArray(new ITestNGMethod[allMethods.size()]);

  // Fix the method inheritance if these are @Configuration methods to make
  // sure base classes are invoked before child classes if 'before' and the
  // other way around if they are 'after'
  if (!forTests && allMethodsArray.length > 0) {
    ITestNGMethod m = allMethodsArray[0];
    boolean before = m.isBeforeClassConfiguration()
        || m.isBeforeMethodConfiguration() || m.isBeforeSuiteConfiguration()
        || m.isBeforeTestConfiguration();
    MethodInheritance.fixMethodInheritance(allMethodsArray, before);
  }

  topologicalSort(allMethodsArray, sl, pl);

  List<ITestNGMethod> result = Lists.newArrayList();
  result.addAll(sl);
  result.addAll(pl);
  return result;
}
 
Example 2
Source File: AllureTestNg.java    From allure-java with Apache License 2.0 5 votes vote down vote up
private void ifClassFixtureStarted(final ITestNGMethod testMethod) {
    if (testMethod.isBeforeClassConfiguration()) {
        getClassContainer(testMethod.getTestClass())
                .ifPresent(parentUuid -> startBefore(parentUuid, testMethod));
    }
    if (testMethod.isAfterClassConfiguration()) {
        getClassContainer(testMethod.getTestClass())
                .ifPresent(parentUuid -> startAfter(parentUuid, testMethod));
    }
}
 
Example 3
Source File: AllureTestNg.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("BooleanExpressionComplexity")
private boolean isSupportedConfigurationFixture(final ITestNGMethod testMethod) {
    return testMethod.isBeforeMethodConfiguration() || testMethod.isAfterMethodConfiguration()
            || testMethod.isBeforeTestConfiguration() || testMethod.isAfterTestConfiguration()
            || testMethod.isBeforeClassConfiguration() || testMethod.isAfterClassConfiguration()
            || testMethod.isBeforeSuiteConfiguration() || testMethod.isAfterSuiteConfiguration();
}
 
Example 4
Source File: VerboseReporter.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param method method to be described
 * @return FQN of a class + method declaration for a method passed in
 *      ie. test.triangle.CheckCount.testCheckCount(java.lang.String)
 */
private String getMethodDeclaration(ITestNGMethod method) {
    //see Utils.detailedMethodName
    //perhaps should rather adopt the original method instead
    ConstructorOrMethod m = method.getConstructorOrMethod();
    StringBuilder buf = new StringBuilder();
    buf.append("\"");
    if (suiteName != null) {
        buf.append(suiteName);
    } else {
        buf.append("UNKNOWN");
    }
    buf.append("\"");
    buf.append(" - ");
    if (method.isBeforeSuiteConfiguration()) {
        buf.append("@BeforeSuite ");
    } else if (method.isBeforeTestConfiguration()) {
        buf.append("@BeforeTest ");
    } else if (method.isBeforeClassConfiguration()) {
        buf.append("@BeforeClass ");
    } else if (method.isBeforeGroupsConfiguration()) {
        buf.append("@BeforeGroups ");
    } else if (method.isBeforeMethodConfiguration()) {
        buf.append("@BeforeMethod ");
    } else if (method.isAfterMethodConfiguration()) {
        buf.append("@AfterMethod ");
    } else if (method.isAfterGroupsConfiguration()) {
        buf.append("@AfterGroups ");
    } else if (method.isAfterClassConfiguration()) {
        buf.append("@AfterClass ");
    } else if (method.isAfterTestConfiguration()) {
        buf.append("@AfterTest ");
    } else if (method.isAfterSuiteConfiguration()) {
        buf.append("@AfterSuite ");
    }
    buf.append(m.getDeclaringClass().getName());
    buf.append(".");
    buf.append(m.getName());
    buf.append("(");
    int i = 0;
    for (Class<?> p : m.getParameterTypes()) {
        if (i++ > 0) {
            buf.append(", ");
        }
        buf.append(p.getName());
    }
    buf.append(")");
    return buf.toString();
}