How to run tests in IntelliJ

I don’t really understand how to run the tests from IntelliJ.
Sometimes it works, and sometimes intelliJ doesn’t find any tests to run.

If I click the mouse on the name of the test file AccumulatorSuite in the file directory widget, and active “Run ‘AccumulatorSuite’”, then it runs the tests in that file.

However, if I click on “Run All Tests”, then I get the message “No tests were found”.
As I understand, the fact that the test/scala directory appears in green means IntelliJ knows it is a test directory.

And it tells me to use the module “cl-robdd-scala-build”.

I don’t know what a “module” is.

Does anyone have any suggestions ?

Screenshot 2020-04-29 at 16.11.24

1 Like

Don’t have an answer for you but a module in IntelliJ is any any top level directory that has one or more of its subdirectories market as a source or test source directory. Go to “System settings” to see the list of modules. For any source/test directory right click on the node. On the bottom of the context menu you will find a “Mark directory as”. Select that and choose the appropriate type. Make sure you have your tests marked as such.

As for the tests use sbt or mill. You can use JUnit, Scalatest, etc. You also have the option to select which tests to run. For example by class name, test name or module. Note that not all selection options are available for all unit testing frameworks.

A word of warning - finding tests is dependent on directory structure, which in turn is different for different build tools (Mill does have sbt compatibility mode).

HTHs

To run all tests in a folder, select this folder in the Project tool window and press Ctrl+Shift+F10 or select Run Tests in ‘folder’ from the …We can run our unit tests with Maven by using the clicker counter command: mvn clean test. When we run this command at command prompt, we should see that the Maven Surefire Plugin runs our unit tests. We can now create a Maven project that compiles and runs unit tests which use JUnit 5