コード例 #1
0
 private void onTestFinished(ITestResult iTestResult, TestResult.ResultType resultType) {
   Object testId;
   TestStartEvent startEvent = null;
   synchronized (lock) {
     testId = tests.remove(iTestResult);
     if (testId == null) {
       // This can happen when a method fails which this method depends on
       testId = idGenerator.generateId();
       Object parentId = testMethodToSuiteMapping.get(iTestResult.getMethod());
       startEvent = new TestStartEvent(iTestResult.getStartMillis(), parentId);
     }
   }
   if (startEvent != null) {
     // Synthesize a start event
     resultProcessor.started(
         new DefaultTestMethodDescriptor(
             testId, iTestResult.getTestClass().getName(), iTestResult.getName()),
         startEvent);
   }
   if (resultType == TestResult.ResultType.FAILURE) {
     resultProcessor.failure(testId, iTestResult.getThrowable());
   }
   resultProcessor.completed(
       testId, new TestCompleteEvent(iTestResult.getEndMillis(), resultType));
 }
コード例 #2
0
 public void onConfigurationFailure(ITestResult testResult) {
   // Synthesise a test for the broken configuration method
   TestDescriptorInternal test =
       new DefaultTestMethodDescriptor(
           idGenerator.generateId(),
           testResult.getMethod().getTestClass().getName(),
           testResult.getMethod().getMethodName());
   resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis()));
   resultProcessor.failure(test.getId(), testResult.getThrowable());
   resultProcessor.completed(
       test.getId(),
       new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE));
 }
コード例 #3
0
 public void onConfigurationFailure(ITestResult testResult) {
   if (failedConfigurations.put(testResult, true) != null) {
     // workaround for bug in TestNG 6.2 (apparently fixed in some 6.3.x): listener is notified
     // twice per event
     return;
   }
   // Synthesise a test for the broken configuration method
   TestDescriptorInternal test =
       new DefaultTestMethodDescriptor(
           idGenerator.generateId(),
           testResult.getMethod().getTestClass().getName(),
           testResult.getMethod().getMethodName());
   resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis()));
   resultProcessor.failure(test.getId(), testResult.getThrowable());
   resultProcessor.completed(
       test.getId(),
       new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE));
 }
コード例 #4
0
 public void onFinish(ITestContext iTestContext) {
   Object id;
   synchronized (lock) {
     id = suites.remove(iTestContext.getName());
     for (ITestNGMethod method : iTestContext.getAllTestMethods()) {
       testMethodToSuiteMapping.remove(method);
     }
   }
   resultProcessor.completed(id, new TestCompleteEvent(iTestContext.getEndDate().getTime()));
 }
コード例 #5
0
 public void onStart(ITestContext iTestContext) {
   TestDescriptorInternal testInternal;
   synchronized (lock) {
     testInternal =
         new DefaultTestSuiteDescriptor(idGenerator.generateId(), iTestContext.getName());
     suites.put(testInternal.getName(), testInternal.getId());
     for (ITestNGMethod method : iTestContext.getAllTestMethods()) {
       testMethodToSuiteMapping.put(method, testInternal.getId());
     }
   }
   resultProcessor.started(
       testInternal, new TestStartEvent(iTestContext.getStartDate().getTime()));
 }
コード例 #6
0
  public void onTestStart(ITestResult iTestResult) {
    TestDescriptorInternal testInternal;
    Object parentId;
    synchronized (lock) {
      testInternal =
          new DefaultTestMethodDescriptor(
              idGenerator.generateId(),
              iTestResult.getTestClass().getName(),
              iTestResult.getName());
      Object oldTestId = tests.put(iTestResult, testInternal.getId());
      assert oldTestId == null
          : "Apparently some other test has started but it hasn't finished. "
              + "Expect the resultProcessor to break. "
              + "Don't expect to see this assertion stack trace due to the current architecture";

      parentId = testMethodToSuiteMapping.get(iTestResult.getMethod());
      assert parentId != null;
    }
    resultProcessor.started(
        testInternal, new TestStartEvent(iTestResult.getStartMillis(), parentId));
  }