All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedSuiteResultEvent Maven / Gradle / Ivy

The newest version!
package com.carrotsearch.ant.tasks.junit4.events.aggregated;

import java.util.Collections;
import java.util.List;

import org.junit.runner.Description;

import com.carrotsearch.ant.tasks.junit4.SlaveInfo;
import com.carrotsearch.ant.tasks.junit4.events.IEvent;
import com.carrotsearch.ant.tasks.junit4.events.mirrors.FailureMirror;

public class AggregatedSuiteResultEvent implements AggregatedResultEvent {
  private final SlaveInfo slave;
  private final Description description;
  private final List tests;
  private final List suiteFailures;
  private final List eventStream;
  private final long executionTime;
  private final long startTimestamp;

  public AggregatedSuiteResultEvent(SlaveInfo id, Description description, 
      List suiteFailures, List tests,
      List eventStream,
      long startTimestamp, long executionTime) {
    this.slave = id;
    this.tests = tests;
    this.suiteFailures = suiteFailures;
    this.description = description;
    this.eventStream = eventStream;
    this.executionTime = executionTime;
    this.startTimestamp = startTimestamp;
  }

  public List getTests() {
    return tests;
  }

  @Override
  public List getFailures() {
    return Collections.unmodifiableList(suiteFailures);
  }

  @Override
  public boolean isSuccessful() {
    if (!suiteFailures.isEmpty())
      return false;

    for (AggregatedTestResultEvent e : tests) {
      if (!e.isSuccessful()) {
        return false;
      }
    }

    return true;
  }

  @Override
  public List getEventStream() {
    return eventStream;
  }
  
  @Override
  public SlaveInfo getSlave() {
    return slave;
  }

  @Override
  public Description getDescription() {
    return description;
  }

  /**
   * Execution time in milliseconds.
   */
  public long getExecutionTime() {
    return executionTime;
  }

  /**
   * Execution start timestamp (on the slave).
   */
  public long getStartTimestamp() {
    return startTimestamp;
  }

  /**
   * The number of tests that have {@link TestStatus#FAILURE} and
   * include assertion violations at suite level.
   */
  public int getFailureCount() {
    int count = 0;
    for (AggregatedTestResultEvent t : getTests()) {
      if (t.getStatus() == TestStatus.FAILURE)
        count++;
    }
    for (FailureMirror m : getFailures()) {
      if (m.isAssertionViolation())
        count++;
    }
    return count;
  }
  
  /**
   * The number of tests that have {@link TestStatus#ERROR} and
   * include the suite-level errors.
   */
  public int getErrorCount() {
    int count = 0;
    for (AggregatedTestResultEvent t : getTests()) {
      if (t.getStatus() == TestStatus.ERROR)
        count++;
    }
    
    for (FailureMirror m : getFailures()) {
      if (m.isErrorViolation())
        count++;
    }
    return count;
  }

  /**
   * Return the number of ignored or assumption-ignored tests.
   */
  public int getIgnoredCount() {
    int count = 0;
    for (AggregatedTestResultEvent t : getTests()) {
      if (t.getStatus() == TestStatus.IGNORED ||
          t.getStatus() == TestStatus.IGNORED_ASSUMPTION) {
        count++;
      }
    }
    return count;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy