ScalaTest Release Notes

Changes in 1.6.1 (for Scala 2.9.x)

1.6.1 includes all the enhancements listed in the ScalaTest 1.5 release notes, plus a few other enhancements relative to 1.5:

  • Reworked some of the Scaladoc documentation, particularly the documentation on how to use shared fixtures to make clearer the intent and tradeoffs of each way of doing shared fixtures
  • Added the 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.
  • Deprecated the 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".

Changes in 1.5.1 (for Scala 2.8.1)

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.

Changes in 1.5 (for Scala 2.8.1)

  • Changed the method signature of 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.
  • Added 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.
  • Added 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.
  • Added 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).
  • Enhanced the standard out/error reporters, and the reporters used with sbt, so they show truncated stacktraces if available even if the exception contains or is a "cause" exception. Previously if a cause existed, full stack traces were always displayed.
  • Fixed tiny little display bug which caused "duplicate test name" to show up twice in the error message when duplicate tests were discovered in a FunSuite or FixtureFunSuite.
  • Made 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.
  • Dropped the Suite self type from Checkers, and made a Checkers companion object that mixes in the Checkers trait: the self-less trait pattern.
  • Overrode 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.
  • Made Informer extend (String => Unit), the function type it always felt it was at heart.
  • Added a companion object for Matcher with a factory method that allows you to create a Matcher[T] from a passed function of type (T => MatchResult).
  • Added a companion object for BeMatcher with a factory method that allows you to create a BeMatcher[T] from a passed function of type (T => MatchResult).
  • Added a companion object for BePropertyMatcher with a factory method that allows you to create a BePropertyMatcher[T] from a passed function of type (T => MatchResult).
  • Added a toNoArgTest method to OneArgTest, to make it easier to delegate to an inherited implementation of the form of withFixture that takes a NoArgTest.
  • Created a 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.
  • Created a Specs class that performs the same function as Suites, but sounds more BDDish.
  • Removed org.scalatest.BeforeAndAfter trait, which had been deprecated since 1.0.
  • Removed groups method from Suite, which had been deprecated since 1.0.
  • Removed org.scalatest.Group class, which had been deprecated since 1.0.
  • Removed org.scalatest.Report class, which had been deprecated since 1.0.
  • Removed org.scalatest.SpecReport class, which had been deprecated since 1.0.
  • Removed the failedTestCodeStackDepth and failedTestCodeFileNameAndLineNumberString methods from StackDepth and its descendants. These had both been deprecated since 1.0.
  • Removed trait Rerunnable, which had been deprecated since 1.0.
  • Removed ScalaTestTask, which had been deprecated since 1.0.
  • Started requiring 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.
  • Stop running nested suites in 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.
  • Fixed bug whereby passing in a non-existing test name to run on FunSuite and FixtureFunSuite would result in a failed test rather than an IllegalArgumentException.
  • Insert line breaks where they should be in the GUI reporter's message display. This made PropertyCheckFailedExceptions read more nicely in the GUI Reporter.
  • Enhanced 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.)
  • Changed the test names in 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.

  • Removed four overloaded execute methods on 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.

  • Enhanced TDD-style traits so that they send formatted events. Previously only BDD-style traits sent formatted events. This change affects the output of Suite, FunSuite, JUnit3Suite, JUnitSuite, and TestNGSuite.
  • Enhanced style traits that allow nesting so that the output shows up nested as well. Previously all style traits flattened their output to at most one level of indentation. This change affects the output of Spec and WordSpec.
  • Previously you could choose between short and full stack traces in reporters that printed strings (such as the standard out reporter). Added an option in 1.5 to show no stack trace for stack depth exceptions, and made this the default. Added a '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.
  • Added two new style traits, PropSpec and FreeSpec, including sister traits in the fixture package: FixturePropSpec, FixtureFreeSpec, MultipleFixturePropSpec, and MultipleFixtureFreeSpec.
  • Severed the inheritance relationship between function types and several of the traits passed to 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.
  • Added the org.scalatest.Shell and an org.scalatest package object that implements "the ScalaTest shell," its DSL for the Scala interpreter.
  • Enhanced sbt integration so that 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-2019 Artima, Inc. All Rights Reserved.

artima