ScalaTest User Guide
Selecting testing styles
Defining base classes
Writing your first test
Tagging your tests
Running your tests
Testing with mock objects
Philosophy and design
Migrating to 2.0
Using ScalaTest with Eclipse
For Eclipse users, ScalaTest offers a powerful plugin that provides seamless support for testing in the Scala IDE for Eclipse. Not only does this plugin give Scala programmers the level of test-framework/IDE integration that Java programmers have enjoyed with JUnit, it goes quite a bit farther:
You can use the plugin with any release of ScalaTest, but you'll enjoy the most seamless IDE integration if you use ScalaTest 2.2.1. You can plug it into the latest stable release of the Scala IDE for Eclipse (version 3.0.x). For a nightly build, you'll need to build it by hand by following the steps given in https://github.com/scalatest/scalatest-eclipse-plugin
Screenshot of ScalaTest Eclipse Plugin with ScalaTest 2.2.1
Installing the ScalaTest Eclipse Plugin
You can install the plugin together with Scala IDE using latest update sites listed at http://scala-ide.org/. For Scala IDE 3.0.x, tick 'ScalaTest for Scala IDE' as shown in the figure below:
Information on the features of the integration (and some screenshots (and the source code)) is here:
A video demo of the plugin that I gave back at ScalaDays is here:
Info on ScalaTest 2.2.1 is here:
With the release notes for ScalaTest 2.2.1 here:
Using ScalaTest in a Scala project
To use ScalaTest in your Scala project, you must download ScalaTest and include it in build path of your project.
You can use any ScalaTest 1.x release or the latest 2.2.1 (recommended). Using ScalaTest 2.0 enables the following:
When using ScalaTest 1.x, the GUI Runner provided by ScalaTest will be used instead of the built-in test result view.
Running a Selected Suite
To run a selected suite, you can select the suite using 2 different ways:-
After you choose the target suite element, just right click and choose:-
Run As -> ScalaTest - Suite
A Run Configuration with the suite name will be created automatically.
Running a Selected Test
To run a selected test, click on the target test element in the editor, right click and choose:-
Run As -> ScalaTest - Test
A Run Configuration with the test name will be created automatically.
Running a Selected Scope
To run a selected scope, click on the target scope element in the editor, right click and choose:-
Run As -> ScalaTest - Test
A Run Configuration with the scope name will be created automatically.
Running All Suites in a Selected File
To run all ScalaTest suites in a selected file, you can select the file using 2 different ways:
After you choose the target Scala source file, just right click and choose:-
Run As -> ScalaTest - File
All ScalaTest suites in the selected Scala source file will be run.
A Run Configuration with the file name will be created automatically.
Running All Suites in Selected Package
To run all ScalaTests suites in a package, you can right click on a package in Project Explorer and choose:-
Run As -> ScalaTest Package
All ScalaTest suites in the selected package (not nested package) will be run. To include ScalaTest suites in nested packages, you'll need to select the 'Include Nested' option in the Run Configuration.
A Run Configuration with the package name will be created automatically.
Run Configuration Types
ScalaTest is brought to you by Bill Venners, with
contributions from several other folks. It is sponsored by
ScalaTest is free, open-source software released under the Apache 2.0 license.
Copyright © 2009-2013 Artima, Inc. All Rights Reserved.