pax_global_header00006660000000000000000000000064121634026520014513gustar00rootroot0000000000000052 comment=17a94641942546e21f4c6b300a3360be2d2888f6 test-interface-1.0/000077500000000000000000000000001216340265200142705ustar00rootroot00000000000000test-interface-1.0/.gitattributes000066400000000000000000000003401216340265200171600ustar00rootroot00000000000000# Set default behaviour, in case users don't have core.autocrlf set. * text=auto # Explicitly declare text files we want to always be normalized and converted # to native line endings on checkout. *.scala text *.java text test-interface-1.0/LICENSE000066400000000000000000000026021216340265200152750ustar00rootroot00000000000000Copyright (c) 2009, 2010 Josh Cough, Mark Harrah All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. test-interface-1.0/README000066400000000000000000000004001216340265200151420ustar00rootroot00000000000000To build, run 'sbt package' For test framework authors, the interfaces to implement are: * Framework * Runner2 * Fingerprint (one of SubclassFingerprint or AnnotatedFingerprint) For test framework clients, Logger and EventHandler must be implemented. test-interface-1.0/build.sbt000066400000000000000000000033521216340265200161040ustar00rootroot00000000000000name := "test-interface" organization := "org.scala-sbt" version := "1.0" description := "Uniform test interface to Scala/Java test frameworks (specs, ScalaCheck, ScalaTest, JUnit and other)" scalaVersion := "2.10.2" // disable using the Scala version in output paths and artifacts crossPaths := false autoScalaLibrary := false resolvers ++= Seq("releases" at "http://oss.sonatype.org/content/repositories/releases", "snapshots" at "http://oss.sonatype.org/content/repositories/snapshots", "localmaven" at "file://"+Path.userHome+"/.m2/repository") publishTo <<= version { v: String => val nexus = "https://oss.sonatype.org/" if (v.trim.endsWith("SNAPSHOT")) Some("publish-snapshots" at nexus + "content/repositories/snapshots") else Some("publish-releases" at nexus + "service/local/staging/deploy/maven2") } libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0.M6-SNAP24" % "test" publishMavenStyle := true publishArtifact in Test := false pomIncludeRepository := { _ => false } pomExtra := ( http://www.scala-sbt.org BSD https://github.com/sbt/test-interface/blob/master/LICENSE repo https://github.com/sbt/test-interface harrah Mark Harrah josh Josh Cough bill Bill Venners cheeseng Chua Chee Seng ) test-interface-1.0/project/000077500000000000000000000000001216340265200157365ustar00rootroot00000000000000test-interface-1.0/project/build.properties000066400000000000000000000000231216340265200211460ustar00rootroot00000000000000sbt.version=0.12.4 test-interface-1.0/project/plugins.sbt000066400000000000000000000000641216340265200201310ustar00rootroot00000000000000addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8")test-interface-1.0/src/000077500000000000000000000000001216340265200150575ustar00rootroot00000000000000test-interface-1.0/src/main/000077500000000000000000000000001216340265200160035ustar00rootroot00000000000000test-interface-1.0/src/main/java/000077500000000000000000000000001216340265200167245ustar00rootroot00000000000000test-interface-1.0/src/main/java/org/000077500000000000000000000000001216340265200175135ustar00rootroot00000000000000test-interface-1.0/src/main/java/org/scalatools/000077500000000000000000000000001216340265200216575ustar00rootroot00000000000000test-interface-1.0/src/main/java/org/scalatools/testing/000077500000000000000000000000001216340265200233345ustar00rootroot00000000000000test-interface-1.0/src/main/java/org/scalatools/testing/AnnotatedFingerprint.java000066400000000000000000000005311216340265200303230ustar00rootroot00000000000000package org.scalatools.testing; /** Identifies a test by a class or its methods having a specific annotation. */ public interface AnnotatedFingerprint extends Fingerprint { /** Whether a test is a module or a class*/ public boolean isModule(); /** The name of the annotation that identifies it as a test.*/ public String annotationName(); }test-interface-1.0/src/main/java/org/scalatools/testing/Event.java000066400000000000000000000002351216340265200252600ustar00rootroot00000000000000package org.scalatools.testing; public interface Event { String testName(); String description(); Result result(); Throwable error(); } test-interface-1.0/src/main/java/org/scalatools/testing/EventHandler.java000066400000000000000000000001551216340265200265570ustar00rootroot00000000000000package org.scalatools.testing; public interface EventHandler { public void handle(Event testEvent); } test-interface-1.0/src/main/java/org/scalatools/testing/Fingerprint.java000066400000000000000000000001411216340265200264620ustar00rootroot00000000000000package org.scalatools.testing; /** A way to identify a test. */ public interface Fingerprint {}test-interface-1.0/src/main/java/org/scalatools/testing/Framework.java000066400000000000000000000010011216340265200261240ustar00rootroot00000000000000package org.scalatools.testing; public interface Framework { /** The name of the test framework that this object represents. It is intended to be a human readable label.*/ public String name(); /** Specifies how to identify classes that are tests.*/ public Fingerprint[] tests(); /** Provide a runner for tests that will load test classes from 'testClassLoader' and direct all * logging output from the framework to 'loggers'.*/ public Runner testRunner(ClassLoader testClassLoader, Logger[] loggers); }test-interface-1.0/src/main/java/org/scalatools/testing/Logger.java000066400000000000000000000010201216340265200254070ustar00rootroot00000000000000package org.scalatools.testing; /** A basic interface to provide feedback. Note that the logging methods are not call-by-name as * a Scala interface would be. We could define a Function0 interface if we find that this is a problem.*/ public interface Logger { /** True if ANSI color codes are understood by this instance.*/ public boolean ansiCodesSupported(); public void error(String msg); public void warn(String msg); public void info(String msg); public void debug(String msg); public void trace(Throwable t); }test-interface-1.0/src/main/java/org/scalatools/testing/Result.java000066400000000000000000000001311216340265200254500ustar00rootroot00000000000000package org.scalatools.testing; public enum Result { Success, Error, Failure, Skipped }test-interface-1.0/src/main/java/org/scalatools/testing/Runner.java000066400000000000000000000013341216340265200254510ustar00rootroot00000000000000package org.scalatools.testing; public interface Runner { /** Runs the test suite with class name 'testClassName' and returns the results of executing each test * contained in the suite. This Runner should run the suite in the calling (current) thread. * * 'fingerprint' indicates how the test suite was identified as a test suite. This method may be called with the * same value for 'testClassName' but different fingerprints. For example, if both a class and its companion object * were tests, this method would be called with the same name but with a different value for 'fingerprint.isModule'. */ public abstract void run(String testClassName, TestFingerprint fingerprint, EventHandler eventHandler, String[] args); }test-interface-1.0/src/main/java/org/scalatools/testing/Runner2.java000066400000000000000000000017551216340265200255420ustar00rootroot00000000000000package org.scalatools.testing; /** New Runner that can handle more types of Fingerprints.*/ public abstract class Runner2 implements Runner { /** Runs the test suite with class name 'testClassName' and returns the results of executing each test * contained in the suite. This Runner should run the suite in the calling (current) thread. * * 'fingerprint' indicates how the test suite was identified as a test suite. This method may be called with the * same value for 'testClassName' but different fingerprints. For example, if both a class and its companion object * were tests, this method would be called with the same name but with a different value for 'fingerprint.isModule'. */ public abstract void run(String testClassName, Fingerprint fingerprint, EventHandler eventHandler, String [] args); public final void run(String testClassName, TestFingerprint fingerprint, EventHandler eventHandler, String[] args) { run(testClassName, (Fingerprint)fingerprint, eventHandler, args); } }test-interface-1.0/src/main/java/org/scalatools/testing/SubclassFingerprint.java000066400000000000000000000005101216340265200301620ustar00rootroot00000000000000package org.scalatools.testing; /** Identifies a test as a class that has a specific type as an ancestor. */ public interface SubclassFingerprint extends Fingerprint { /** Whether a test is a module or a class*/ public boolean isModule(); /** The name of the type that designates a test.*/ public String superClassName(); }test-interface-1.0/src/main/java/org/scalatools/testing/TestFingerprint.java000066400000000000000000000002661216340265200273320ustar00rootroot00000000000000package org.scalatools.testing; /** For backwards compatibility. New code should use SubclassFingerprint instead. */ public interface TestFingerprint extends SubclassFingerprint {}test-interface-1.0/src/main/java/sbt/000077500000000000000000000000001216340265200175145ustar00rootroot00000000000000test-interface-1.0/src/main/java/sbt/testing/000077500000000000000000000000001216340265200211715ustar00rootroot00000000000000test-interface-1.0/src/main/java/sbt/testing/AnnotatedFingerprint.java000066400000000000000000000015741216340265200261700ustar00rootroot00000000000000package sbt.testing; /** * Indicates that classes or modules with a specific annotation, either on at least one top level * method or on the class or module itself, should be discovered as test classes. */ public interface AnnotatedFingerprint extends Fingerprint { /** * Indicates whether modules with the annotation should * be considered during discovery, or just classes. * *

