IntelliJ IDEA 2016.2 Help

Working with Scala Tests

IntelliJ IDEA lets you create and run the following Scala tests:

IntelliJ IDEA supports the following methods in Scala tests:
  • string constants
  • constructions like immutable string variables
  • concatenation
  • substring
  • stripSuffix
  • stripPrefix
  • toLowerCase
  • replace
  • trim

In this section:

Creating a Scala Test

Before you start creating Scala tests, make sure you have the appropriate scala test dependency version added to your SBT project or you have the appropriate test library downloaded to your regular Scala project. You can use Project Structure dialog for these purposes.


  1. Open the class of interest in the editor.
  2. Place the cursor within the line containing the class declaration.
  3. On the context menu, choose Go to | Test.
  4. If the target test doesn't exist, you are prompted to create it.
  5. In the Create Test dialog specify the necessary information and click OK.

Running Scala Tests

  1. Open your test file.
  2. In the Editor enter your code, right-click on the class and from the context menu, select Run 'test name'.
  3. The result is displayed in the Test Runner tab of the Run tool window.

You can also run the tests inside the scope for scalaTest.

Check the following example:


If you open context menu for one of the tests inside the scope, you can create a Run/Debug configuration just for the specified test inside that scope.

You can run the test and view the output inside the Run tool window.

If you open a context menu for the whole scope, you can create a Run/Debug configuration for all the tests inside the scope.

You can run the test for the whole scope and view the output inside the Run tool window.

Viewing a Scala Test File Structure

  1. Click View | Tool Windows | Structure.
  2. View the result in the Structure Tool Window.

See Also

Last modified: 23 November 2016