Examples of ITestResult


Examples of org.apache.qpid.disttest.results.aggregation.ITestResult

        assertClientThreadsShutdown(client1Thread);
        assertClientsStopped(ClientState.STOPPED, client1);
        assertFalse("Test should have no errors", results.hasErrors());
        List<ITestResult> allTestResults = results.getTestResults();
        assertEquals("Unexpected number of test results", 1, allTestResults.size());
        ITestResult testResult1 = allTestResults.get(0);
        assertEquals("Unexpected test name", "Test 1", testResult1.getName());
        List<ParticipantResult> test1ParticipantResults = testResult1.getParticipantResults();
        assertEquals("Unexpected number of participant results for test 1", 1, test1ParticipantResults.size());
        assertParticipantNames(test1ParticipantResults, "participantProducer1");

        // check message properties
        for (int i=0; i< 10; i++)
View Full Code Here

Examples of org.apache.qpid.disttest.results.aggregation.ITestResult

    }

    public ParticipantResult getFirstParticipantResult(ResultsForAllTests results)
    {
        List<ITestResult> testResults = results.getTestResults();
        ITestResult testResult = testResults.iterator().next();
        List<ParticipantResult> participantResults = testResult.getParticipantResults();
        return participantResults.iterator().next();
    }
View Full Code Here

Examples of org.apache.qpid.disttest.results.aggregation.ITestResult

        assertClientThreadsShutdown(client1Thread);
        assertClientsStopped(ClientState.STOPPED, client1);
        assertFalse("Test should have no errors", results.hasErrors());
        List<ITestResult> allTestResults = results.getTestResults();
        assertEquals("Unexpected number of test results", 1, allTestResults.size());
        ITestResult testResult1 = allTestResults.get(0);
        assertEquals("Unexpected test name", "Test 1", testResult1.getName());
        List<ParticipantResult> test1ParticipantResults = testResult1.getParticipantResults();
        assertEquals("Unexpected number of participant results for test 1", 1, test1ParticipantResults.size());
        assertParticipantNames(test1ParticipantResults, "participantProducer1");

        // check message properties
        for (int i=0; i< 10; i++)
View Full Code Here