* If a test framework allows both classes and modules, they should return two different * fingerprints from Framework.fingerprints, one that returns false for * isModule and another that returns true. *

*/ public boolean isModule(); /** * The fully qualified name of the annotation that identifies classes or modules as test * classes or modules to be discovered. */ public String annotationName(); } test-interface-1.0/src/main/java/sbt/testing/Event.java000066400000000000000000000024431216340265200231200ustar00rootroot00000000000000package sbt.testing; /** * An event fired by the test framework during a run. */ public interface Event { /** * The fully qualified name of a class that can rerun the suite or test * about which an event was fired. */ String fullyQualifiedName(); /** * The fingerprint of the test class whose fully qualifed name is returned by the fullyQualifiedName * method on this Event. If the isModule method of the fingerprint indicates that the * fullyQualifiedName refers to a module (singleton object), the * fullyQualifiedName string does not include the trailing dollar sign. */ Fingerprint fingerprint(); /** * Additional information identifying the suite or test about which an event was fired. */ Selector selector(); /** * Indicates whether the event represents a test success, failure, error, skipped, ignored, canceled, pending. */ Status status(); /** * An OptionalThrowable associated with this Event. */ OptionalThrowable throwable(); /** * An amount of time, in milliseconds, that was required to complete the action reported by this event, or -1, if no duration was available. */ long duration(); } test-interface-1.0/src/main/java/sbt/testing/EventHandler.java000066400000000000000000000006611216340265200244160ustar00rootroot00000000000000package sbt.testing; /** * Interface implemented by clients that handle events fired by the test framework * during a run. * *

* An event handler is passed to the test framework via the execute method * of Tasks. *

*/ public interface EventHandler { /** * Handle an event. * * @param event the event to handle */ public void handle(Event event); } test-interface-1.0/src/main/java/sbt/testing/Fingerprint.java000066400000000000000000000002601216340265200243210ustar00rootroot00000000000000package sbt.testing; /** * A way to identify test classes and/or modules that should * be discovered when the client performs discovery. */ public interface Fingerprint {} test-interface-1.0/src/main/java/sbt/testing/Framework.java000066400000000000000000000024311216340265200237710ustar00rootroot00000000000000package sbt.testing; /** * Interface implemented by test frameworks. */ public interface Framework { /** * A human-friendly name of the test framework that this object represents. */ public String name(); /** * An array of Fingerprints that specify how to identify test classes during * discovery. */ public Fingerprint[] fingerprints(); /** * Initiates a run. * *

* If a client invokes this method before a previously initiated run has completed, * the test framework may throw IllegalStateExceptionto indicate it * cannot perform the two runs concurrently. *

* * @param args the test-framework-specific arguments for the new run * @param remoteArgs the test-framework-specific remote arguments for the run in a forked JVM * @param testClassLoader a class loader to use when loading test classes during the run * * @return a Runner representing the newly started run. * @throws IllegalStateException if the test framework is unable to initiate a run because it is * already performing a previously initiated run that has not yet completed. */ public Runner runner(String[] args, String[] remoteArgs, ClassLoader testClassLoader); } test-interface-1.0/src/main/java/sbt/testing/Logger.java000066400000000000000000000023031216340265200232510ustar00rootroot00000000000000package sbt.testing; /** * A logger through which to provide feedback to the user about a run. * *

* The difference between the event handler and the logger is that the event handler is * for events intended to be consumed by the client software whereas the logger is * for messages intended to be consumed by the client *user* (i.e., a human). *

* *

* Implementations of this interface must be thread-safe. *

*/ public interface Logger { /** * True if ANSI color codes are understood by this instance. */ public boolean ansiCodesSupported(); /** * Provide an error message. * * @param msg the error message */ public void error(String msg); /** * Provide an warning message. * * @param msg the warning message */ public void warn(String msg); /** * Provide an info message. * * @param msg the info message */ public void info(String msg); /** * Provide a debug message. * * @param msg the debug message */ public void debug(String msg); /** * Provide a stack trace * * @param t the Throwable containing the stack trace being logged */ public void trace(Throwable t); } test-interface-1.0/src/main/java/sbt/testing/NestedSuiteSelector.java000066400000000000000000000023351216340265200257740ustar00rootroot00000000000000package sbt.testing; import java.io.Serializable; /** * Information in addition to a test class name that identifies a nested suite about which an * event was fired. */ public final class NestedSuiteSelector extends Selector implements Serializable { private String _suiteId; /** * Constructs a new NestedSuiteSelector with given suiteId. * * @param suiteId the id of the nested suite */ public NestedSuiteSelector(String suiteId) { if (suiteId == null) { throw new NullPointerException("suiteId was null"); } _suiteId = suiteId; } /** * An id that, in addition to a test class name, identifies a nested suite about which an * event was fired. * * @return the id of the nested suite */ public String suiteId() { return _suiteId; } @Override public boolean equals(Object o) { boolean retVal = false; if (o instanceof NestedSuiteSelector) { NestedSuiteSelector nss = (NestedSuiteSelector) o; retVal = nss._suiteId == _suiteId; } return retVal; } @Override public int hashCode() { return _suiteId.hashCode(); } @Override public String toString() { return "NestedSuiteSelector(" + _suiteId + ")"; } } test-interface-1.0/src/main/java/sbt/testing/NestedTestSelector.java000066400000000000000000000036751216340265200256320ustar00rootroot00000000000000package sbt.testing; import java.io.Serializable; /** * Information in addition to a test class name that identifies a test in a nested suite about which an * event was fired. */ public final class NestedTestSelector extends Selector implements Serializable { private String _suiteId; private String _testName; /** * Constructs a new NestedSuiteSelector with given suiteId and testName. * * @param suiteId the id of the nested suite containing the test * @param testName the name of the test */ public NestedTestSelector(String suiteId, String testName) { if (suiteId == null) { throw new NullPointerException("suiteId was null"); } if (testName == null) { throw new NullPointerException("testName was null"); } _suiteId = suiteId; _testName = testName; } /** * An id that, in addition to a test class name, identifies a nested suite that contains a test * about which an event was fired. * * @return the id of the nested suite containing the test */ public String suiteId() { return _suiteId; } /** * The name of the test in a nested suite about which an event was fired. * * @return the name of the test in the nested suite identified by the id returned by suiteId. */ public String testName() { return _testName; } @Override public boolean equals(Object o) { boolean retVal = false; if (o instanceof NestedTestSelector) { NestedTestSelector nts = (NestedTestSelector) o; retVal = nts._suiteId.equals(_suiteId) && nts._testName.equals(_testName); } return retVal; } @Override public int hashCode() { int retVal = 17; retVal = 31 * retVal + _suiteId.hashCode(); retVal = 31 * retVal + _testName.hashCode(); return retVal; } @Override public String toString() { return "NestedTestSelector(" + _suiteId + ", " + _testName + ")"; } } test-interface-1.0/src/main/java/sbt/testing/OptionalThrowable.java000066400000000000000000000046541216340265200255020ustar00rootroot00000000000000package sbt.testing; import java.io.Serializable; /** * An optional Throwable. */ public final class OptionalThrowable implements Serializable { private Throwable exception; /** * Constructs an OptionalThrowable containing a Throwable. */ public OptionalThrowable(Throwable exception) { if (exception == null) { throw new NullPointerException("Cannot pass a null exception to OptionalThrowable's constructor."); } this.exception = exception; } /** * Constructs an OptionalThrowable containing no Throwable. */ public OptionalThrowable() { } /** * Indicates whether this OptionalThrowable is "defined," i.e., contains a Throwable. * * @return true if this OptionalThrowable contains a Throwable */ public boolean isDefined() { return exception != null; } /** * Indicates whether this OptionalThrowable is "empty," i.e., contains no Throwable. * * @return true if this OptionalThrowable contains no Throwable */ public boolean isEmpty() { return exception == null; } /** * Returns the Throwable contained in this OptionalThrowable if defined, else throws IllegalStateException. * *

* To avoid the IllegalStateException, ensure isDefined returns true before calling this method. *

* * @return the contained Throwable, if this OptionalThrowable is defined * @throws IllegalStateException if this OptionalThrowable is not defined. */ public Throwable get() { if (exception == null) { throw new IllegalStateException("This OptionalThrowable is not defined"); } return exception; } @Override public boolean equals(Object o) { boolean retVal = false; if (o instanceof OptionalThrowable) { OptionalThrowable ot = (OptionalThrowable) o; retVal = ot.exception == exception; } return retVal; } @Override public int hashCode() { return (exception == null) ? 0 : exception.hashCode(); } @Override public String toString() { String retVal = "OptionalThrowable()"; if (exception != null) { retVal = "OptionalThrowable(" + exception + ")"; } return retVal; } } test-interface-1.0/src/main/java/sbt/testing/Runner.java000066400000000000000000000111041216340265200233020ustar00rootroot00000000000000package sbt.testing; /** * Represents one run of a suite of tests. * *

* The run represented by a Runner has a lifecycle. The run begins when the * Runner is instantiated by the framework and returned to the client during * a Framework.runner invocation. The run continues until the client * invokes done on the Runner. Before invoking done, * the client can invoke the tasks method as many times at it wants, but once * done has been invoked, the Runner enters "spent" mode. Any * subsequent invocations of tasks will be met with an * IllegalStateException. *

*/ public interface Runner { /** * Returns an array of tasks that when executed will run tests and suites determined by the * passed TaskDefs. * *

* Each returned task, when executed, will run tests and suites determined by the * test class name, fingerprints, "explicitly specified" field, and selectors of one of the passed TaskDefs. *

* *

* This tasks method may be called with TaskDefs containing the same value for testClassName but * different fingerprints. For example, if both a class and its companion object were test classes, the tasks method could be * passed an array containing TaskDefs with the same name but with a different value for fingerprint.isModule. *

* *

* A test framework may "reject" a requested task by returning no Task for that TaskDef. *

* * @param taskDefs the TaskDefs for requested tasks * @return an array of Tasks * @throws IllegalStateException if invoked after done has been invoked. */ public Task[] tasks(TaskDef[] taskDefs); /** * Indicates the client is done with this Runner instance. * *

* After invoking the done method on a Runner instance, the client should no * longer invoke the task methods on that instance. (If the client does invoke task * after done, it will be rewarded with an IllegalStateException.) *

* *

* Similarly, after returning from done, the test framework should no longer write * any messages to the Logger, nor fire any more events to the EventHandler, * passed to Framework.runner. If the test framework has not completed writing log messages * or firing events when the client invokes done, the framework should not return from * done until it is finished sending messages and events, and may block the thread * that invoked done until it is actually done. *

* *

* In short, by invoking done, the client indicates it is done invoking the task * methods for this run. By returning from done, the test framework indicates it is done writing * log messages and firing events for this run. *

* *

* If the client invokes done more than once on the same Runner instance, the test * framework should on subsequent invocations should throw IllegalStateException. *

* *

* The test framework may send a summary (i.e., a message giving total tests succeeded, failed, and * so on) to the user via a log message. If so, it should return the summary from done. * If not, it should return an empty string. The client may use the return value of done * to decide whether to display its own summary message. *

* *

* The test framework may return a multi-lines string (i.e., a message giving total tests succeeded, failed and * so on) to the client. *

* * @return a possibly multi-line summary string, or the enpty string if no summary is provided */ public String done(); /** * Remote args that will be passed to Runner in a sub-process as remoteArgs. * * @return an array of strings that will be passed to Runner in a sub-process as remoteArgs. */ public String[] remoteArgs(); /** * Returns thge arguments that were used to create this Runner. * * @return an array of argument that is used to create this Runner. */ public String[] args(); } test-interface-1.0/src/main/java/sbt/testing/Selector.java000066400000000000000000000024211216340265200236130ustar00rootroot00000000000000package sbt.testing; /** * Information in addition to a test class name that identifies the suite or test about which an * event was fired. * *

* This class has five subtypes: *

* * */ abstract public class Selector {} test-interface-1.0/src/main/java/sbt/testing/Status.java000066400000000000000000000036541216340265200233270ustar00rootroot00000000000000package sbt.testing; /** * Represents the status of running a test. Test frameworks can decided which of these to * use and what they mean, but in general, the intended meanings are: * * * *

* The difference between errors and failures, if any, is determined by the test frameworks. * JUnit and specs2 differentiate between errors and failures. ScalaTest reports everything (both assertion failures and unexpected errors) as failures. * JUnit and ScalaTest support ignored tests. ScalaTest and specs2 support a notion of pending tests. ScalaTest differentiates between ignored and * canceled tests, whereas specs2 only supports skipped tests, which are implemented like ScalaTest's canceled tests. TestNG uses "skipped" to report tests * that were not executed because of failures in dependencies, which is also similar to canceled tests in ScalaTest. *

*/ public enum Status { /** * Indicates a test succeeded. */ Success, /** * Indicates an "error" occurred. */ Error, /** * Indicates a "failure" occurred. */ Failure, /** * Indicates a test was skipped. */ Skipped, /** * Indicates a test was ignored. */ Ignored, /** * Indicates a test was canceled. */ Canceled, /** * Indicates a test was declared as pending. */ Pending } test-interface-1.0/src/main/java/sbt/testing/SubclassFingerprint.java000066400000000000000000000024021216340265200260210ustar00rootroot00000000000000package sbt.testing; /** * Indicates that classes (and possibly modules) that extend a particular superclass, * or mix in a particular supertrait, should be discovered as test classes. */ public interface SubclassFingerprint extends Fingerprint { /** * Indicates whether modules (singleton objects) that extend the superclass or * supertrait should be considered during discovery, or just classes. * *

* If modules are not allowed by the test framework, they should return false for * isModule. Returning false will speed up discovery because * classes for modules can be quickly bypassed. *

*/ public boolean isModule(); /** * The name of the superclass or supertrait that identifies classes (and possibly modules) as test * classes to be discovered. */ public String superclassName(); /** * Indicates whether discovered classes must have a no-arg constructor. * *

* If this method returns true, the client should not discover any subclass of * the given superClassName that does not declare a no-arg constructor, i.e., * a constructor that takes no arguments. *

*/ public boolean requireNoArgConstructor(); } test-interface-1.0/src/main/java/sbt/testing/SuiteSelector.java000066400000000000000000000010071216340265200246240ustar00rootroot00000000000000package sbt.testing; import java.io.Serializable; /** * Indicates an event was about the entire suite whose class had the fully qualified name specified as * the fullyQualifiedName attribute the event. */ public final class SuiteSelector extends Selector implements Serializable { @Override public boolean equals(Object o) { return o instanceof SuiteSelector; } @Override public int hashCode() { return 29; } @Override public String toString() { return "SuiteSelector"; } } test-interface-1.0/src/main/java/sbt/testing/Task.java000066400000000000000000000026661216340265200227500ustar00rootroot00000000000000package sbt.testing; /** * A task to execute. * *

* The client may decide when or how to execute the task based on its tags. * A task can be any job, but is primarily intended for running tests and/or supplying more tasks * to the client. A framework can supply more tasks * to the client in the returned an array of Tasks (which can be empty if there's * no more work to do.) *

*/ public interface Task { /** * A possibly zero-length array of string tags associated with this task. * *

* A task may be tagged, for example, with a string that indicates it consumes a lot * of CPU time. Users can configure the client to only run, say, three such CPU-intensive * tasks concurrently. *

* * @return a possibly zero-length string array of this task's tags */ String[] tags(); /** * Executes this task, possibly returning to the client new tasks to execute. * * @param eventHandler an event handler to which to fire events during the run * @param loggers an array of loggers to which to emit log messages during the run * @return a possibly empty array of new tasks for the client to execute */ Task[] execute(EventHandler eventHandler, Logger[] loggers); /** * Returns the TaskDef that was used to request this Task. * * @return the TaskDef that was used to request this Task. */ TaskDef taskDef(); } test-interface-1.0/src/main/java/sbt/testing/TaskDef.java000066400000000000000000000124501216340265200233570ustar00rootroot00000000000000package sbt.testing; import java.util.Arrays; import java.io.Serializable; /** * A bundle of information used to request a Task from a test framework. * *

* An array of TaskDef is passed to Runner's tasks method, which returns * an array of Tasks. Each returned task, when executed, will run tests and suites determined by the * test class name, fingerprints, "explicitly specified" field, and selectors of one of the passed TaskDefs. *

* *

* The "Explicitly specified" field means the user supplied a complete fully qualified test name, such as with the command: *

* *
 * > test-only com.mycompany.myproject.WholeNameSpec
 * 
* *

* as opposed to commands like: *

* *
 * > test-only *WholeNameSpec
 * 
* *

* or simply: *

* *
 * > test
 * 
* *

* The explicitlySpecified field will be true for in the first case, and false in the last two cases, because only * in the first case was the fully qualified test class name completely specified by the user. The test framework can use this information * to decide whether to ignore an annotation requesting a class not be discovered. *

* *

* The fingerprint parameter indicates how the test suite was identified as a test suite. This tasks * method may be called with TaskDefs containing the same value for testClassName but different fingerprints. * For example, if both a class and its companion object were test classes, the tasks method could be passed an array containing * TaskDefs with the same name but with a different value for fingerprint.isModule. *

* *

* A test framework may "reject" a requested task by returning no Task for that TaskDef. *

*/ public final class TaskDef implements Serializable { private String _fullyQualifiedName; private Fingerprint _fingerprint; private boolean _explicitlySpecified; private Selector[] _selectors; /** * Constructs a new TaskDef with the given fully qualified name, fingerprint, "explicitly specified" fag, and array * of selectors. * * @param fullyQualifiedName the fully qualified name of the test class to be run by the requested task * @param fingerprint indicates how the test suite was identified as a test suite. * @param explicitlySpecified indicates whether the test class was explicitly specified by user. * @param selectors a possibly empty array of Selectors determining suites and tests to run */ public TaskDef(String fullyQualifiedName, Fingerprint fingerprint, boolean explicitlySpecified, Selector[] selectors) { if (fullyQualifiedName == null) { throw new NullPointerException("fullyQualifiedName was null"); } if (fingerprint == null) { throw new NullPointerException("fingerprint was null"); } if (selectors == null) { throw new NullPointerException("selectors was null"); } _fullyQualifiedName = fullyQualifiedName; _fingerprint = fingerprint; _explicitlySpecified = explicitlySpecified; _selectors = selectors; } /** * The fully qualified name of the test class requested by this TaskDef. */ public String fullyQualifiedName() { return _fullyQualifiedName; } /** * The fingerprint that the test class requested by this TaskDef matches. */ public Fingerprint fingerprint() { return _fingerprint; } /** * Indicates whether or not the test class requested by this TaskDef was "explicitly specified." * *

* For more information on what explicitly specified means, see the main documentation for this class. *

*/ public boolean explicitlySpecified() { return _explicitlySpecified; } /** * One to many selectors describing the nature of the Task requested by this TaskDef. * *

* A Selector can indicate a direct, such as command-line, request from the user or a "rerun" of previously run tests. * In the latter case, the Selectors would be taken from those passed in events of a previous run or runs. *

*/ public Selector[] selectors() { return _selectors; } @Override public boolean equals(Object o) { boolean retVal = false; if (o instanceof TaskDef) { TaskDef td = (TaskDef) o; retVal = td._fullyQualifiedName.equals(_fullyQualifiedName) && td._fingerprint.equals(_fingerprint) && td._explicitlySpecified == _explicitlySpecified && Arrays.equals(td._selectors, _selectors); } return retVal; } @Override public int hashCode() { int retVal = 17; retVal = 31 * retVal + _fullyQualifiedName.hashCode(); retVal = 31 * retVal + _fingerprint.hashCode(); retVal = 31 * retVal + (_explicitlySpecified ? 1 : 0); retVal = 31 * retVal + Arrays.hashCode(_selectors); return retVal; } @Override public String toString() { return "TaskDef(" + _fullyQualifiedName + ", " + _fingerprint + ", " + _explicitlySpecified + ", " + Arrays.toString(_selectors) + ")"; } } test-interface-1.0/src/main/java/sbt/testing/TestSelector.java000066400000000000000000000024071216340265200244570ustar00rootroot00000000000000package sbt.testing; import java.io.Serializable; /** * Information in addition to a test class name that identifies a test directly contained in the suite * whose class had the fully qualified name specified as the fullyQualifiedName attribute * passed to the event. */ public final class TestSelector extends Selector implements Serializable { private String _testName; /** * Constructs a new TestSelector with passed testName. * * @param testName the name of the test about which an event as fired. */ public TestSelector(String testName) { if (testName == null) { throw new NullPointerException("testName was null"); } _testName = testName; } /** * The name of a test about which an event was fired. * * @return the name of the test */ public String testName() { return _testName; } @Override public boolean equals(Object o) { boolean retVal = false; if (o instanceof TestSelector) { TestSelector ts = (TestSelector) o; retVal = ts._testName == _testName; } return retVal; } @Override public int hashCode() { return _testName.hashCode(); } @Override public String toString() { return "TestSelector(" + _testName + ")"; } } test-interface-1.0/src/main/java/sbt/testing/TestWildcardSelector.java000066400000000000000000000036261216340265200261350ustar00rootroot00000000000000package sbt.testing; import java.io.Serializable; /** * Information that identifies zero to many tests directly contained in a test class. * *

* The testWildcard is a simple string, i.e., not a glob or regular expression. * Any test whose name includes the testWildcard string as a substring will be selected. *

*/ public final class TestWildcardSelector extends Selector implements Serializable { private String _testWildcard; /** * Constructs a new TestWildcardSelector with passed testWildcard. * *

* The testWildcard is a simple string, i.e., not a glob or regular expression. * Any test whose name includes the testWildcard string as a substring will be selected. *

* * @param testWildcard a string used to select tests. */ public TestWildcardSelector(String testWildcard) { if (testWildcard == null) { throw new NullPointerException("testWildcard was null"); } _testWildcard = testWildcard; } /** * A test wildcard string used to select tests. * *

* The testWildcard is a simple string, i.e., not a glob or regular expression. * Any test whose name includes the testWildcard string as a substring will be selected. *

* * @return the test wildcard string used to select tests. */ public String testWildcard() { return _testWildcard; } @Override public boolean equals(Object o) { boolean retVal = false; if (o instanceof TestWildcardSelector) { TestWildcardSelector tws = (TestWildcardSelector) o; retVal = tws._testWildcard == _testWildcard; } return retVal; } @Override public int hashCode() { return _testWildcard.hashCode(); } @Override public String toString() { return "TestWildcardSelector(" + _testWildcard + ")"; } } test-interface-1.0/src/test/000077500000000000000000000000001216340265200160365ustar00rootroot00000000000000test-interface-1.0/src/test/scala/000077500000000000000000000000001216340265200171215ustar00rootroot00000000000000test-interface-1.0/src/test/scala/sbt/000077500000000000000000000000001216340265200177115ustar00rootroot00000000000000test-interface-1.0/src/test/scala/sbt/testing/000077500000000000000000000000001216340265200213665ustar00rootroot00000000000000test-interface-1.0/src/test/scala/sbt/testing/NestedSuiteSelectorSpec.scala000066400000000000000000000033271216340265200271500ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class NestedSuiteSelectorSpec extends UnitSpec { object `a NestedSuiteSelector` { val redNestedSuiteSelector = new NestedSuiteSelector("red") val blueNestedSuiteSelector = new NestedSuiteSelector("blue") def `should give back what you put into it` { redNestedSuiteSelector.suiteId shouldBe "red" blueNestedSuiteSelector.suiteId shouldBe "blue" } def `should have a properly behaving equals method` { redNestedSuiteSelector shouldEqual redNestedSuiteSelector redNestedSuiteSelector shouldEqual new NestedSuiteSelector("red") redNestedSuiteSelector should not equal new NestedSuiteSelector("blue") redNestedSuiteSelector should not equal null redNestedSuiteSelector should not equal "howdy" redNestedSuiteSelector should not equal new SuiteSelector } def `should have a properly behaving hashCode method` { redNestedSuiteSelector.hashCode shouldEqual redNestedSuiteSelector.hashCode redNestedSuiteSelector.hashCode shouldEqual (new NestedSuiteSelector("red")).hashCode redNestedSuiteSelector.hashCode should not equal blueNestedSuiteSelector.hashCode blueNestedSuiteSelector.hashCode shouldEqual blueNestedSuiteSelector.hashCode blueNestedSuiteSelector.hashCode shouldEqual (new NestedSuiteSelector("blue")).hashCode } def `should throw NPE from constructor of null passed` { a [NullPointerException] should be thrownBy { new NestedSuiteSelector(null) } } def `should have a pretty toString` { redNestedSuiteSelector.toString shouldEqual "NestedSuiteSelector(red)" blueNestedSuiteSelector.toString shouldEqual "NestedSuiteSelector(blue)" } } } test-interface-1.0/src/test/scala/sbt/testing/NestedTestSelectorSpec.scala000066400000000000000000000052131216340265200267720ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class NestedTestSelectorSpec extends UnitSpec { object `a NestedTestSelector` { val redBirdNestedTestSelector = new NestedTestSelector("red", "bird") val blueBirdNestedTestSelector = new NestedTestSelector("blue", "bird") val redFishNestedTestSelector = new NestedTestSelector("red", "fish") val blueFishNestedTestSelector = new NestedTestSelector("blue", "fish") def `should give back what you put into it` { redBirdNestedTestSelector.suiteId shouldBe "red" redBirdNestedTestSelector.testName shouldBe "bird" blueBirdNestedTestSelector.suiteId shouldBe "blue" blueBirdNestedTestSelector.testName shouldBe "bird" redFishNestedTestSelector.suiteId shouldBe "red" redFishNestedTestSelector.testName shouldBe "fish" blueFishNestedTestSelector.suiteId shouldBe "blue" blueFishNestedTestSelector.testName shouldBe "fish" } def `should have a properly behaving equals method` { redBirdNestedTestSelector shouldEqual redBirdNestedTestSelector redBirdNestedTestSelector shouldEqual new NestedTestSelector("red", "bird") redBirdNestedTestSelector should not equal blueBirdNestedTestSelector redBirdNestedTestSelector should not equal redFishNestedTestSelector redBirdNestedTestSelector should not equal blueFishNestedTestSelector redBirdNestedTestSelector should not equal null redBirdNestedTestSelector should not equal "howdy" redBirdNestedTestSelector should not equal new SuiteSelector } def `should have a properly behaving hashCode method` { redBirdNestedTestSelector.hashCode shouldEqual redBirdNestedTestSelector.hashCode redBirdNestedTestSelector.hashCode shouldEqual (new NestedTestSelector("red", "bird")).hashCode redBirdNestedTestSelector.hashCode should not equal blueBirdNestedTestSelector.hashCode redBirdNestedTestSelector.hashCode should not equal redFishNestedTestSelector.hashCode blueBirdNestedTestSelector.hashCode shouldEqual blueBirdNestedTestSelector.hashCode blueBirdNestedTestSelector.hashCode shouldEqual (new NestedTestSelector("blue", "bird")).hashCode } def `should throw NPE from constructor if null passed` { a [NullPointerException] should be thrownBy { new NestedTestSelector(null, "bird") } a [NullPointerException] should be thrownBy { new NestedTestSelector("red", null) } } def `should have a pretty toString` { redBirdNestedTestSelector.toString shouldEqual "NestedTestSelector(red, bird)" blueBirdNestedTestSelector.toString shouldEqual "NestedTestSelector(blue, bird)" } } } test-interface-1.0/src/test/scala/sbt/testing/OptionalThrowableSpec.scala000066400000000000000000000045161216340265200266510ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class OptionalThrowableSpec extends UnitSpec { object `an OptionalThrowable` { val ex1 = new Error("red alert") val ex2 = new RuntimeException("feeling blue") val def1 = new OptionalThrowable(ex1) val def2 = new OptionalThrowable(ex2) val undef = new OptionalThrowable() object `when defined` { def `should say it is defined` { def1.isDefined shouldBe true def2.isDefined shouldBe true } def `should say it is not empty` { def1.isEmpty shouldBe false def2.isEmpty shouldBe false } def `should return the Throwable from its get method` { def1.get shouldBe ex1 def2.get shouldBe ex2 } } object `when empty` { def `should say it is not defined` { undef.isDefined shouldBe false } def `should say it is empty` { undef.isEmpty shouldBe true } def `should return throw IllegalStateException from its get method` { an [IllegalStateException] should be thrownBy { undef.get } } } def `should throw NPE from constructor if null passed` { a [NullPointerException] should be thrownBy { new OptionalThrowable(null) } } def `should have a properly behaving equals method` { def1 shouldEqual def1 def1 shouldEqual new OptionalThrowable(ex1) def2 shouldEqual def2 def2 shouldEqual new OptionalThrowable(ex2) def1 should not equal null def1 should not equal undef def1 should not equal "howdy" def1 should not equal new OptionalThrowable(ex2) undef shouldEqual undef undef shouldEqual new OptionalThrowable() undef should not equal def1 } def `should have a properly behaving hashCode method` { def1.hashCode shouldEqual (new OptionalThrowable(ex1)).hashCode def2.hashCode shouldEqual (new OptionalThrowable(ex2)).hashCode undef.hashCode shouldEqual (new OptionalThrowable()).hashCode } def `should have a pretty toString` { def1.toString should (startWith ("OptionalThrowable(") and endWith (")") and not be ("OptionalThrowable()")) def2.toString should (startWith ("OptionalThrowable(") and endWith (")") and not be ("OptionalThrowable()")) undef.toString shouldBe "OptionalThrowable()" } } } test-interface-1.0/src/test/scala/sbt/testing/SuiteSelectorSpec.scala000066400000000000000000000013341216340265200260010ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class SuiteSelectorSpec extends UnitSpec { object `a SuiteSelector` { val aSuiteSelector = new SuiteSelector def `should have a properly behaving equals method` { aSuiteSelector shouldEqual aSuiteSelector aSuiteSelector shouldEqual new SuiteSelector aSuiteSelector should not equal null aSuiteSelector should not equal "howdy" aSuiteSelector should not equal new TestSelector("howdy") } def `should have a properly behaving hashCode method` { (new SuiteSelector).hashCode shouldEqual (new SuiteSelector).hashCode } def `should have a pretty toString` { aSuiteSelector.toString shouldEqual "SuiteSelector" } } } test-interface-1.0/src/test/scala/sbt/testing/TaskDefSpec.scala000066400000000000000000000064741216340265200245420ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class TaskDefSpec extends UnitSpec { case object SuiteSubclassFingerprint extends SubclassFingerprint { def isModule: Boolean = false def superclassName: String = "org.scalatest.Suite" def requireNoArgConstructor: Boolean = true } case object WrapWithAnnotatedFingerprint extends AnnotatedFingerprint { def isModule: Boolean = false def annotationName: String = "org.scalatest.WrapWith" } val fqn1 = "com.myproject.SomeSpec" val td1 = new TaskDef( fqn1, SuiteSubclassFingerprint, false, Array(new SuiteSelector) ) val fqn2 = "com.myproject.SomeOtherSpec" val td2 = new TaskDef( fqn2, WrapWithAnnotatedFingerprint, true, Array(new TestSelector("it should do something")) ) object `a TaskDef` { def `should give back what you put into it` { td1.fullyQualifiedName shouldBe fqn1 td1.fingerprint shouldBe SuiteSubclassFingerprint td1.explicitlySpecified shouldBe false td1.selectors shouldBe Array(new SuiteSelector) td2.fullyQualifiedName shouldBe fqn2 td2.fingerprint shouldBe WrapWithAnnotatedFingerprint td2.explicitlySpecified shouldBe true td2.selectors shouldBe Array(new TestSelector("it should do something")) } def `should throw NPE from constructor if null passed` { val fullyQualifiedName: String = "com.myproject.SomeSpec" val fingerprint: Fingerprint = SuiteSubclassFingerprint val selectors: Array[Selector] = Array(new SuiteSelector) val invalidCombos = Table( ("fullyQualifiedName", "fingerprint", "selectors"), ( null , fingerprint , selectors ), ( fullyQualifiedName , null , selectors ), ( fullyQualifiedName , fingerprint , null ) ) forAll (invalidCombos) { (fqn, fp, sel) => a [NullPointerException] should be thrownBy { new TaskDef(fqn, fp, false, sel) } } } def `should have a properly behaving equals method` { td1 shouldEqual td1 td1 shouldEqual ( new TaskDef( fqn1, SuiteSubclassFingerprint, false, Array(new SuiteSelector) ) ) td1 should not equal null td1 should not equal "howdy" td1 should not equal td2 } def `should have a properly behaving hashCode method` { td1.hashCode shouldEqual td1.hashCode td1.hashCode shouldEqual ( new TaskDef( fqn1, SuiteSubclassFingerprint, false, Array(new SuiteSelector) ).hashCode ) td1.hashCode should not equal td2.hashCode td2.hashCode shouldEqual td2.hashCode td2.hashCode shouldEqual ( new TaskDef( fqn2, WrapWithAnnotatedFingerprint, true, Array(new TestSelector("it should do something")) ).hashCode ) } def `should have a pretty toString` { td1.toString should startWith ("TaskDef(com.myproject.SomeSpec, ") td1.toString should endWith (", false, [SuiteSelector])") td2.toString should startWith ("TaskDef(com.myproject.SomeOtherSpec, ") td2.toString should endWith (", true, [TestSelector(it should do something)])") } } } test-interface-1.0/src/test/scala/sbt/testing/TestSelectorSpec.scala000066400000000000000000000027711216340265200256350ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class TestSelectorSpec extends UnitSpec { object `a TestSelector` { val redTestSelector = new TestSelector("red") val blueTestSelector = new TestSelector("blue") def `should give back what you put into it` { redTestSelector.testName shouldBe "red" blueTestSelector.testName shouldBe "blue" } def `should have a properly behaving equals method` { redTestSelector shouldEqual redTestSelector redTestSelector shouldEqual new TestSelector("red") redTestSelector should not equal new TestSelector("blue") redTestSelector should not equal null redTestSelector should not equal "howdy" redTestSelector should not equal new SuiteSelector } def `should have a properly behaving hashCode method` { redTestSelector.hashCode shouldEqual redTestSelector.hashCode redTestSelector.hashCode shouldEqual (new TestSelector("red")).hashCode redTestSelector.hashCode should not equal blueTestSelector.hashCode blueTestSelector.hashCode shouldEqual blueTestSelector.hashCode blueTestSelector.hashCode shouldEqual (new TestSelector("blue")).hashCode } def `should throw NPE from constructor if null passed` { a [NullPointerException] should be thrownBy { new TestSelector(null) } } def `should have a pretty toString` { redTestSelector.toString shouldEqual "TestSelector(red)" blueTestSelector.toString shouldEqual "TestSelector(blue)" } } } test-interface-1.0/src/test/scala/sbt/testing/TestWildcardSelectorSpec.scala000066400000000000000000000034011216340265200272760ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class TestWildcardSelectorSpec extends UnitSpec { object `a TestWildcardSelector` { val redTestWildcardSelector = new TestWildcardSelector("red") val blueTestWildcardSelector = new TestWildcardSelector("blue") def `should give back what you put into it` { redTestWildcardSelector.testWildcard shouldBe "red" blueTestWildcardSelector.testWildcard shouldBe "blue" } def `should have a properly behaving equals method` { redTestWildcardSelector shouldEqual redTestWildcardSelector redTestWildcardSelector shouldEqual new TestWildcardSelector("red") redTestWildcardSelector should not equal new TestWildcardSelector("blue") redTestWildcardSelector should not equal null redTestWildcardSelector should not equal "howdy" redTestWildcardSelector should not equal new SuiteSelector } def `should have a properly behaving hashCode method` { redTestWildcardSelector.hashCode shouldEqual redTestWildcardSelector.hashCode redTestWildcardSelector.hashCode shouldEqual (new TestWildcardSelector("red")).hashCode redTestWildcardSelector.hashCode should not equal blueTestWildcardSelector.hashCode blueTestWildcardSelector.hashCode shouldEqual blueTestWildcardSelector.hashCode blueTestWildcardSelector.hashCode shouldEqual (new TestWildcardSelector("blue")).hashCode } def `should throw NPE from constructor if null passed` { a [NullPointerException] should be thrownBy { new TestWildcardSelector(null) } } def `should have a pretty toString` { redTestWildcardSelector.toString shouldEqual "TestWildcardSelector(red)" blueTestWildcardSelector.toString shouldEqual "TestWildcardSelector(blue)" } } } test-interface-1.0/src/test/scala/sbt/testing/UnitSpec.scala000066400000000000000000000001731216340265200241260ustar00rootroot00000000000000package sbt.testing import org.scalatest._ class UnitSpec extends Spec with Matchers with prop.TableDrivenPropertyChecks