1.6.1 includes all the enhancements listed in the ScalaTest 1.5 release notes, plus a few other enhancements relative to 1.5:
BeforeAndAfter
trait and deprecated BeforeAndAfterEachFunctions
and BeforeAndAfterAllFunctions
.
The BeforeAndAfterEach/AllFunctions
traits were added in ScalaTest 1.3. They were deprecated for two reasons. One is that the trait names were too long. The other was that BeforeAndAfterEachFunctions
has a beforeEach
method that takes one parameter, and so does BeforeAndAfterEach
. If these two traits were mixed together there was an (extremely unlikely) chance you could accidentally invoke the wrong beforeEach
. BeforeAndAfter
replaces BeforeAndAfterEachFunctions
, with before
replacing beforeEach
. If you used BeforeAndAfterEachFunctions
, you can get rid of the deprecation warning by changing your code to use BeforeAndAfter
instead. If you used BeforeAndAfterAllFunctions
, you can get rid of the deprecation warning by changing your code to use BeforeAndAfterAll
instead.
MultipleFixtureXXX
traits in the fixture
package.
The MultipleFixtureXXX
traits were deprecated because because using explicit conversions to implement multiple fixtures yields more readable code than using implicit conversions. You can continue to use the implicit conversion approach if you wish, of course. To get rid of the deprecation warning, change "MultipleFixtureXXX
" to "FixtureXXX with ConfigMapFixture
".
Version 1.5.1 has the same features as version 1.6.1, but ScalaTest works on Scala 2.8.1+ whereas ScalaTest 1.6.1 works on Scala 2.9.0+. See the release notes for ScalaTest 1.6.1 for information on the enhancements this release contains on top of ScalaTest 1.5.
whenExecuting
in EasyMockSugar
so that it takes a single var arg of mock objects instead of one mock object followed by a second var arg of optional mock objects. The original goal was to make it a compiler error to not pass no mock objects. But a user who had a list of mock objects (say, named mocks
) wanted to say whenExecuting(mocks: _*)
, and could not. I decided it was better to make that situation easy and just allow the error of passing no mocks to when executing to become a runtime error. Since this method will most likely be called inside test code, that error would simply result in a test failure. This change breaks binary compatibility, but not source code, unless someone was using named parameters in an invocation of whenExecuting
, which is unlikely). So a simple recompile should suffice.failedCodeFileName
and failedCodeLineNumber
methods to the StackDepth
trait. These are implemented already, so should be source (and even binary) compatible, unless you have a method of that name already in a custom exception you made that extends StackDepth
. Likely no one does.failureOf
method in a FailureOf
trait. This method executes a passed block of code. If no exception is thrown it returns a None
. Else if it is one of the exceptions that normally causes a test to fail in ScalaTest (all but some Error
types), it returns that exception wrapped in a Some
.TableFor1
through TableFor22
, which host tables of data on which property checks can be performed. Added a TableDrivenPropertyChecks
trait that provides convenient factory methods for creating tables and checking properties against them. Fleshed out a PropertyCheckFailedException
hierarchy, adding PropertyCheckFailedException
,TableDrivenPropertyCheckFailedException
, and GeneratorDrivenPropertyCheckFailedException
(deprecated PropertyTestFailedException
in favor of the name GeneratorDrivenPropertyCheckFailedException
).FunSuite
or FixtureFunSuite
.Iterable
and Collection
into Traversable
in ScalaTest matchers. This was the final step in bringing matchers up to date with Scala 2.8. In the process, some classes that implement the matchers DSL were renamed. This will be a breaking change only if someone did something that used those explicit names, which is highly unlikely. For example, the name of implicit conversion convertIterableMatcherToArrayMatcher
was changed to convertTraversableMatcherToArrayMatcher
. Most people would be using that implicitly, so the name change won't break code. Anyone who just used the ScalaTest matchers DSL, and did not attempt to explicitly use its internals, will only need to recompile. In the process, ScalaTest's matchers became more general. Where before they were only working with Iterables
, they now they work with Traversables
.Suite
self type from Checkers
, and made a Checkers
companion object that mixes in the Checkers
trait: the self-less trait pattern.compose
on many types that extend function, narrowing the result type to the ScalaTest type. For example, overrode compose[U]
on Matcher[T]
, which extends (T => MatchResult)
, and narrowed the result type to Matcher[U]
. This way when you compose a Matcher
and a function, you get a Matcher
back. Also did this on BeMatcher
, BePropertyMatcher
, and HavePropertyMatcher
.Informer
extend (String => Unit)
, the function type it always felt it was at heart.Matcher
with a factory method that allows you to create a Matcher[T]
from a passed function of type (T => MatchResult)
.BeMatcher
with a factory method that allows you to create a BeMatcher[T]
from a passed function of type (T => MatchResult)
.BePropertyMatcher
with a factory method that allows you to create a BePropertyMatcher[T]
from a passed function of type (T => MatchResult)
.toNoArgTest
method to OneArgTest
, to make it easier to delegate to an inherited implementation of the form of withFixture
that takes a NoArgTest
.Suites
class that takes a variable length arg of suites to nest. Made SuperSuite
extend this, and deprecated SuperSuite
. Suites
is a much clearer name, and I'd like to use "SuperSuite
" and "SuperSpec
" as the suggested name of a trait or class that mixes in your favorite things.Specs
class that performs the same function as Suites
, but sounds more BDDish.org.scalatest.BeforeAndAfter
trait, which had been deprecated since 1.0.groups
method from Suite
, which had been deprecated since 1.0.org.scalatest.Group
class, which had been deprecated since 1.0.org.scalatest.Report
class, which had been deprecated since 1.0.org.scalatest.SpecReport
class, which had been deprecated since 1.0.failedTestCodeStackDepth
and failedTestCodeFileNameAndLineNumberString
methods from StackDepth
and its descendants. These had both been deprecated since 1.0.Rerunnable
, which had been deprecated since 1.0.TagAnnotation
for tagging methods of Suite
. As of 1.5 any annotations that aren't themselves annotated with org.scalatest.TagAnnotation
will not be interpretted as tags. Interpretting arbitrary annotations as tags had been deprecated since 1.0.runNestedSuites
and tests in runTests
after the stopper returns true. The current test or nested suite running when the stop flag is set to true will continue, but will be the last, when running sequentially. When running tests in parallel, more than one may be currently running, which means more than one may continue to completion before the flag is again checked, after which it will stop. A Stopper
is a polite request to stop, so some implementations of Suite
may not stop right away once a stop is requested, but prior to this release, most traits in ScalaTest kept right on going after a stop was requested.FunSuite
and FixtureFunSuite
would result in a failed test rather than an IllegalArgumentException
.PropertyCheckFailedExceptions
read more nicely in the GUI Reporter.StackDepthException
by adding a new constructor. Moved the formerly primary constructor, which took an Option[String]
message, Option[Throwable]
cause, and Int
failedCodeStackDepth
, to be an auxiliary constructor. The new primary constructor takes functions that produce a message and the stack depth. This allows the calculation of these to be delayed. One reason is to avoid doing the processing to find the stack depth an build the string if it is never used, which can happen, for example, during a shrink phase of a failed property check. It also enables the message to include the failed code file name and line number. Also added one other auxiliary constructor, and modified TestFailedException
, NotAllowedException
, DuplicateTestNameException
, TestRegistrationClosedException
, but left the previous primary constructor as an auxiliary contructor in each case, so existing code will not break. (New exceptions PropertyTestFailedException
, TableDrivenPropertyTestFailedException
, and GeneratorDrivenPropertyTestFailedException
also take the same functions.)FeatureSpec
and FixtureFeatureSpec
so they include "Scenario:"
. Given this FeatureSpec
:
class MySpec extends FeatureSpec { feature("Remote control mute button") { scenario("Mute button pressed when TV not muted") {} scenario("Mute button pressed when TV is muted") {} } }
The test names prior to 1.5 would have been:
Feature: Remote control mute button Mute button pressed when TV is muted Feature: Remote control mute button Mute button pressed when TV not muted
And in 1.5 they are:
Feature: Remote control mute button Scenario: Mute button pressed when TV is muted Feature: Remote control mute button Scenario: Mute button pressed when TV not muted
This is a breaking change if anyone has written code that depends on those test name strings. It is unlikely anyone has done that, but if so, the fix is to insert "Scenario: "
between the feature part and the scenario part of the test name.
Suite
and replaced them with one execute method that takes parameters with default argument values. This will not break source code unless you invoked the overloaded form of execute that takes a config map only. I figure it is unlikely anyone has done that, because config maps are used rarely and execute is likely most often called from an interpreter command not source code. If this does strike you, however, my apologies. The fix is to change this:
mySuite.execute(myConfigMap)
to this:
mySuite.execute(configMap = myConfigMap)
At the call site.
In addition to testName
and configMap
, which you could pass to execute prior to 1.5, in 1.5 you can also configure the run with parameters color
, durations
, shortstacks
, fullstacks
, and stats
. See the Scaladoc documenation for execute for details on these parameters.
Suite
, FunSuite
, JUnit3Suite
, JUnitSuite
, and TestNGSuite
.Spec
and WordSpec
.'S'
configuration option for reporters that selects short stack traces. This option can be specified to Runner
, the ant task, and sbt via the ScalaTestFramework
implementation.PropSpec
and FreeSpec
, including sister traits in the fixture package: FixturePropSpec
, FixtureFreeSpec
, MultipleFixturePropSpec
, and MultipleFixtureFreeSpec
.Suite.run
. This was done to allow tools vendors to implement these types in Java. This could be a breaking change if a user used any of these types as a function. That is very unlikely, but just in case, also added implicit conversions from each type to the corresponding function type. This affected traits Reporter
, Stopper
, and Distributor
.org.scalatest.Shell
and an org.scalatest
package object that implements "the ScalaTest shell," its DSL for the Scala interpreter.SuiteStarting/Completed/Aborted
events are fired. This makes the output when running with sbt consistent with the output when running via the Runner
with the standard out reporter. (Mainly, you get the simple name of the suite class at the top, terminated by a colon.)
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.