I can run:
run
run...
run/debug configuration
> + > junit > test kind = all in package
> search for tests = in whole project
But if I do the same as (2) with a scala test (+ > scala test > test kind...) the first test fails very strangely (it seems an object
is not instantiated) while the same test pass if I run it using (1) or (3)
Config:
Bonus question: how to run all tests (junit and scalatest)?
Open the test in the editor, press Ctrl+Shift+F10 or right-click on the test class and from the context menu select Run 'test name'. IntelliJ IDEA creates a run/debug configuration for the test automatically, but if you want to edit settings in your configuration, click Run | Edit Configurations on the main menu.
IntelliJ now allows you to create a run configuration for an SBT task. You create the Run Configuration by : choosing "Edit configurations" from the "Run" menu (or the toolbar popup) click the "+" button to add a configuration and select "SBT Task" as the type of configuration you want to make.
ScalaTest is one of the main testing libraries for Scala projects, and in this lesson you'll see how to create a Scala project that uses ScalaTest. You'll also be able to compile, test, and run the project with sbt.
After you have an sbt build – one you created yourself or from a template – follow these steps to import the project into IntelliJ IDEA: From the Welcome Screen or File menu, select Open. Browse to and select the top-level folder of your sbt project, and click OK. The Import Project from SBT dialog opens.
Add your Scala source code under the src/main/scala folder, add your tests under the src/test/scala folder, and then run the tests with the SBT test command:
IntelliJ IDEA displays results in the sbt shell window. Use the sbt settings to configure the build and run actions the sbt project, an sbt version, importing of the project's changes, and so on. Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment| sbt.
ScalaTest support in the IntelliJ Scala plugin The IntelliJ Scala plugin comes with good ScalaTest support, including: Running ScalaTest suite by right-clicking on the source Showing the run results in a format that mirrors the structure of the suite/specification
ScalaTest uses its own thread pool to run ParallelTestExecution suites, its pool size is determined by the following formula: To see classpath that sbt uses to lookup for test classes, you can use the following command: You can pass arguments to ScalaTest by using testOptions and Tests.Argument in your sbt build file:
You should be able to right click on the root directory of the project and click Run "All Tests"
. This recursively searches for tests in your project, and will run the tests in each module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With