Why Does Intellij Idea Suddenly Not Recognize Tests in Test Folder Anymore

Why does Intellij IDEA suddenly not recognize tests in test folder anymore?

OK, I fixed it.

In menu, under File, there is an invalidate cache option. That fixed it!

Running a unit test after changing it does not run the updated test in IntelliJ

Snap

In Run Configuration, add Build Project so that it picks up latest changes

How do I make IntelliJ IDEA run all the tests in a package including sub packages

The default key combination to run all tests is Ctrl+Shift+F10

IntelliJ does not refresh Spring autoconfigurations in multi-module tests when running all tests

Answering my own question for posterity. This is a partial answer that assumes that all your modules share the same root package. In my case, all the modules share a.b.c where the first module's package is a.b.c.first, the second module is a.b.c.second and so on. If you have a better solution I'll happily change the accepted answer.

The problem, as suspected, is how you define the test configuration. Since this is a multi-module project, and I want all the tests to run, there are two ways of defining it:

The problematic way: Defining a pattern on the entire project. This solution is described in this StackOverflow answer.

running all tests with a pattern

Running this configuration will cause the problems described in the question - unrelated auto-configurations of dependencies the module doesn't have will start to fail and therefore the tests will fail as well.

The way that works: This way works under the said assumption that all modules share the same package. Create a new Run Configuration as follows:

run all tests under a shared package

  • Test kind: All in package
  • Package: The share root package of all your modules, e.g. a.b.c in the example I gave in the beginning of this answer.
  • Search for tests: In whole project

This will run all your tests with the correct auto-configurations.



Related Topics



Leave a reply



Submit