android-junit5
android-junit5 copied to clipboard
"Expected N+1 tests, received N" caused by fun with @TestTemplate
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.