Sbt test does not actually run any tests

I’ve been running tests mostly in IDEs (both Eclipse and IntelliJ) and they both work fine. However, I’ve noticed that if I try running tests from sbt shell with test, nothing happens. Here’s what it looks like:

[example] $ test
[success] Total time: 1 s, completed Jun 4, 2021 11:33:21 AM

I then tried testOnly with testOnly com.example.MyTestClass and that didn’t work either. Here’s what it looks like:

[example] $ testOnly com.example.MyTestClass
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] No tests to run for Test / testOnly

I’m using sbt 1.5.2 and I’m using Play for Java with scalaVersion := "2.13.5".

Does anyone know what’s going on here?

So here’s a little more info.

I have 2 projects with very similar setups and the build.sbt files look pretty much identical. One big difference is that one project has a ton of test files, ans it’s that project that has this issue. The smaller project does not have this issue. Is it possible that having too many test files is the problem?

This sometimes happens to me as well. No idea why.

sbt clean usually resolves the issue

Yes, try sbt clean.

Thanks for the suggestion. I have tried sbt clean multiple times, including deleting the generated directories and it didn’t help.

Ok try removing all target directories in all sub projects. In the project root run the below.
(CAREFUL where you run the below!!! it rm -rf all target directories from current dir down). Also delete the tmp directory in the project root.

find . -name target -type d -exec rm -rf {} ;

I just tried that and it didn’t help :see_no_evil: