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

org.pantsbuild.tools.junit.impl.SpecSet Maven / Gradle / Ivy

Go to download

A command line tool for running junit tests that provides functionality above and beyond that provided by org.junit.runner.JUnitCore.

There is a newer version: 1.0.30
Show newest version
package org.pantsbuild.tools.junit.impl;

import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;

class SpecSet {
  private final Set specs;
  private final Concurrency defaultConcurrency;

  public SpecSet(Collection allSpecs, Concurrency defaultConcurrency) {
    this.specs = new LinkedHashSet(allSpecs);
    this.defaultConcurrency = defaultConcurrency;
  }

  /**
   * Remove and return all specs that match the specfied Concurrency parameter and have no
   * separate test methods defined.
   */
  public SpecSet extract(Concurrency concurrencyFilter) {
    Set results = new LinkedHashSet();
    for (Spec spec : specs) {
      if (spec.getMethods().isEmpty() &&
          spec.getConcurrency(defaultConcurrency).equals(concurrencyFilter)) {
        results.add(spec);
      }
    }
    specs.removeAll(results);
    return new SpecSet(results, defaultConcurrency);
  }

  public Set specs() {
    return ImmutableSet.copyOf(specs);
  }

  public  Class[] classes() {
    Class[] classes = new Class[specs.size()];
    int index = 0;
    for (Spec spec: specs) {
      classes[index++] = spec.getSpecClass();
    }
    return classes;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy