Examples of ITest


Examples of be.pw999.jape.tests.ITest

        //The actual tests
        for (Class<? extends ITest> clazz : classes) {
            log.info("Starting test class " + clazz.getSimpleName());
            try {
                ITest test = (ITest) (this.getClass().getClassLoader().loadClass(clazz.getName())).newInstance();
                log.trace("Initializing test class for first time (" + test.getClass().getSimpleName() + ")");
                test.init();

                //Each test-method inside a test-class
                Method[] methods = test.getClass().getMethods();
                for (Method method : methods) {
                    if (ReflectionUtils.getAnnotation(Test.class, method) != null) {
                        try {
                            int repeats = 1;
                            int size = Settings.TEST_LOOPS;
                            int leftOvers = 0;
                            long totalDuration = 0L;
                            boolean noGC = false;
                            if (ReflectionUtils.getAnnotation(NotInfinite.class, method) != null) {
                                size = ReflectionUtils.getAnnotation(NotInfinite.class, method).invocations();
                                repeats = Settings.TEST_LOOPS / size;
                                leftOvers = Settings.TEST_LOOPS % size;
                                noGC = ReflectionUtils.getAnnotation(NotInfinite.class, method).noGC();
                                log.trace("NotInfinite annotation found on " + test.getClass().getSimpleName() + "#" + method.getName() + ". {size=" + size + ",repeats=" + repeats + ",leftOvers=" + leftOvers + "}");
                            }
                            long start;
                            for (int i = 0; i < repeats; ++i) {
                                start = System.currentTimeMillis();
                                for (int j = 0; j < size; ++j) {
                                    method.invoke(test);
                                }
                                totalDuration += (System.currentTimeMillis() - start);
                                test.init();
                                if (!noGC) {
                                    GCManager.gc();
                                }
                            }
                            if (leftOvers != 0) {   //TODO: remove repeats
                                start = System.currentTimeMillis();
                                for (int j = 0; j < leftOvers; ++j) {
                                    method.invoke(test);
                                }
                                totalDuration += (System.currentTimeMillis() - start);
                            }

                            log.trace("Test finished (" + test.getClass().getSimpleName() + "#" + method.getName() + ")");
                            addResult(new Result(test.getClass(), method, totalDuration), test.getClass().getAnnotation(TestSuite.class));

                            if (ReflectionUtils.getAnnotation(DirtiesObject.class, method) != null) {
                                log.trace("DirtiesObject annotation found on " + test.getClass().getSimpleName() + "#" + method.getName() + ": reinitializing");
                                test.init();
                            }
                        } catch (InvocationTargetException e) {
                            log.error("Failed to invoke testmethod " + test.getClass().getSimpleName() + "#" + method.getName() + ": " + e.getMessage(), e);
                            addResult(new Result(test.getClass(), method, Long.MIN_VALUE), test.getClass().getAnnotation(TestSuite.class));
                        }
                    } else {
                        if (method.getName().startsWith("test")) {
                            log.warn("Method " + method.getName() + " skipped");
                        } else {
                            log.trace("Method " + method.getName() + " skipped");
                        }
                    }
                }

                //Test-class finished, clear resources and go to next test-class
                log.trace("Test finished");
                test.destroy();
                test = null;
                GCManager.forceGC();
            } catch (InitializationException e) {
                log.error("Failed to initialize test " + clazz.getSimpleName() + ": " + e.getMessage(), e);
            } catch (InstantiationException e) {
View Full Code Here

Examples of be.pw999.jape.tests.ITest

        int k = -1;
        //The actual tests
        for (Class<? extends ITest> clazz : classes) {
            log.info("Pre-Loading test class " + clazz.getSimpleName() + " iteration " + k);
            try {
                ITest test = (ITest) (this.getClass().getClassLoader().loadClass(clazz.getName())).newInstance();
                log.trace("Initializing test class for first time (" + test.getClass().getSimpleName() + ")");
                test.init();

                //Each test-method inside a test-class
                Method[] methods = test.getClass().getMethods();
                for (Method method : methods) {
                    if (ReflectionUtils.getAnnotation(Test.class, method) != null) {
                        try {
                            int repeats = 100;
                            int size = 10;
                            int leftOvers = 0;
                            long totalDuration = 0L;
                            boolean noGC = false;
                            if (ReflectionUtils.getAnnotation(NotInfinite.class, method) != null) {
                                size = 10;
                                repeats = 100;
                                leftOvers = 0;
                                noGC = ReflectionUtils.getAnnotation(NotInfinite.class, method).noGC();
                                log.trace("NotInfinite annotation found on " + test.getClass().getSimpleName() + "#" + method.getName() + ". {size=" + size + ",repeats=" + repeats + ",leftOvers=" + leftOvers + "}");
                            }
                            long start;
                            for (int i = 0; i < repeats; ++i) {
                                start = System.currentTimeMillis();
                                for (int j = 0; j < size; ++j) {
                                    method.invoke(test);
                                }
                                totalDuration += (System.currentTimeMillis() - start);
                                test.init();
                                if (!noGC) {
                                    GCManager.gc();
                                }
                            }
                            if (leftOvers != 0) {   //TODO: remove repeats
                                start = System.currentTimeMillis();
                                for (int j = 0; j < leftOvers; ++j) {
                                    method.invoke(test);
                                }
                                totalDuration += (System.currentTimeMillis() - start);
                            }

                            log.trace("Test finished (" + test.getClass().getSimpleName() + "#" + method.getName() + ")");

                            if (ReflectionUtils.getAnnotation(DirtiesObject.class, method) != null) {
                                log.trace("DirtiesObject annotation found on " + test.getClass().getSimpleName() + "#" + method.getName() + ": reinitializing");
                                test.init();
                            }
                        } catch (InvocationTargetException e) {
                            log.error("Failed to invoke testmethod " + test.getClass().getSimpleName() + "#" + method.getName() + ": " + e.getMessage(), e);
                        }
                    }
                }

                //Test-class finished, clear resources and go to next test-class
                log.trace("Test finished");
                test.destroy();
                test = null;
                GCManager.forceGC();
            } catch (InitializationException e) {
                log.error("Failed to initialize test " + clazz.getSimpleName() + ": " + e.getMessage(), e);
            } catch (InstantiationException e) {
View Full Code Here

Examples of org.testng.internal.annotations.ITest

    }

    // If this configuration method has inherit-groups=true, add the groups
    // defined in the @Test class
    if (inheritGroupsFromTestClass()) {
      ITest classAnnotation =
        (ITest) m_annotationFinder.findAnnotation(m_methodClass, ITest.class);
      if (classAnnotation != null) {
        String[] groups = classAnnotation.getGroups();
        Map<String, String> newGroups = new HashMap<String, String>();
        for (String g : getGroups()) {
          newGroups.put(g, g);
        }
        if (groups != null) {
View Full Code Here

Examples of org.testng.internal.annotations.ITest

    return result;
  }
 
  public static Method findDataProvider(Class clazz, Method m, IAnnotationFinder finder) {
    Method result = null;
    ITest annotation = AnnotationHelper.findTest(finder, m);
    if (null != annotation) {
      String dataProviderName = annotation.getDataProvider();
      if (null != dataProviderName && ! "".equals(dataProviderName)) {
        result = findDataProvider(clazz, finder, dataProviderName, annotation.getDataProviderClass());
      }
    }

    return result;
  }
View Full Code Here

Examples of org.testng.internal.annotations.ITest

    if (expectedExceptions != null) {
      result = expectedExceptions.getValue();
    }
    else {
      // New syntax
      ITest testAnnotation =
        (ITest) finder.findAnnotation(method, ITest.class);
      if (testAnnotation != null) {
        Class[] ee = testAnnotation.getExpectedExceptions();
        if (testAnnotation != null && ee.length > 0) {
          result = ee;
        }
      }
    }
View Full Code Here

Examples of org.testng.internal.annotations.ITest

  //
  // End of public methods
  // ///

  public static boolean isEnabled(Class objectClass, IAnnotationFinder finder) {
    ITest testClassAnnotation= AnnotationHelper.findTest(finder, objectClass);

    return isEnabled(testClassAnnotation);
  }
View Full Code Here

Examples of org.testng.internal.annotations.ITest

    return isEnabled(testClassAnnotation);
  }
 
  public static boolean isEnabled(Method m, IAnnotationFinder finder) {
    ITest annotation = AnnotationHelper.findTest(finder, m);
   
    // If no method annotation, look for one on the class
    if (null == annotation) {
      annotation = AnnotationHelper.findTest(finder, m.getDeclaringClass());
    }
View Full Code Here

Examples of org.testng.internal.annotations.ITest

    System.out.println("[TestNGMethod] " + s);
  }

  private void init() {
    {
      ITest testAnnotation = AnnotationHelper.findTest(getAnnotationFinder(), m_method);
     
      if (testAnnotation == null) {
        // Try on the class
        testAnnotation = AnnotationHelper.findTest(getAnnotationFinder(), m_method.getDeclaringClass());
      }

      if (null != testAnnotation) {
        m_timeOut = testAnnotation.getTimeOut();
      }

      if (null != testAnnotation) {
        m_successPercentage = testAnnotation.getSuccessPercentage();

        setInvocationCount(testAnnotation.getInvocationCount());
        setThreadPoolSize(testAnnotation.getThreadPoolSize());
      }

      // Groups
      {
        initGroups(ITest.class);
      }

      // Other annotations
      if (null != testAnnotation) {
        setAlwaysRun(testAnnotation.getAlwaysRun());
        setDescription(testAnnotation.getDescription());
      }
    }
  }
View Full Code Here

Examples of org.testng.internal.annotations.ITest

    Map<String, XmlSuite> suites = new HashMap<String, XmlSuite>();
    IAnnotationFinder finder = getAnnotationFinder();
   
    for (int i = 0; i < classes.length; i++) {
      Class c = classes[i];
      ITest test = (ITest) finder.findAnnotation(c, ITest.class);
      String suiteName = getDefaultSuiteName();
      String testName = getDefaultTestName();
      if (test != null) {
        final String candidateSuiteName = test.getSuiteName();
        if (candidateSuiteName != null && !"".equals(candidateSuiteName)) {
          suiteName = candidateSuiteName;
        }
        final String candidateTestName = test.getTestName();
        if (candidateTestName != null && !"".equals(candidateTestName)) {
          testName = candidateTestName;  
        }
      } 
      XmlSuite xmlSuite = suites.get(suiteName);
View Full Code Here

Examples of org.testng.internal.annotations.ITest

  public static String[] dependentGroupsForThisMethodForTest(Method m, IAnnotationFinder finder) {
    List<String> vResult = new ArrayList<String>();
    Class<?> cls = m.getDeclaringClass();

    // Collect groups on the class
    ITest tc = AnnotationHelper.findTest(finder, cls);
    if (null != tc) {
      for (String group : tc.getDependsOnGroups()) {
        vResult.add(group);
      }
    }

    // Collect groups on the method
    ITest tm = AnnotationHelper.findTest(finder, m);
    if (null != tm) {
      String[] groups = tm.getDependsOnGroups();

      //       ppp("Method:" + m + " #Groups:" + groups.length);
      for (String group : groups) {
        vResult.add(group);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.