ShouldMatchers and MustMatchers traits, plus many supporting classes
and traits.SpecReport in the GUI, so that SpecReports get displayed in
a specification style. This makes org.scalatest.Spec output look nicer in the GUI,
and also makes it possible for org.specs.Specification to send SpecReports that will
look nice in the ScalaTest GUI.TestFailedException, which allows a stack trace depth to be sent along with
test failures. This allows reports to highlight the exactly filename and line number at which a test
failed. This makes it quicker for users to find the cause of the problem. Enhanced everything to
send TestFailedExceptions where possible.TestFailedException,
which was not being propagated to the reporters before.FunSuite and Spec were not sending Rerunnables in
reports even though they could, which made rerunning not work in some cases in the GUI. They now send
a Rerunnable whenever they can.SpecDasher from the API, which also is no longer mixed in by Spec.
The only reason this was included in 0.9.4 was that it was demonstrated in Programming in
Scala. It still works and can be used, so if you liked it, you can just grab it from
0.9.4 and mix it in yourself as a local mix in.ImpSuite to BeforeAndAfter. ImpSuite remains for now but is marked as deprecated. In
a future release of ScalaTest ImpSuite will be dropped, so please rename your uses of ImpSuite to BeforeAndAfter
as soon as convenient. The reason this was changed is that the "Imp" stood for imperative, because the trait facilitates an imperative style
of testing. Also "imp" in English means "little devil," which projected a good attitude, because one goal of ScalaTest is to encourage users to adopt
a more functional style for fixture "setup" and "teardown." But it's a bit too cute and its meaning not obvious enough from its name. Plus mixing
an ImpSuite into a Spec felt like mixing metaphors.expect and intercept constructs from Suite
into their own trait, named Assertions. Suite now mixes in this trait, so that it has the same functionality as
before. The main reason this was done was so that these constructs could more easily be used outside of ScalaTest Suites, and also
so the trait could be extended by ScalaTest's matchers. (ScalaTest's matchers are not yet released, but will probably make their debut in
ScalaTest version 0.9.5.) This allows ScalaTest's matchers to assume these constructs exist, and makes it easier to use ScalaTest matchers
independently from ScalaTest Suites.intercept that takes an implicit Manifest, so that you need not explicitly pass
a class instance anymore. Thus, instead of saying this:
intercept(classOf[StringIndexOutOfBoundsException]) {
"hi".charAt(-1)
}
You can write:
intercept[StringIndexOutOfBoundsException] {
"hi".charAt(-1)
}
The old style that requires an explicit class instance are still in the API, but they are deprecated. They will be removed in some future
release of ScalaTest, so please start migrating to the new style. There are a few corner cases where the new form can't be used, which
are caused by overloading ambiguities with the old style. The two corners are passing an explicit null to intercept and throwing
an explicit exception such that the inferred type of the by-name parameter is Nothing. It is unlikely anyone would do that
anyway, and these two issues will resolve themselves once the deprecated old-style intercept methods are removed.
Spec. This trait is inspired by Ruby's RSpec BDD tool.PropSuite to FunSuite in org.scalatest.prop. This was done because it made sense
to add the extra ScalaCheck methods to Spec as well, so it seemed
more reasonable to just have traits with the same name in two different packages. So there would be a FunSuite and Spec
in both org.scalatest and org.scalatest.prop. The latter batch would already mix
in Checkers and offer the extra ScalaCheck property-taking methods, and of course, have a dependency on ScalaCheck. Thus,
PropSuite was deprecated, but it is left in the API for the time being to avoid client code breakage. PropSuite
will go away in a future release. Later, the traits that had the extra property-taking methods were judged not worth their weight, so
ScalaTest 0.9.4 does not include a Spec in package org.scalatest.prop.
However because an example using org.scalatest.prop.FunSuite was included in Programming in Scala, it was included
in 0.9.4, already deprecated. Both PropSuite and FunSuite will be removed from the org.scalatest.prop
package in a future ScalaTest release, so please start migrating to use org.scalatest.FunSuite, mixing in Checkers
and passing properties to ScalaCheck with check, as shown in this example.SpecDasher trait. This may or may not be a good idea, but
an example of the "dashes" style it enables was shown in Programming in Scala, so it was included in 0.9.4, but deprecated. It may stay or go in
a future release, depending on user feedback. Currently, Spec already mixes SpecDasher in by default, but if
it ends up staying in the API, this connection will almost certainly be severed so that users must explicitly mix it in to get the "dashes" style.
So use it with caution, but even if it is removed, if you like it you can always just add the code for it to your own project and
use it that way.SpecReport, a subclass of Report. Specs emit SpecReports when they run, and
the print reporters (standard out, err, file, etc.) recognize them and generate specification-like output. In this release the graphic
reporter does not handle SpecReport's specially, so the output looks like regular test output. In a future release the graphic
reporter will generate a specification-like output. One use case for SpecReports is integration with Eric Torreborre's specs
tool, however one piece still remains for that integration. Specs (and JUnit and TestNG) generate nested test output, whereas ScalaTest's
model is flat. In a future version ScalaTest's Report class will be enhanced to support nested reports. This will enable
specs tests run through ScalaTest to provide nice nested, specification-like reports.ExecuteAndRun trait. The purpose of this trait is to pull out abstract method signatures for execute and
runTest (and later if it turns out to be useful, runNestedSuites and runTests) so they can be
called by traits that have Suite as their self type, but extend ExecuteAndRun not Suite, such
as BeforeAndAfter. This makes such traits stackable behaviors that can be mixed into a Suite while not
being a Suite themselves.testWithInformer and ignoreWithInformer methods from FunSuite, because they were
simply too ugly to live. Unfortunately these were not deprecated, so if you used them you'll need to already make an adjustment to upgrade
to 0.9.4. What replaced them is an imperative approach, which while more error prone will work fine unless abused, and makes
for much nicer client code. There's a new method named info in FunSuite, which returns an Informer.
So where before you said:
testWithInformer("test name") {
info => {
info("send info to the reporter")
}
}
Now you'll just say:
test("test name") {
info("send info to the reporter")
}
During suite execution, the info method returns an Informer that immediately forwards information passed to its apply
methods to the reporter. During construction of the object, the info method returns an Informer that saves the information
passed to its apply methods for later sending to the reporter when the suite is executed. At any other time, the info
method will return an Informer that throws an exception.
FunSuite from the org.scalatest.fun to org.scalatest package.FunSuite1 through FunSuite9, which were also in the org.scalatest.fun package, because the surface area
they added to the API didn't seem worth the small savings in code size over creating "with" methods with meaningful
names and explicitly calling them.ImpSuite, which can be mixed into another suite to gain methods that will run before and after each suite and test.Suite and FunSuite that discuss mutable fixtures. Dropped
the suggestion to override runTest, which still works but is verbose, and instead recommended defining and explicitly calling "create" methods or
"with" methods from tests that need the mutable fixtures, or mixing in ImpSuite and using beforeEach, afterEach, etc.Informer trait, which provides a simpler way to send information to the infoProvided
method of a Reporter.Suite such that instead of being able to define test methods that take a Reporter, you can define
test methods that take an Informer. Replaced the section of scaladoc for Suite that used to explain how to
use a passed-in Reporter to now show how to use an Informer.FunSuite such that instead of being able to register tests whose function values take a Reporter, you can register
tests whose function values take an Informer. Changed the names of the registration methods from test/ignoreWithReporter to
test/ignoreWithInformer. Replaced the section of scaladoc for FunSuite that used to explain how to
use a Reporter passed in to a test function to now show how to use an Informer.org.scalatest.scalacheck.CheckSuite to org.scalatest.prop.Checkers, and renamed its checkProperty
methods to plain old check.PropSuite, a subtrait of FunSuite, which offers methods that register tests composed of a single property check.assert(... === ...) and expect(...){...} methods. Strings are now reported surrounded
by double quotes, with ends truncated where matching if very long, and with square brackets surrounding the portions that differ. Characters are reported
surrounded by single quotes, integer and floating point numbers as is, and any other object's toString result surrounded by angle brackets.Suite's scaladoc that describes using external assertions, such as JUnit's assertions, Hamcrest
matchers, or specs matchers, in ScalaTest tests.Runner from org.scalatest to org.scalatest.tools package.org.scalatest.junit.org.scalatest.testng.org.scalatest.scalacheck.FunSuite family of traits in package org.scalatest.fun.testGroups method name to groups.===, from expected === actual to left === right.2 === 1, from "Expected 1, but got 2" to "2 did not equal 1".expect method name to intercept.expectNPE and expectIAE methods.expect method, which takes an expected and actual value. expect(1) {2} would generate
the error message "Expected 1, but got 2.expect and intercept that take a message.Suite discovery mechanism in Runner, accessed via -m or -w
command-line arguments.!== method from the great Equalizer.
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.