ScalaTest User Guide

Writing your first test

Using assertions

Tagging your tests

Running your tests

Sharing fixtures

Sharing tests

Using matchers

Testing with mock objects

Tests as specifications

Property-based testing

Other goodies

Philosophy and design

Selecting a style

This user guide will help you get rolling quickly with ScalaTest. First a brief orientation:

  • The central concept in ScalaTest is the suite, a collection of zero to many tests.
  • A test can be anything with a name that can start and either succeed or fail.
  • The design of ScalaTest is embodied in trait Suite, which represents a suite of tests.
  • Trait Suite declares run and nine other “lifecycle” methods that define a default way to write and run tests.
  • The lifecycle methods can be overriden to define custom ways of writing and running tests.
  • ScalaTest offers several style traits that override lifecycle methods to support different styles of testing, such as TDD, BDD, and acceptance testing.

This user guide shows how to write tests primarily using FunSuite, a style trait for test-driven development (TDD). ScalaTest is very consistent, so the concepts you learn about FunSuite will apply if you later decide to use a different style trait. For information about other styles, this user guide will point you to the Scaladoc documentation. ScalaTest has extensive Scaladoc documention that includes tutorials with many examples that can help you get moving quickly using any style.

Now, get started by writing your first test.

ScalaTest is brought to you by Bill Venners, with contributions from several other folks. It is sponsored by Artima, Inc.
ScalaTest is free, open-source software released under the Apache 2.0 license.

Copyright © 2009-2011 Artima, Inc. All Rights Reserved.

artima