org.scalatest

# Shell

#### trait Shell extends AnyRef

Trait whose instances provide a `run` method and configuration fields that implement the ScalaTest shell: its DSL for the Scala interpreter.

The main command of the ScalaTest shell is `run`, which you can use to run a suite of tests. The shell also provides several commands for configuring a call to `run`:

- `color` (the default) - display results in color (green for success; red for failure; yellow for warning; blue for statistics)
- `nocolor` - display results without color
- `durations` - display durations of (i.e., how long it took to run) tests and suites
- `nodurations` (the default) - do not display durations of tests and suites
- `shortstacks` - display short (i.e., truncated to show just the most useful portion) stack traces for all exceptions
- `fullstacks` - display full stack trackes for all exceptions
- `nostacks` (the default) - display no stack trace for `StackDepth` exceptions and a short stack trace for non-`StackDepth` exceptions
- `stats` - display statistics before and after the run, such as expected test count before the run and tests succeeded, failed, pending,etc., counts after the run
- `nostats` (the default) not display statistics before or after the run

The default configuration is `color`, `nodurations`, `nostacks`, and `nostats`.

All of these commands are fields of trait `org.scalatest.Shell`. Each configuration command is a field that refers to another `Shell` instance with every configuration parameter the same except for the one you've asked to change. For example, `durations` provides a`Shell` instance that has every parameter configured the same way, except with durations enabled. When you invoke`run` on that, you will get a run with durations enabled and every other configuration parameter at its default value.

Two other useful "commands" to know about, though not technically part of the shell, are the `apply` factory methods in the `Suites` and `Specs`singleton objects. These allow you to easily create composite suites out of nested suites, which you can then pass to `run`. This will be demonstrated later in this documentation.

#### Using the ScalaTest shell

The package object of the `org.scalatest` package, although it does not extend `Shell`, declares all the same members as `Shell`. Its `run` method runs with all the `Shell` configuration parameters set to their default values. A good way to use the ScalaTest shell, therefore, is to import the members of package `org.scalatest`:

    scala> import org.scalatest._
    import org.scalatest._

One thing importing `org.scalatest._` allows you to do is access any of ScalaTest's classes and traits by shorter names, for example:

    scala> class ArithmeticSuite extends FunSuite with matchers.ShouldMatchers {
         |   test("addition works") {
         |     1 + 1 should equal (2)
         |   }
         |   ignore("subtraction works") {
         |     1 - 1 should equal (0)
         |   }
         |   test("multiplication works") {
         |     1 * 1 should equal (2)
         |   }
         |   test("division works") (pending)
         | }
    defined class ArithmeticSuite

But importing `org.scalatest._` also brings into scope the commands of the `Shell`, so you can, for example, invoke `run` without qualification:

    scala> run(new ArithmeticSuite)ArithmeticSuite:
    - addition works- subtraction works !!! IGNORED !!!- multiplication works *** FAILED ***
      1 did not equal 2 (<console>:16)- division works (pending)

#### Configuring a single run

To configure a single run, you can prefix run by one or more configuration commands, separated by dots. For example, to enable durations during a single run, you would write:

    scala> durations.run(new ArithmeticSuite)ArithmeticSuite:
    - addition works (102 milliseconds)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED *** (36 milliseconds)
      1 did not equal 2 (<console>:16)- division works (pending)

To enable statistics during a single run, you would write:

    scala> stats.run(new ArithmeticSuite)Run starting. Expected test count is: 3ArithmeticSuite:
    - addition works- subtraction works !!! IGNORED !!!- multiplication works *** FAILED ***
      1 did not equal 2 (<console>:16)- division works (pending)Run completed in 386 milliseconds.
    Total number of tests run: 2
    Suites: completed 1, aborted 0
    Tests: succeeded 1, failed 1, ignored 1, pending 1*** 1 TEST FAILED ***

And to enable both durations and statistics during a single run, you could write:

    scala> durations.stats.run(new ArithmeticSuite)Run starting. Expected test count is: 3ArithmeticSuite:
    - addition works (102 milliseconds)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED (36 milliseconds)***
      1 did not equal 2 (<console>:16)- division works (pending)Run completed in 386 milliseconds.
    Total number of tests run: 2
    Suites: completed 1, aborted 0
    Tests: succeeded 1, failed 1, ignored 1, pending 1*** 1 TEST FAILED ***

The order doesn't matter when you are chaining multiple configuration commands. You'll get the same result whether you write `durations.stats.run` or `stats.durations.run`.

To disable color, use `nocolor`:

    scala> nocolor.run(new ArithmeticSuite)
    ArithmeticSuite:
    - addition works
    - subtraction works !!! IGNORED !!!
    - multiplication works *** FAILED ***
      1 did not equal 2 (<console>:16)
    - division works (pending)

