Working with Scala Tests
IntelliJ IDEA lets you create and run the following Scala tests:
- string constants
- constructions like immutable string variables
In this section:
Creating Scala Tests
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.
- Open the class of interest in the editor.
- Place the cursor within the line containing the class declaration.
- On the context menu, choose .
- If the target test doesn't exist, you are prompted to create it.
- In the Create Test dialog specify the necessary information and click OK.
Running a Scala Test
- Open your test file.
- In the Editor enter your code, right-click on the class and from the context menu, select Run 'test name'.
- 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
- Click .
- View the the result in the Structure Tool Window.