ScalaTest User Guide

Getting started

Selecting testing styles

Defining base classes

Writing your first test

Using assertions

Tagging your tests

Running your tests

Sharing fixtures

Sharing tests

Using matchers

Testing with mock objects

Property-based testing

Asynchronous testing

Using Scala-js

Using Inside

Using OptionValues

Using EitherValues

Using PartialFunctionValues

Using PrivateMethodTester

Using WrapWith

Philosophy and design

Migrating to 3.0

Using ScalaTest with Mill

ScalaTest's Framework supports using ScalaTest from Mill. The following is an example test project you can add in your

object test extends ScalaTests with TestModule.ScalaTest  {
  def ivyDeps = Agg(

Running Tests

Your test source files go into src. You can run all of them from the command prompt with:

> ./mill test

If you want to run particular suites, you can use testOnly and provide their fully qualified names in a space separated list:

> ./mill test.testOnly org.acme.RedSuite org.acme.BlueSuite

Or you can specify a glob:

> ./mill test.testOnly *RedSuite

To run only tests affected by your latest code changes, either in main or test, you can use testCached:

> ./mill test.testCached

Specifying ScalaTest Arguments

You can pass arguments to ScalaTest after the test command:

> ./mill test -oD

If you are using testCached, you may also specify testCachedArgs in your

def testCachedArgs = Seq("-oD")

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-2024 Artima, Inc. All Rights Reserved.