Examples of ITestClass


Examples of org.testng.ITestClass

    assert null != testMethod.getTestClass()
    : "COULDN'T FIND TESTCLASS FOR " + testMethod.getMethod().getDeclaringClass();
   
    List<ITestResult> result = new ArrayList<ITestResult>();
   
    ITestClass testClass= testMethod.getTestClass();
    Method method= testMethod.getMethod();
    long start= System.currentTimeMillis();

    //
    // TODO:
    // - [DONE] revisit invocationCount, threadPoolSize values
    // - try to remove the isWithinThreadedMethod: still needed to determine the @BeforeMethod + @AfterMethod
    // - [DONE] solve the results different approaches: assignment and addAll
    //
    // HINT: for invocationCount>1 and threadPoolSize>1 the method will be invoked on a thread pool
    int invocationCount = (testMethod.getThreadPoolSize() > 1 ? 1 : testMethod.getInvocationCount());
   
    int failureCount = 0;

    Class[] expectedExceptionClasses =
      MethodHelper.findExpectedExceptions(m_annotationFinder, testMethod.getMethod());
    while(invocationCount-- > 0) {
      boolean okToProceed = checkDependencies(testMethod, testClass, allTestMethods);

      if (okToProceed) {
        //
        // Invoke the test method if it's enabled
        //
        if (MethodHelper.isEnabled(testMethod.getMethod(), m_annotationFinder)) {
            //
            // HINT: If threadPoolSize specified, run this method in its own pool thread.
            //
            if (testMethod.getThreadPoolSize() > 1) {
              try {
                result = invokePooledTestMethods(testMethod, allTestMethods, suite,
                    parameters, groupMethods, testContext);
              }
              finally {
                failureCount = handleInvocationResults(testMethod, result, failureCount, expectedExceptionClasses, false);
              }
            }
           
            //
            // No threads, regular invocation
            //
            else {
              ITestNGMethod[] beforeMethods = filterMethods(testClass, testClass.getBeforeTestMethods());
              ITestNGMethod[] afterMethods = filterMethods(testClass, testClass.getAfterTestMethods());


              Map<String, String> allParameterNames = new HashMap<String, String>();
              Iterator<Object[]> allParameterValues =
                Parameters.handleParameters(testMethod, allParameterNames,
View Full Code Here

Examples of org.testng.ITestClass

                                                    Map<String, String> parameters,
                                                    ConfigurationGroupMethods groupMethods,
                                                    ITestContext testContext)
  {
    // HINT: invoke @BeforeGroups on the original method (reduce thread contention, and also solve thread confinement)
    ITestClass testClass= testMethod.getTestClass();
    Object[] instances = testClass.getInstances(true);
    for(Object instance: instances) {
      invokeBeforeGroupsConfigurations(testClass, testMethod, groupMethods, suite, parameters, instance);
    }
   
   
View Full Code Here

Examples of org.testng.ITestClass

   * Clones the current <code>TestNGMethod</code> and its @BeforeMethod and @AfterMethod methods.
   * @see org.testng.internal.BaseTestMethod#clone()
   */
  public TestNGMethod clone() {
    TestNGMethod clone= new TestNGMethod(getMethod(), getAnnotationFinder(), false);
    ITestClass tc= getTestClass();
    NoOpTestClass testClass= new NoOpTestClass(tc);
    testClass.setBeforeTestMethods(clone(tc.getBeforeTestMethods()));
    testClass.setAfterTestMethod(clone(tc.getAfterTestMethods()));
    clone.m_testClass= testClass;
    clone.setDate(getDate());
    clone.setGroups(getGroups());
    clone.setGroupsDependedUpon(getGroupsDependedUpon());
    clone.setMethodsDependedUpon(getMethodsDependedUpon());
View Full Code Here

Examples of org.testng.ITestClass

  /**
   * Add beforeMethod, method, afterMethod
   */
  private void addTestOperation(Operation o) {
    ITestNGMethod method = o.getMethod();
    ITestClass testClass = method.getTestClass();
    if (! m_classesSeen.contains(testClass)) {
      m_classesSeen.add(testClass);
      addMethods(testClass.getBeforeClassMethods(), o.getAffinity(),
          m_operations.size());
    }
   
    String[] groups = method.getGroups();
    for (String group : groups) {
      if (! m_groupsSeen.contains(group)) {
        List<ITestNGMethod> beforeMethods
          = m_groupMethods.getBeforeGroupsMap().get(group);
        if (beforeMethods != null) {
          ITestNGMethod[] beforeGroupMethods
            = beforeMethods.toArray(new ITestNGMethod[beforeMethods.size()]);
          addMethods(beforeGroupMethods,
              o.getAffinity(), m_operations.size());
          m_groupsSeen.add(group);
        }
      }
    }
   
    addMethods(testClass.getBeforeTestMethods(), o.getAffinity(),
        m_operations.size());
    m_operations.add(o);
    addMethods(testClass.getAfterTestMethods(), o.getAffinity(),
        m_operations.size());
  }
View Full Code Here

Examples of org.testng.ITestClass

    // Using an index here because we need to tell the invoker
    // the index of the current method
    for (int indexMethod = 0; indexMethod < m_testMethods.length; indexMethod++) {
      ITestNGMethod tm = m_testMethods[indexMethod].getMethod();
 
      ITestClass testClass = tm.getTestClass();

      invokeBeforeClassMethods(testClass, m_testMethods[indexMethod]);
     
      //
      // Invoke test method
View Full Code Here

Examples of org.testng.ITestClass

    assert null != testMethod.getTestClass()
    : "COULDN'T FIND TESTCLASS FOR " + testMethod.getMethod().getDeclaringClass();
   
    List<ITestResult> result = new ArrayList<ITestResult>();
   
    ITestClass testClass= testMethod.getTestClass();
    long start= System.currentTimeMillis();

    //
    // TODO:
    // - [DONE] revisit invocationCount, threadPoolSize values
    // - try to remove the isWithinThreadedMethod: still needed to determine the @BeforeMethod + @AfterMethod
    // - [DONE] solve the results different approaches: assignment and addAll
    //
    // For invocationCount>1 and threadPoolSize>1 the method will be invoked on a thread pool
    int invocationCount = (testMethod.getThreadPoolSize() > 1 ? 1 : testMethod.getInvocationCount());
   
    int failureCount = 0;

    Class<?>[] expectedExceptionClasses =
        MethodHelper.findExpectedExceptions(m_annotationFinder, testMethod.getMethod());
    while(invocationCount-- > 0) {
      boolean okToProceed = checkDependencies(testMethod, testClass, allTestMethods);

      if (okToProceed) {
        //
        // Invoke the test method if it's enabled
        //
        if (MethodHelper.isEnabled(testMethod.getMethod(), m_annotationFinder)) {
            //
            // If threadPoolSize specified, run this method in its own pool thread.
            //
            if (testMethod.getThreadPoolSize() > 1 && testMethod.getInvocationCount() > 1) {
                return invokePooledTestMethods(testMethod, allTestMethods, suite,
                    parameters, groupMethods, testContext);
            }
           
            //
            // No threads, regular invocation
            //
            else {
              ITestNGMethod[] beforeMethods = filterMethods(testClass, testClass.getBeforeTestMethods());
              ITestNGMethod[] afterMethods = filterMethods(testClass, testClass.getAfterTestMethods());


              Map<String, String> allParameterNames = new HashMap<String, String>();
              ParameterBag bag = createParameters(testClass, testMethod,
                  parameters, allParameterNames, suite, testContext, instances[0]);
View Full Code Here

Examples of org.testng.ITestClass

      ConfigurationGroupMethods groupMethods,
      XmlSuite suite,
      Map<String, String> parameters)
  {
    // HINT: invoke @BeforeGroups on the original method (reduce thread contention, and also solve thread confinement)
    ITestClass testClass= testMethod.getTestClass();
    Object[] instances = testClass.getInstances(true);
    for(Object instance: instances) {
      invokeBeforeGroupsConfigurations(testClass, testMethod, groupMethods, suite, parameters, instance);
    }
   
   
View Full Code Here

Examples of org.testng.ITestClass

      ITestNGMethod[] methods = sr.getTestContext().getAllTestMethods();
      methodCount += Utils.calculateInvokedMethodCount(methods);
       
      // Collect testClasses
      for (ITestNGMethod tm : methods) {
        ITestClass tc = tm.getTestClass();
        m_classes.put(tc.getRealClass().getName(), tc);
      }
    }
     
    String name = "Results for " + suite.getName();
    tableOfContents
        .append("<html>\n")
        .append("<head>\n")
        .append("<title>" + name + "</title>\n")
        .append(HtmlHelper.getCssString())
        .append("</head>\n")
        ;
    tableOfContents
        .append("<body>\n")
        .append("<h3><p align=\"center\">" + makeTitle(suite) + "</p></h3>\n")
        .append("<table border='1' width='100%'>\n")
        .append("<tr valign='top'>\n")
          .append("<td>")
            .append(suiteResults.size()).append(" ").append(pluralize(suiteResults.size(), "test"))
          .append("</td>\n")
          .append("<td>")
              .append("<a target='mainFrame' href='").append(CLASSES).append("'>")
              .append(m_classes.size() + " " + pluralize(m_classes.size(), "class"))
              .append("</a>")
          .append("</td>\n")
          .append("<td>" + methodCount + " " + pluralize(methodCount, "method") + ":<br/>\n")
            .append("&nbsp;&nbsp;<a target='mainFrame' href='").append(METHODS_CHRONOLOGICAL).append("'>").append("chronological</a><br/>\n")
            .append("&nbsp;&nbsp;<a target='mainFrame' href='").append(METHODS_ALPHABETICAL).append("\'>").append("alphabetical</a><br/>\n")
            .append("&nbsp;&nbsp;<a target='mainFrame' href='").append(METHODS_NOT_RUN).append("'>not run (" + suite.getExcludedMethods().size() + ")</a>")
          .append("</td>\n")
        .append("</tr>\n")

        .append("<tr>\n")
        .append("<td><a target='mainFrame' href='").append(GROUPS).append("'>").append(groupCount + pluralize(groupCount, " group") + "</a></td>\n")
        .append("<td><a target='mainFrame' href='").append(REPORTER_OUTPUT).append("'>reporter output</a></td>\n")
        .append("<td><a target='mainFrame' href='").append(TESTNG_XML).append("'>testng.xml</a></td>\n")
        .append("</tr>")
        .append("</table>");
     
      //
      // Generate results for individual tests
      //
     
      // Order the results so we can show the failures first, then the skip and
      // finally the successes
      Map<String, ISuiteResult> redResults = new HashMap<String, ISuiteResult>();
      Map<String, ISuiteResult> yellowResults = new HashMap<String, ISuiteResult>();
      Map<String, ISuiteResult> greenResults = new HashMap<String, ISuiteResult>();
     
      for (String suiteName : suiteResults.keySet()) {
        ISuiteResult sr = suiteResults.get(suiteName);
        ITestContext tc = sr.getTestContext();
        int failed = tc.getFailedTests().size();
        int skipped = tc.getSkippedTests().size();
        int passed = tc.getPassedTests().size();
       
        if (failed > 0) {
          redResults.put(suiteName, sr);
        }
        else if (skipped > 0) {
View Full Code Here

Examples of org.testng.ITestClass

   * Clones the current <code>TestNGMethod</code> and its @BeforeMethod and @AfterMethod methods.
   * @see org.testng.internal.BaseTestMethod#clone()
   */
  public TestNGMethod clone() {
    TestNGMethod clone= new TestNGMethod(getMethod(), getAnnotationFinder(), false);
    ITestClass tc= getTestClass();
    NoOpTestClass testClass= new NoOpTestClass(tc);
    testClass.setBeforeTestMethods(clone(tc.getBeforeTestMethods()));
    testClass.setAfterTestMethod(clone(tc.getAfterTestMethods()));
    clone.m_testClass= testClass;
    clone.setDate(getDate());
    clone.setGroups(getGroups());
    clone.setGroupsDependedUpon(getGroupsDependedUpon());
    clone.setMethodsDependedUpon(getMethodsDependedUpon());
View Full Code Here

Examples of org.testng.ITestClass

      ITestNGMethod[] methods = sr.getTestContext().getAllTestMethods();
      methodCount += Utils.calculateInvokedMethodCount(methods);
       
      // Collect testClasses
      for (ITestNGMethod tm : methods) {
        ITestClass tc = tm.getTestClass();
        m_classes.put(tc.getRealClass().getName(), tc);
      }
    }
     
    String name = "Results for " + suite.getName();
    tableOfContents
        .append("<html>\n")
        .append("<head>\n")
        .append("<title>" + name + "</title>\n")
        .append(HtmlHelper.getCssString())
        .append("</head>\n")
        ;
    tableOfContents
        .append("<body>\n")
        .append("<h3><p align=\"center\">" + makeTitle(suite) + "</p></h3>\n")
        .append("<table border='1' width='100%'>\n")
        .append("<tr valign='top'>\n")
          .append("<td>")
            .append(suiteResults.size()).append(" ").append(pluralize(suiteResults.size(), "test"))
          .append("</td>\n")
          .append("<td>")
              .append("<a target='mainFrame' href='").append(CLASSES).append("'>")
              .append(m_classes.size() + " " + pluralize(m_classes.size(), "class"))
              .append("</a>")
          .append("</td>\n")
          .append("<td>" + methodCount + " " + pluralize(methodCount, "method") + ":<br/>\n")
            .append("&nbsp;&nbsp;<a target='mainFrame' href='").append(METHODS_CHRONOLOGICAL).append("'>").append("chronological</a><br/>\n")
            .append("&nbsp;&nbsp;<a target='mainFrame' href='").append(METHODS_ALPHABETICAL).append("\'>").append("alphabetical</a><br/>\n")
            .append("&nbsp;&nbsp;<a target='mainFrame' href='").append(METHODS_NOT_RUN).append("'>not run (" + suite.getExcludedMethods().size() + ")</a>")
          .append("</td>\n")
        .append("</tr>\n")

        .append("<tr>\n")
        .append("<td><a target='mainFrame' href='").append(GROUPS).append("'>").append(groupCount + pluralize(groupCount, " group") + "</a></td>\n")
        .append("<td><a target='mainFrame' href='").append(REPORTER_OUTPUT).append("'>reporter output</a></td>\n")
        .append("<td><a target='mainFrame' href='").append(TESTNG_XML).append("'>testng.xml</a></td>\n")
        .append("</tr>")
        .append("</table>");
     
      //
      // Generate results for individual tests
      //
     
      // Order the results so we can show the failures first, then the skip and
      // finally the successes
      Map<String, ISuiteResult> redResults = new HashMap<String, ISuiteResult>();
      Map<String, ISuiteResult> yellowResults = new HashMap<String, ISuiteResult>();
      Map<String, ISuiteResult> greenResults = new HashMap<String, ISuiteResult>();
     
      for (String suiteName : suiteResults.keySet()) {
        ISuiteResult sr = suiteResults.get(suiteName);
        ITestContext tc = sr.getTestContext();
        int failed = tc.getFailedTests().size();
        int skipped = tc.getSkippedTests().size();
        int passed = tc.getPassedTests().size();
       
        if (failed > 0) {
          redResults.put(suiteName, sr);
        }
        else if (skipped > 0) {
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.