Esempio n. 1
0
 private void initTestClassesAndInstances() {
   //
   // TestClasses and instances
   //
   Object[] instances = getInstances(false);
   for (Object instance : instances) {
     if (instance instanceof ITest) {
       testName = ((ITest) instance).getTestName();
       break;
     }
   }
   if (testName == null) {
     testName = iClass.getTestName();
   }
 }
Esempio n. 2
0
 private void init(
     IClass cls,
     ITestMethodFinder testMethodFinder,
     IAnnotationFinder annotationFinder,
     XmlTest xmlTest,
     XmlClass xmlClass) {
   log(3, "Creating TestClass for " + cls);
   iClass = cls;
   m_testClass = cls.getRealClass();
   this.xmlTest = xmlTest;
   this.xmlClass = xmlClass;
   this.testMethodFinder = testMethodFinder;
   this.annotationFinder = annotationFinder;
   initTestClassesAndInstances();
   initMethods();
 }
Esempio n. 3
0
  /**
   * Create the test methods that belong to this class (rejects all those that belong to a different
   * class).
   */
  private ITestNGMethod[] createTestMethods(ITestNGMethod[] methods) {
    List<ITestNGMethod> vResult = Lists.newArrayList();
    for (ITestNGMethod tm : methods) {
      ConstructorOrMethod m = tm.getConstructorOrMethod();
      if (m.getDeclaringClass().isAssignableFrom(m_testClass)) {
        for (Object o : iClass.getInstances(false)) {
          log(4, "Adding method " + tm + " on TestClass " + m_testClass);
          vResult.add(
              new TestNGMethod(
                  /* tm.getRealClass(), */ m.getMethod(), annotationFinder, xmlTest, o));
        }
      } else {
        log(4, "Rejecting method " + tm + " for TestClass " + m_testClass);
      }
    }

    return vResult.toArray(new ITestNGMethod[vResult.size()]);
  }
Esempio n. 4
0
 @Override
 public Object[] getInstances(boolean create) {
   return iClass.getInstances(create);
 }
Esempio n. 5
0
  private void initMethods() {
    ITestNGMethod[] methods = testMethodFinder.getTestMethods(m_testClass, xmlTest);
    m_testMethods = createTestMethods(methods);

    for (Object instance : iClass.getInstances(false)) {
      m_beforeSuiteMethods =
          ConfigurationMethod.createSuiteConfigurationMethods(
              testMethodFinder.getBeforeSuiteMethods(m_testClass),
              annotationFinder,
              true,
              instance);
      m_afterSuiteMethods =
          ConfigurationMethod.createSuiteConfigurationMethods(
              testMethodFinder.getAfterSuiteMethods(m_testClass),
              annotationFinder,
              false,
              instance);
      m_beforeTestConfMethods =
          ConfigurationMethod.createTestConfigurationMethods(
              testMethodFinder.getBeforeTestConfigurationMethods(m_testClass),
              annotationFinder,
              true,
              instance);
      m_afterTestConfMethods =
          ConfigurationMethod.createTestConfigurationMethods(
              testMethodFinder.getAfterTestConfigurationMethods(m_testClass),
              annotationFinder,
              false,
              instance);
      m_beforeClassMethods =
          ConfigurationMethod.createClassConfigurationMethods(
              testMethodFinder.getBeforeClassMethods(m_testClass),
              annotationFinder,
              true,
              instance);
      m_afterClassMethods =
          ConfigurationMethod.createClassConfigurationMethods(
              testMethodFinder.getAfterClassMethods(m_testClass),
              annotationFinder,
              false,
              instance);
      m_beforeGroupsMethods =
          ConfigurationMethod.createBeforeConfigurationMethods(
              testMethodFinder.getBeforeGroupsConfigurationMethods(m_testClass),
              annotationFinder,
              true,
              instance);
      m_afterGroupsMethods =
          ConfigurationMethod.createAfterConfigurationMethods(
              testMethodFinder.getAfterGroupsConfigurationMethods(m_testClass),
              annotationFinder,
              false,
              instance);
      m_beforeTestMethods =
          ConfigurationMethod.createTestMethodConfigurationMethods(
              testMethodFinder.getBeforeTestMethods(m_testClass), annotationFinder, true, instance);
      m_afterTestMethods =
          ConfigurationMethod.createTestMethodConfigurationMethods(
              testMethodFinder.getAfterTestMethods(m_testClass), annotationFinder, false, instance);
    }
  }
Esempio n. 6
0
 @Override
 public void addInstance(Object instance) {
   iClass.addInstance(instance);
 }
Esempio n. 7
0
 @Deprecated
 @Override
 public int getInstanceCount() {
   return iClass.getInstanceCount();
 }
Esempio n. 8
0
 @Override
 public long[] getInstanceHashCodes() {
   return iClass.getInstanceHashCodes();
 }