RFR: 7903752: Include duration information in JUnit-based tests
Jaikiran Pai
jpai at openjdk.org
Thu Jun 13 10:46:27 UTC 2024
On Thu, 13 Jun 2024 09:37:42 GMT, Christian Stein <cstein at openjdk.org> wrote:
> Please review this change to include duration information in JUnit-based tests.
>
> For example, see this excerpt from a `.jtr` file generated for the `JupiterTests` self-test.
>
> Before:
>
> #section:junit
> ...
> ----------System.err:(21/1306)----------
> STARTED JupiterTests::nullEmptyAndBlankStrings '[1] test('null')'
> SUCCESSFUL JupiterTests::nullEmptyAndBlankStrings '[1] test('null')'
> STARTED JupiterTests::nullEmptyAndBlankStrings '[2] test('')'
> SUCCESSFUL JupiterTests::nullEmptyAndBlankStrings '[2] test('')'
> ...
>
> After:
>
> #section:junit
> ...
> ----------System.err:(21/1306)----------
> STARTED JupiterTests::nullEmptyAndBlankStrings '[1] test('null')'
> SUCCESSFUL JupiterTests::nullEmptyAndBlankStrings '[1] test('null')' [24ms]
> STARTED JupiterTests::nullEmptyAndBlankStrings '[2] test('')'
> SUCCESSFUL JupiterTests::nullEmptyAndBlankStrings '[2] test('')' [1ms]
> ...
Hello Christian, the proposed change looks good to me, especially the way it is reported.
Would you want to also include this same thing for testng too? Here's what I experimented for testng:
diff --git a/src/share/classes/com/sun/javatest/regtest/agent/TestNGRunner.java b/src/share/classes/com/sun/javatest/regtest/agent/TestNGRunner.java
index 713b12e..d32dbec 100644
--- a/src/share/classes/com/sun/javatest/regtest/agent/TestNGRunner.java
+++ b/src/share/classes/com/sun/javatest/regtest/agent/TestNGRunner.java
@@ -185,12 +185,13 @@ public class TestNGRunner implements MainActionHelper.TestRunner {
} else {
suffix = "\n";
}
-
+ long durationMillis = itr.getEndMillis() - itr.getStartMillis();
System.out.print(k.toString().toLowerCase()
+ " " + itr.getMethod().getConstructorOrMethod().getDeclaringClass().getName()
+ "." + itr.getMethod().getMethodName()
+ formatParams(itr)
+ ": " + statusToString(itr.getStatus())
+ + " [" + durationMillis + "ms]"
+ suffix);
}
and testng tests with jtreg now report as follow (similar to junit):
test LargeEntriesTest.testForceZIP64End(java.util.ImmutableCollections$MapN at 1398b884, 8): success [141ms]
test LargeEntriesTest.testForceZIP64End(java.util.ImmutableCollections$MapN at 1caef225, 0): success [5ms]
test LargeEntriesTest.testForceZIP64End(java.util.ImmutableCollections$MapN at 2a2df4a5, 8): success [4ms]
test LargeEntriesTest.testForceZIP64End(java.util.ImmutableCollections$MapN at 85ce7c1, 0): success [3ms]
test LargeEntriesTest.testJar({create=true}, 8): success [5121ms]
test LargeEntriesTest.testJar(java.util.ImmutableCollections$MapN at 34771e2b, 0): success [3029ms]
test LargeEntriesTest.testJar(java.util.ImmutableCollections$MapN at 27fb5d9f, 8): success [4333ms]
test LargeEntriesTest.testZip({create=true}, 8): success [3944ms]
test LargeEntriesTest.testZip(java.util.ImmutableCollections$MapN at 62272fdb, 0): success [2638ms]
test LargeEntriesTest.testZip(java.util.ImmutableCollections$MapN at 6f1bd253, 8): success [4138ms]
-------------
PR Comment: https://git.openjdk.org/jtreg/pull/206#issuecomment-2165287240
More information about the jtreg-dev
mailing list