I had this issue when by accident marking src
directory as source (even though src/test/java
was correctly marked as test directory).
Instead of this, src/main/java
directory has to be marked as "source" and /src/test/java
directory has to be marked as test, and "src" directory should be unmarked.