ScalaTest 1.8 is source (but not necessarily binary) compatible with previous releases. To upgrade from 1.7.1 or 1.7.2, you should only need to do a clean build.
This release includes the following enhancements, bug fixes, dependency changes, and deprecations:
Enhancements:
path.FunSpec
, a sister trait to org.scalatest.FunSpec
that isolates tests by running each test in its own instance of the test class, and for each test, only executing the path leading to that test.path.FreeSpec
, a sister trait to org.scalatest.FreeSpec
that isolates tests by running each test in its own instance of the test class, and for each test, only executing the path leading to that test.ConfigMapWrapperSuite
, a wrapper Suite
that passes an instance of the config map to the constructor of the wrapped Suite
when run is invoked.Eventually
, which provides an
eventually
construct that periodically retries executing a passed by-name parameter until it either succeeds or the configured timeout has been surpassed.AsyncAssertions
, which facilitates performing
assertions outside the main test thread, such as assertions in callback methods that are invoked asynchronously. Trait AsyncAssertions
provides a
Waiter
class that you can use to orchestrate the inter-thread communication required to perform assertions outside the main test thread, and means
to configure it.Timeouts
, which provides a
failAfter
construct that allows you to specify a time limit for an operation passed as a by-name parameter, as well as a way to interrupt it if the operation
exceeds its time limit.TimeLimitedTests
, which, when mixed into a suite class, establishes a time limit for its tests.Interruptor
, an abstract interface defining a strategy for interrupting an operation after a timeout expires (Interruptor
s are used by traits Timeouts
and TimeLimitedTests
.). Provided four built-in implementations: DoNotInterrupt
, SelectorInterruptor
, SocketInterruptor
, ThreadInterruptor
.org.scalatest.time
package containing class Span
, used to express time spans in ScalaTest (Span
is used by several traits in org.scalatest.concurrent
), trait SpanSugar
, and several other supporting classes and objects.ScaledTimeSpans
, which provides a scaled
method that will scale a Span
larger or smaller by a Double
factor taken from a sister method, spanScaleFactor
. Added a -F
argument to Runner
for specifying the span scale factor (and corresponding commands for sbt and ant).PatienceConfiguration
, which provides methods and classes used to configure timeouts and, where relevant, the interval between retries.IntegrationPatience
, which overrides the implicit PatienceConfig
object providing default values appropriate for unit testing (150 millisecond timeout and 15 millisecond interval) with one more appropriate for integration testing (15 second timeout and 150 millisecond interval). Conductors
, moved a copy of Conductor
there,
and made changes so that Conductor
is configured in a manner consistent with Eventually
and AsyncAssertions
.org.scalatest.exceptions
, and left deprecated type aliases in place of their old names. This change was done to declutter their former homes, so it is easier for users
to focus on the classes and traits they are more likely to use day to day.TestFailedDueToTimeoutException
,
a subclass of TestFailedException
thrown by the failAfter
method of trait Timeouts
if it times out.TimeoutField
, a trait mixed into exceptions
thrown as the result of a timeout.PayloadField
, a trait mixed into exceptions
that can carry a payload (an arbitrary object that will be fired in the corresponding ScalaTest event, so it can be consumed by custom reporters). Had to add payload
to the primary constructor of several existing exception types. Left the old form in place as an auxiliary constructor so existing code would continue to work.ModifiablePayload
, which indicates a PayloadField
exception type can modify its payload.Payloads
, which facilitates the inclusion of a payload in a thrown ScalaTest exception, so that payload object can be included in a corresponding ScalaTest event and interpreted by custom reporters.apply
method of trait Informer
,
to facilitate the inclusion of a payload in an InfoProvided
event. The parameter has type Option[Any]
with a default value of None
,
so old code will continute to work.withClue
construct in Assertions
a result type, so it would pass through any
value in case someone wanted that. Previously it was Unit
.AppendedClues
, which provides an implicit conversion that places a withClue
method on Any
, enabling clue strings to be placed after a block of code that may throw an exception. This construct
complements the withClue
construct provided in trait Assertions
that allows clue strings to be placed before a block of code.java.awt.AWTError
to facilitate running ScalaTest on Android. ScalaTest will continue to treat java.awt.AWTError
s
in the same way: they cause the suite to abort rather than the test to fail, but checking is now done based on the string class name to avoid the explicit reference that
caused problems on Android.run
method in the org.scalatest
package object as an apply
method in an
org.scalatest.run
singleton
object. The client code and behavior are the same, but this implementation enabled the addition of a main
method as well that provides the "simple runner".main
method on the new
org.scalatest.run
singleton object. This application provides
a better out-of-box experience for users getting started with ScalaTest, and an easier to remember way to run tests from the command line for experienced ScalaTest users.-y
argument
to Runner
. Added a new lifecycle method to Suite
,
styleName
to support this feature. ScalaTest style traits override styleName
and return their fully qualified name as a string. If chosen styles is
defined, ScalaTest style traits that are not among the chosen list will abort with a message complaining that the style trait is not one of the chosen styles instead
of running its tests. Chosen styles is also supported by the ScalaTest ant task and ScalaTestFramework
(so accessible via sbt).
-q
, ScalaTest will only load and inspect class files whose
name ends in the suffix to see if they are runnable Suite
s. Also added a -Q
option to specify suffixes "Suite|Spec"
.
they
as an alternative to it
in org.scalatest.FlatSpec
and org.scalatest.fixture.FlatSpec
, org.scalatest.FunSpec
, org.scalatest.fixture.FunSpec
, and org.scalatest.path.FunSpec
. (This enhancement was inspired by a blog post
by Christoph Henkelmann.)ExampleSpec
rather than $read$$iw$$iw$$iw$$iw$ExampleSpec
.-c
to -P
, -r
to -C
, and -p
to -R
in Runner
and
ScalaTestAntTask
, and deprecated the old usages. After the deprecation cycle, will deprecate the capital forms in favor of lower case forms.
The goal is to have -p
mean parallel execution (currently -c
), -c
mean custom reporter (currently -r
), and
-r mean runpath (currently -p
). The new names will be more consistent and hopefully easier to remember.Bug fixes
TestRegistrationClosedException
.GeneratorDrivenPropertyChecks
were not reporting the given parameter names if they were
specified in combination with explicit generators passed to forAll
. Now they do.PropertyCheckException
s were not correctly modifying their message if used with withClue
. Now they do.Deprecations
org.scalatest.concurrent.Conductor
after moving a copy of it to trait Conductors
. The purpose of this move was so that
Conductor
could be configured via PatienceConfiguration
and scaled by ScaledTimeSpans
, making it consistent with
traits Eventually
and AsyncAssertions
.
org.scalatest.concurrent.ConductorMultiFixture
, which accidentally escaped deprecation in 1.5 when the other "multi fixture" traits
(in org.scalatest.fixture
) were deprecated.org.scalatest.DuplicateTestNameException
, org.scalatest.ModifiableMessage
, org.scalatest.NotAllowedException
, org.scalatest.StackDepth
, org.scalatest.StackDepthException
, org.scalatest.TestFailedException
, org.scalatest.TestPendingException
, org.scalatest.TestRegistrationClosedException
, org.scalatest.prop.DiscardedEvaluationException
, org.scalatest.prop.GeneratorDrivenPropertyCheckFailedException
, org.scalatest.prop.PropertyCheckFailedException
, org.scalatest.prop.TableDrivenPropertyCheckFailedException
. These deprecations
were to support moving most exception types to the new org.scalatest.exceptions
package. Old code using the old names will continue
to work during the deprecation phase. An org.scalatest.prop
package object was created to hold the deprecated type aliases for that package. This
package object will also be removed at the end of the deprecation period (unless it acquires a new, non-deprecated member in the meantime).Runner
arguments -r
, -c
, and -p
(and corresponding ScalaTestAntTask
syntax)
in favor of their new names (see the previous Enhancements section).
The old names will continue to work during the deprecation cycle.Removals
Runner
for -t
to run TestNG tests. This use of -t
was deprecated in 1.7 and replaced by -b
,
because in ScalaTest 2.0 -t
will be used to indicate a test name to run. To make sure the ground was clear for this new use
in ScalaTest 2.0, -t
will print an error message and abort the run in ScalaTest 1.8. If you haven't already, you'll have to change uses of
-t
to -b
to upgrade to ScalaTest 1.8.org.scalatest.exceptions.PropertyCheckException
by making it abstract. It was supposed
to be abstract, but as an oversight was left concrete. This is a breaking change that likely will not affect any users.styleName
method to AbstractSuite
and
overriding and making it final in many style traits. It was never intended that users would mix together core style traits, and likely it wouldn't compile in
many cases anyway. But now for sure it won't compile in most cases.
ScalaTest is brought to you by Bill Venners and Artima.
ScalaTest is free, open-source software
released under the Apache
2.0 license.
If your company loves ScalaTest, please consider sponsoring the project.
Copyright © 2009-2025 Artima, Inc. All Rights Reserved.