Examples of org.testng.ITestResult

    for(ITestNGMethod tm : methods) {
      if(null == testClass) {
        testClass= tm.getTestClass();
      }

      ITestResult testResult= new TestResult(testClass,
                                             instance,
                                             tm,
                                             null,
                                             System.currentTimeMillis(),
                                             System.currentTimeMillis());

      IConfiguration configurationAnnotation= null;
      try {
        Object[] instances= tm.getInstances();
        if (instances == null || instances.length == 0) instances = new Object[] { instance };
        Class objectClass= instances[0].getClass();
        Method method= tm.getMethod();

        // Only run the configuration if
        // - the test is enabled and
        // - the Configuration method belongs to the same class or a parent
        if(MethodHelper.isEnabled(objectClass, m_annotationFinder)) {
          configurationAnnotation= (IConfiguration) AnnotationHelper.findConfiguration(m_annotationFinder, method);

          boolean isClassConfiguration= isClassConfiguration(configurationAnnotation);
          boolean alwaysRun= isAlwaysRun(configurationAnnotation);

          if(!confInvocationPassed(tm) && !alwaysRun) {
            handleConfigurationSkip(tm, testResult);
            continue;
          }

          log(3, "Invoking " + Utils.detailedMethodName(tm, true));
         
          Object[] parameters= Parameters.createConfigurationParameters(tm.getMethod(),
                                                                        params,
                                                                        currentTestMethod,
                                                                        m_annotationFinder,
                                                                        suite);
          testResult.setParameters(parameters);

          Object[] newInstances= (null != instance) ? new Object[] { instance } : instances;

          invokeConfigurationMethod(newInstances, tm, parameters, isClassConfiguration, testResult);
         
          // TODO: probably we should trigger the event for each instance???
          testResult.setEndMillis(System.currentTimeMillis());
          runConfigurationListeners(testResult);
        } // if is enabled
        else {
          log(3,
              "Skipping "
View Full Code Here

Examples of org.testng.ITestResult

      } // okToProceed
      else {
        //
        // Test is being skipped
        //
        ITestResult testResult= new TestResult(testClass, null,
                                               testMethod,
                                               null,
                                               start,
                                               System.currentTimeMillis());
        testResult.setEndMillis(System.currentTimeMillis());
        String missingGroup = testMethod.getMissingGroup();
        if (missingGroup != null) {
          testResult.setThrowable(new Throwable("Method " + testMethod
              + " depends on nonexistent group \"" + missingGroup + "\""));
        }

        testResult.setStatus(ITestResult.SKIP);
        m_notifier.addSkippedTest(testMethod, testResult);
        runTestListeners(testResult);
      }
    }
   
View Full Code Here

Examples of org.testng.ITestResult

    for(ITestNGMethod tm : methods) {
      if(null == testClass) {
        testClass= tm.getTestClass();
      }

      ITestResult testResult= new TestResult(testClass,
                                             instance,
                                             tm,
                                             null,
                                             System.currentTimeMillis(),
                                             System.currentTimeMillis());

      IConfiguration configurationAnnotation= null;
      try {
        Object[] instances= tm.getInstances();
        if (instances == null || instances.length == 0) instances = new Object[] { instance };
        Class<?> objectClass= instances[0].getClass();
        Method method= tm.getMethod();

        // Only run the configuration if
        // - the test is enabled and
        // - the Configuration method belongs to the same class or a parent
        if(MethodHelper.isEnabled(objectClass, m_annotationFinder)) {
          configurationAnnotation= (IConfiguration) AnnotationHelper.findConfiguration(m_annotationFinder, method);

          boolean isClassConfiguration= isClassConfiguration(configurationAnnotation);
          boolean alwaysRun= isAlwaysRun(configurationAnnotation);

          if(!confInvocationPassed(tm) && !alwaysRun) {
            handleConfigurationSkip(tm, testResult);
            continue;
          }

          log(3, "Invoking " + Utils.detailedMethodName(tm, true));
         
          Object[] parameters= Parameters.createConfigurationParameters(tm.getMethod(),
                                                                        params,
                                                                        currentTestMethod,
                                                                        m_annotationFinder,
                                                                        suite,
                                                                        m_testContext);
          testResult.setParameters(parameters);

          Object[] newInstances= (null != instance) ? new Object[] { instance } : instances;

          invokeConfigurationMethod(newInstances, tm,
            parameters, isClassConfiguration, testResult);
         
          // TODO: probably we should trigger the event for each instance???
          testResult.setEndMillis(System.currentTimeMillis());
          runConfigurationListeners(testResult);
        } // if is enabled
        else {
          log(3,
              "Skipping "
View Full Code Here

Examples of org.testng.ITestResult

                    if (! m_skipFailedInvocationCounts) {
                      m_skipFailedInvocationCounts = testMethod.skipFailedInvocations();
                    }
                    if (failureCount > 0 && m_skipFailedInvocationCounts) {
                      while (invocationCount-- > 0) {
                        ITestResult r =
                          new TestResult(testMethod.getTestClass(),
                            instances[0],
                            testMethod,
                            null,
                            start,
                            System.currentTimeMillis());
                        r.setStatus(TestResult.SKIP);
                        result.add(r);
                        runTestListeners(r);
                        m_notifier.addSkippedTest(testMethod, r);
                      }
                      break;
                    }
                  }
                  parametersIndex++;
                }
              } // for parameters
            }

        } // isTestMethodEnabled

      } // okToProceed
      else {
        //
        // Test is being skipped
        //
        ITestResult testResult= new TestResult(testClass, null,
                                               testMethod,
                                               null,
                                               start,
                                               System.currentTimeMillis());
        testResult.setEndMillis(System.currentTimeMillis());
        String missingGroup = testMethod.getMissingGroup();
        if (missingGroup != null) {
          testResult.setThrowable(new Throwable("Method " + testMethod
              + " depends on nonexistent group \"" + missingGroup + "\""));
        }

        testResult.setStatus(ITestResult.SKIP);
        m_notifier.addSkippedTest(testMethod, testResult);
        runTestListeners(testResult);
      }
    }
   
View Full Code Here

