Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit5 generates a negative execution time for test case unexpectedly #363

Open
ZzhengSyna opened this issue Jan 10, 2025 · 2 comments
Open

Comments

@ZzhengSyna
Copy link

This should be a rare scenario, I haven't seen it before.
Basically I was running a JUnit5 test on an android S device, using ./gradlew connectedDebugAndroid. Inside my test project, there are 9 cases, each is run with @RepeatedTest(9), so if everything goes well, there should be 81 cases in total.

Now I ran this suite for multiple times, and met twice of the below issue:
During my test, something goes wrong(should be a bug in the android system), from the console log of the android device, I can see the android system crashed with a Kernel panic. So the test suite was terminated, somehow, the xml test file was still generated and pulled to the computer.

From the generated xml test report, I can see something like this:

<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 1 of 9" time="109.09"/>
<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 2 of 9" time="107.962"/>
<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 3 of 9" time="107.832"/>
<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 4 of 9" time="108.991"/>
<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 5 of 9" time="107.835"/>
<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 6 of 9" time="107.884"/>
<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 7 of 9" time="107.725"/>
<testcase classname="com.xxx.MainTest" name="testFrameDropTunnelModeEnabled: repetition 8 of 9" time="-1.73649439603E9"/>
<testcase classname="com.xxx.MainTest" name="testVerticalTunnelModeEnabled: repetition 1 of 9" time="21.424"/>
<testcase classname="com.xxx.MainTest" name="testVerticalTunnelModeEnabled: repetition 2 of 9" time="20.345"/>
<testcase classname="com.xxx.MainTest" name="testVerticalTunnelModeEnabled: repetition 3 of 9" time="-1.736494169664E9"/>

Note the two special execution time: time="-1.73649439603E9" and time="-1.736494169664E9".
This is unexpected, I think JUnit should set them as failure or error?

The plugins I'm using:

// In project level build.grale
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.6.0.0'
// In app level build.gradle
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArgument "runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder"

...

androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.2.0"

If additional info is required, please kindly let me know.

@ZzhengSyna ZzhengSyna changed the title JUnit5 generates a negative execution time for test case unexpected JUnit5 generates a negative execution time for test case unexpectedly Jan 10, 2025
@ZzhengSyna
Copy link
Author

Find a similar xml result:

<testcase classname="com.xyz.MainTest" name="testDolbyVisionTunnelModeEnabled: repetition 12 of 90" time="20.314"/>
<testcase classname="com.xyz.MainTest" name="testDolbyVisionTunnelModeEnabled: repetition 13 of 90" time="22.07"/>
<testcase classname="com.xyz.MainTest" name="testDolbyVisionTunnelModeEnabled: repetition 14 of 90" time="20.162"/>
<testcase classname="com.xyz.MainTest" name="testDolbyVisionTunnelModeEnabled: repetition 15 of 90" time="-1.736740711497E9"/>
</testsuite>

@ZzhengSyna
Copy link
Author

Found again:

<testcase classname="com.xyz.MainTest" name="testVerticalTunnelModeEnabled: repetition 28 of 90" time="20.22"/>
<testcase classname="com.xyz.MainTest" name="testVerticalTunnelModeEnabled: repetition 29 of 90" time="20.2"/>
<testcase classname="com.xyz.MainTest" name="testVerticalTunnelModeEnabled: repetition 30 of 90" time="20.195"/>
<testcase classname="com.xyz.MainTest" name="testVerticalTunnelModeEnabled: repetition 31 of 90" time="20.194"/>
<testcase classname="com.xyz.MainTest" name="testVerticalTunnelModeEnabled: repetition 32 of 90" time="-1.736757829469E9"/>
</testsuite>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant