android-junit5 icon indicating copy to clipboard operation
android-junit5 copied to clipboard

"Expected N+1 tests, received N" caused by fun with @TestTemplate

Open mgroth0 opened this issue 1 year ago • 0 comments

I was getting "Expected N+1 tests, received N" errors, and at first it was very difficult to find the cause. After a thorough investigation I found that:

  • The "Expected N+1 tests, received N" error was only happening for android instrumented Junit5 tests.
  • Did not occur for regular JVM Junit5 tests or android Junit 5 unit tests
  • Only occured when a certain top-level function was on the classpath with a signature like:
@TestTemplate fun someFunction() {}

If I comment out @TestTemplate above, the problem goes away.

For context, note that someFunction above was just some scrap code I through somewhere when I was messing around and forget to get rid of. It is located in a common test dependency that is shared by JVM desktop, android unit tests, and android instrumented tests. It never caused any issue until I set up android-junit5 for my instrumented tests.

mgroth0 avatar Feb 24 '24 18:02 mgroth0