Can I use test balloon and JUnit 4 tests in the sa...
# testballoon
e
Can I use test balloon and JUnit 4 tests in the same module?
o
Yes.
👍🏼 1
e
I decided to migrate one by one tests. And I can not run junit4 test now
gradle test task doesn’t pick junit4 (at least I don’t see it log)
If I try to use IDE plugin I get
Copy code
Execution failed for task ':core:common:test'.
> No tests found for given includes: [*TestBalloonGradleGuardPattern, com.google.samples.apps.nowinandroid.core.common.result.ResultKtTest, TestBalloonJUnit4](--tests filter)
I applied test balloon plugin for the module
o
This example is showing side-by-side JUnit4/TestBalloon tests.
e
Oke, don’t see any significant difference
Ah, except it is not android module but plain kotlin one
o
JUnit 4 is only available for Android targets. On a non-Android JVM, TestBalloon would use JUnit Platform to interface with Gradle.
e
Oke, so for jvm you can not have it side by side
o
There it's side-by-side with JUnit 5.
e
Oke, let me add junit5 to verify
But is it as designed? I would say it would be nice not to force junit5
o
You could use JUnit Vintage to include JUnit 4 on the JVM.
JUnit 4 is not well supported outside Android.
e
Yeah, that what I’m doing now. I was just thinking - you don’t need to do it for Android modules.
o
Yes. KMP offers different targets for Android and JVM. So TestBalloon configures itself to the best supported interface on each of them (JUnit 4 on Android, JUnit Platform on JVM). Doing more would have required an extra artifact and demand more configuration awareness from users.
e
Clear. Adding junit5 - restored run of junit4 tests.
o
Also, JUnit 4 does not provide an out-of-the-box mechanism for operating different frameworks side-by-side. TestBalloon jumps through hoops to make that possible.
If there is anything where the current configuration is not good enough, feel free to add an issue with a specific use case, and we can re-evaluate possible solutions.
e
One more observation - run of one test JUnit4 and test balloon is reported as magnitude of 10x (~0.005s and ~0.05s). Nothing to worry about, but interesting. Also wonder if it is a fair/correct measurement.
o
Oh, Gradle-reported test times are almost never accurate. First, it ignores the timestamps present in reported test events and uses its own (processing) times instead. On top of that, it becomes particularly silly if you use parallel invocation, where Gradle just adds up individual test times, so the reported total time can be like weeks when in fact it was minutes. This is independent of the test framework used. IIRC, Duncan featured this in one of his videos on YT (@PairingWithDuncan). For accurate times, just use your own custom report like here.
e
Thanks!