Examples of org.testng.ITestResult

    // Go through all the results and create a TestResult for each of them
    //
    List<ITestResult> resultsToRetry = new ArrayList<ITestResult>();

    for (int i = 0; i < result.size(); i++) {
      ITestResult testResult = result.get(i);
      Throwable ite= testResult.getThrowable();
      int status= testResult.getStatus();

      // Exception thrown?
      if(ite != null) {

        //  Invocation caused an exception, see if the method was annotated with @ExpectedException
        if(isExpectedException(ite, expectedExceptionClasses)) {
          testResult.setStatus(ITestResult.SUCCESS);
          status= ITestResult.SUCCESS;
        }
        else if (SkipException.class.isAssignableFrom(ite.getClass())){
          SkipException skipEx= (SkipException) ite;
          if(skipEx.isSkip()) {
            status= ITestResult.SKIP;
          }
          else {
            handleException(ite, testMethod, testResult, failureCount++);
            status= ITestResult.FAILURE;
          }
        }
        else {
          handleException(ite, testMethod, testResult, failureCount++);
          status= testResult.getStatus();
        }
      }

      // No exception thrown, make sure we weren't expecting one
      else if(status != ITestResult.SKIP) {
        if (expectedExceptionClasses.length > 0) {
          testResult.setThrowable(
              new TestException("Expected an exception in test method " + testMethod));
          status= ITestResult.FAILURE;
        }
      }

      testResult.setStatus(status);

      boolean retry = false;
     
      if (testResult.getStatus() == ITestResult.FAILURE) {
        IRetryAnalyzer retryAnalyzer = testMethod.getRetryAnalyzer();

        if (retryAnalyzer != null) {
          retry = retryAnalyzer.retry(testResult);
        }

        if (retry) {
          resultsToRetry.add(testResult);
          if (failedInstances != null) {
            failedInstances.add(testResult.getMethod().getInstances()[i]);
          }
        }
      }
      if (!retry) {
        // Collect the results
View Full Code Here

Examples of org.testng.ITestResult

  private void logResults() {
    //
    // Log Text
    //
    for(Object o : getConfigurationFailures()) {
      ITestResult tr = (ITestResult) o;
      Throwable ex = tr.getThrowable();
      String stackTrace= "";
      if (ex != null) {
        if (m_verbose >= 2) {
          stackTrace= Utils.stackTrace(ex, false)[0];
        }
      }

      logResult("FAILED CONFIGURATION",
          Utils.detailedMethodName(tr.getMethod(), false),
          tr.getMethod().getDescription(),
          stackTrace,
          tr.getParameters(),
          tr.getMethod().getMethod().getParameterTypes()
      );
    }

    for(Object o : getConfigurationSkips()) {
      ITestResult tr = (ITestResult) o;
      logResult("SKIPPED CONFIGURATION",
          Utils.detailedMethodName(tr.getMethod(), false),
          tr.getMethod().getDescription(),
          null,
          tr.getParameters(),
          tr.getMethod().getMethod().getParameterTypes()
      );
    }
   
    for(Object o : getPassedTests()) {
      ITestResult tr = (ITestResult) o;
      logResult("PASSED", tr.getName(), tr.getMethod().getDescription(), null, tr.getParameters(), tr.getMethod().getMethod().getParameterTypes());
    }

    for(Object o : getFailedTests()) {
      ITestResult tr = (ITestResult) o;
      Throwable ex = tr.getThrowable();
      String stackTrace= "";
      if (ex != null) {
        if (m_verbose >= 2) {
          stackTrace= Utils.stackTrace(ex, false)[0];
        }
      }

      logResult("FAILED", tr.getName(), tr.getMethod().getDescription(), stackTrace, tr.getParameters(), tr.getMethod().getMethod().getParameterTypes());
    }

    for(Object o : getSkippedTests()) {
      ITestResult tr = (ITestResult) o;
      logResult("SKIPPED", tr.getName(), tr.getMethod().getDescription(), null, tr.getParameters(), tr.getMethod().getMethod().getParameterTypes());
    }

    ITestNGMethod[] ft = resultsToMethods(getFailedTests());
    StringBuffer logBuf= new StringBuffer("\n===============================================\n");
    logBuf.append("    ").append(m_testName).append("\n");
View Full Code Here

Examples of org.testng.ITestResult

    PerPackageCoverageListener listener = new PerPackageCoverageListener();

    void simulateTest(Class<?> fauxTestClass) {
        IClass mockClass = EasyMock.createMock(IClass.class);
        ITestResult mockResult = EasyMock.createMock(ITestResult.class);
        EasyMock.expect(mockResult.getTestClass()).andReturn(mockClass);
        EasyMock.expect(mockClass.getRealClass()).andReturn(fauxTestClass);
        EasyMock.replay(mockResult, mockClass);
        listener.onTestStart(mockResult);
    }
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.