To enable short stack traces during a single run, use `shortstacks`:

    scala> shortstacks.run(new ArithmeticSuite)ArithmeticSuite:
    - addition works (101 milliseconds)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED *** (33 milliseconds)
      1 did not equal 2 (<console>:16)
      org.scalatest.TestFailedException:
      ...
      at line2$object$$iw$$iw$$iw$$iw$ArithmeticSuite$$anonfun$3.apply$mcV$sp(<console>:16)
      at line2$object$$iw$$iw$$iw$$iw$ArithmeticSuite$$anonfun$3.apply(<console>:16)
      at line2$object$$iw$$iw$$iw$$iw$ArithmeticSuite$$anonfun$3.apply(<console>:16)
      at org.scalatest.FunSuite$$anon$1.apply(FunSuite.scala:992)
      at org.scalatest.Suite$class.withFixture(Suite.scala:1661)
      at line2$object$$iw$$iw$$iw$$iw$ArithmeticSuite.withFixture(<console>:8)
      at org.scalatest.FunSuite$class.invokeWithFixture$1(FunSuite.scala:989)
      ...- division works (pending)

#### Changing the default configuration

If you want to change the default for multiple runs, you can import the members of your favorite `Shell` configuration. For example, if you always like to run with durations and statistics enabled, you could write:

    scala> import stats.durations._
    import stats.durations._

Now anytime you run statistics and durations will, by default, be enabled:

    scala> run(new ArithmeticSuite)Run starting. Expected test count is: 3ArithmeticSuite:
    - addition works (9 milliseconds)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED *** (10 milliseconds)
      1 did not equal 2 (<console>:18)- division works (pending)Run completed in 56 milliseconds.
    Total number of tests run: 2
    Suites: completed 1, aborted 0
    Tests: succeeded 1, failed 1, ignored 1, pending 1*** 1 TEST FAILED ***

#### Running multiple suites

If you want to run multiple suites, you can use the factory methods in either the `Suites` or`Specs`singleton objects. If you wrap a comma-separated list of suite instances inside `Suites(...)`, for example, you'll get a suite instance that contains no tests, but whose nested suites includes the suite instances you placed between the parentheses. You can place `Suites` inside `Suites` to any level of depth, creating a tree of suites to pass to `run`. Here's a (contrived) example in which `ArithmeticSuite` is executed four times:

    scala> run(Suites(new ArithmeticSuite, new ArithmeticSuite, Suites(new ArithmeticSuite, new ArithmeticSuite)))Run starting. Expected test count is: 12Suites:
    ArithmeticSuite:
    - addition works (0 milliseconds)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED *** (1 millisecond)
      1 did not equal 2 (<console>:16)- division works (pending)ArithmeticSuite:
    - addition works (1 millisecond)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED *** (0 milliseconds)
      1 did not equal 2 (<console>:16)- division works (pending)Suites:
    ArithmeticSuite:
    - addition works (0 milliseconds)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED *** (0 milliseconds)
      1 did not equal 2 (<console>:16)- division works (pending)ArithmeticSuite:
    - addition works (0 milliseconds)- subtraction works !!! IGNORED !!!- multiplication works *** FAILED *** (0 milliseconds)
      1 did not equal 2 (<console>:16)- division works (pending)Run completed in 144 milliseconds.
    Total number of tests run: 8
    Suites: completed 6, aborted 0
    Tests: succeeded 4, failed 4, ignored 4, pending 4*** 4 TESTS FAILED ***

#### Running a single test

The `run` command also allows you to specify the name of a test to run and/or a config map. You can run a particular test in a suite, for example, by specifying the test name after the suite instance in your call to `run`, like this:

    scala> run(new ArithmeticSuite, "addition works")ArithmeticSuite:
    - addition works

attributes: sealed
linear super types: AnyRef, Any
Ordering

1. Alphabetic
2. By inheritance

Inherited

1. Hide All
2. Show all

1. Shell
2. AnyRef
3. Any

Visibility

1. Public
2. All

Impl.

1. Concrete
2. Abstract

### Value Members

1. #### def != (arg0: AnyRef) : Boolean

   attributes: final
   definition classes: AnyRef

2. #### def != (arg0: Any) : Boolean

   `o != arg0` is the same as `!(o == (arg0))`.

   `o != arg0` is the same as `!(o == (arg0))`.

   arg0

     the object to compare against this object for dis-equality.

   returns

     `false` if the receiver object is equivalent to the argument; `true` otherwise.

   attributes: final
   definition classes: Any

3. #### def ## () : Int

   attributes: final
   definition classes: AnyRef → Any

4. #### def $asInstanceOf [T0] () : T0

   attributes: final
   definition classes: AnyRef

5. #### def $isInstanceOf [T0] () : Boolean

   attributes: final
   definition classes: AnyRef

6. #### def == (arg0: AnyRef) : Boolean

   `o == arg0` is the same as `if (o eq null) arg0 eq null else o.equals(arg0)`.

   `o == arg0` is the same as `if (o eq null) arg0 eq null else o.equals(arg0)`.

   arg0

     the object to compare against this object for equality.

   returns

     `true` if the receiver object is equivalent to the argument; `false` otherwise.

   attributes: final
   definition classes: AnyRef

7. #### def == (arg0: Any) : Boolean

   `o == arg0` is the same as `o.equals(arg0)`.

   `o == arg0` is the same as `o.equals(arg0)`.

   arg0

     the object to compare against this object for equality.

   returns

     `true` if the receiver object is equivalent to the argument; `false` otherwise.

   attributes: final
   definition classes: Any

8. #### def asInstanceOf [T0] : T0

   This method is used to cast the receiver object to be of type `T0`.

   This method is used to cast the receiver object to be of type `T0`.

   Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression`1.asInstanceOf[String]` will throw a `ClassCastException` at runtime, while the expression`List(1).asInstanceOf[List[String]]` will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

   returns

     the receiver object.

   attributes: final
   definition classes: Any

9. #### def clone () : AnyRef

   This method creates and returns a copy of the receiver object.

   This method creates and returns a copy of the receiver object.

   The default implementation of the `clone` method is platform dependent.

   returns

     a copy of the receiver object.

   attributes: protected
   definition classes: AnyRef

10. #### val color : Shell

    A `Shell` whose `run` method will pass `true` for `execute`'s `color`parameter, and pass for all other parameters the same values as this `Shell`.

    A `Shell` whose `run` method will pass `true` for `execute`'s `color`parameter, and pass for all other parameters the same values as this `Shell`.

    attributes: abstract

11. #### val durations : Shell

    A `Shell` whose `run` method will pass `true` for `execute`'s `durations`parameter, and pass for all other parameters the same values as this `Shell`.

    A `Shell` whose `run` method will pass `true` for `execute`'s `durations`parameter, and pass for all other parameters the same values as this `Shell`.

    attributes: abstract

12. #### def eq (arg0: AnyRef) : Boolean

    This method is used to test whether the argument (`arg0`) is a reference to the receiver object (`this`).

    This method is used to test whether the argument (`arg0`) is a reference to the receiver object (`this`).

    The `eq` method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on non-null instances of `AnyRef`: * It is reflexive: for any non-null instance `x` of type `AnyRef`, `x.eq(x)` returns `true`. * It is symmetric: for any non-null instances `x` and `y` of type `AnyRef`, `x.eq(y)` returns `true` if and only if `y.eq(x)` returns `true`. * It is transitive: for any non-null instances `x`, `y`, and `z` of type `AnyRef` if `x.eq(y)` returns `true` and `y.eq(z)` returns `true`, then `x.eq(z)` returns `true`.

    Additionally, the `eq` method has three other properties. * It is consistent: for any non-null instances `x` and `y` of type `AnyRef`, multiple invocations of `x.eq(y)` consistently returns `true` or consistently returns `false`. * For any non-null instance `x` of type `AnyRef`, `x.eq(null)` and `null.eq(x)` returns `false`. * `null.eq(null)` returns `true`.

    When overriding the `equals` or `hashCode` methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (`o1 eq o2`), they should be equal to each other (`o1 == o2`) and they should hash to the same value (`o1.hashCode == o2.hashCode`).

    arg0

      the object to compare against this object for reference equality.

    returns

      `true` if the argument is a reference to the receiver object; `false` otherwise.

    attributes: final
    definition classes: AnyRef

13. #### def equals (arg0: Any) : Boolean

    This method is used to compare the receiver object (`this`) with the argument object (`arg0`) for equivalence.

    This method is used to compare the receiver object (`this`) with the argument object (`arg0`) for equivalence.

    The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation]: * It is reflexive: for any instance `x` of type `Any`, `x.equals(x)` should return `true`. * It is symmetric: for any instances `x` and `y` of type `Any`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`. * It is transitive: for any instances `x`, `y`, and `z` of type `AnyRef` if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override `hashCode` to ensure that objects that are "equal" (`o1.equals(o2)` returns `true`) hash to the same scala.Int (`o1.hashCode.equals(o2.hashCode)`).

    arg0

      the object to compare against this object for equality.

    returns

      `true` if the receiver object is equivalent to the argument; `false` otherwise.

    definition classes: AnyRef → Any

14. #### def finalize () : Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    The details of when and if the `finalize` method are invoked, as well as the interaction between `finalize`and non-local returns and exceptions, are all platform dependent.

    attributes: protected
    definition classes: AnyRef

15. #### val fullstacks : Shell

    A `Shell` whose `run` method will pass `false` for `execute`'s `shortstacks`parameter and `true` for its `fullstacks` parameter, and pass for all other parameters the same values as this `Shell`.

    A `Shell` whose `run` method will pass `false` for `execute`'s `shortstacks`parameter and `true` for its `fullstacks` parameter, and pass for all other parameters the same values as this `Shell`.

    attributes: abstract

16. #### def getClass () : java.lang.Class[_]

    Returns a representation that corresponds to the dynamic class of the receiver object.

    Returns a representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

      a representation that corresponds to the dynamic class of the receiver object.

    attributes: final
    definition classes: AnyRef

17. #### def hashCode () : Int

    Returns a hash code value for the object.

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (`o1.hashCode.equals(o2.hashCode)`) yet not be equal (`o1.equals(o2)` returns `false`). A degenerate implementation could always return `0`. However, it is required that if two objects are equal (`o1.equals(o2)` returns `true`) that they have identical hash codes (`o1.hashCode.equals(o2.hashCode)`). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the `equals` method.

    returns

      the hash code value for the object.

    definition classes: AnyRef → Any

18. #### def isInstanceOf [T0] : Boolean

    This method is used to test whether the dynamic type of the receiver object is `T0`.

    This method is used to test whether the dynamic type of the receiver object is `T0`.

    Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression`1.isInstanceOf[String]` will return `false`, while the expression `List(1).isInstanceOf[List[String]]` will return `true`. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

      `true` if the receiver object is an instance of erasure of type `T0`; `false` otherwise.

    attributes: final
    definition classes: Any

19. #### def ne (arg0: AnyRef) : Boolean

    `o.ne(arg0)` is the same as `!(o.eq(arg0))`.

    `o.ne(arg0)` is the same as `!(o.eq(arg0))`.

    arg0

      the object to compare against this object for reference dis-equality.

    returns

      `false` if the argument is not a reference to the receiver object; `true` otherwise.

    attributes: final
    definition classes: AnyRef

20. #### val nocolor : Shell

    Returns a copy of this `Shell` with `colorPassed` configuration parameter set to `false`.

    Returns a copy of this `Shell` with `colorPassed` configuration parameter set to `false`.

    attributes: abstract

21. #### val nodurations : Shell

    Returns a copy of this `Shell` with `durationsPassed` configuration parameter set to `false`.

    Returns a copy of this `Shell` with `durationsPassed` configuration parameter set to `false`.

    attributes: abstract

22. #### val nostacks : Shell

    Returns a copy of this `Shell` with `shortStacksPassed` configuration parameter set to `false`.

    Returns a copy of this `Shell` with `shortStacksPassed` configuration parameter set to `false`.

    attributes: abstract

23. #### val nostats : Shell

    Returns a copy of this `Shell` with `statsPassed` configuration parameter set to `false`.

    Returns a copy of this `Shell` with `statsPassed` configuration parameter set to `false`.

    attributes: abstract

24. #### def notify () : Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef

25. #### def notifyAll () : Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef

26. #### def run (suite: Suite, testName: String =null, configMap: Map[String, Any] =Map()) : Unit

    Run the passed suite, optionally passing in a test name and config map.

    Run the passed suite, optionally passing in a test name and config map.

    This method will invoke `execute` on the passed `suite`, passing in the specified (or default) `testName` and `configMap` and a set of configuration values. A particular `Shell` instance will always pass the same configuration values (`color`,`durations`, `shortstacks`, `fullstacks`, and `stats`) to `execute` each time this method is invoked.

    attributes: abstract

27. #### val shortstacks : Shell

    A `Shell` whose `run` method will pass `true` for `execute`'s `shortstacks`parameter and `false` for its `fullstacks` parameter, and pass for all other parameters the same values as this `Shell`.

    A `Shell` whose `run` method will pass `true` for `execute`'s `shortstacks`parameter and `false` for its `fullstacks` parameter, and pass for all other parameters the same values as this `Shell`.

    attributes: abstract

28. #### val stats : Shell

    A `Shell` whose `run` method will pass `true` for `execute`'s `stats`parameter, and pass for all other parameters the same values as this `Shell`.

    A `Shell` whose `run` method will pass `true` for `execute`'s `stats`parameter, and pass for all other parameters the same values as this `Shell`.

    attributes: abstract

29. #### def synchronized [T0] (arg0: T0) : T0

    attributes: final
    definition classes: AnyRef

30. #### def toString () : String

    Returns a string representation of the object.

    Returns a string representation of the object.

    The default representation is platform dependent.

    returns

      a string representation of the object.

    definition classes: AnyRef → Any

31. #### def wait () : Unit

    attributes: final
    definition classes: AnyRef

32. #### def wait (arg0: Long, arg1: Int) : Unit

    attributes: final
    definition classes: AnyRef

33. #### def wait (arg0: Long) : Unit

    attributes: final
    definition classes: AnyRef

### Inherited from AnyRef

### Inherited from Any