mirror of
https://github.com/corda/corda.git
synced 2025-06-17 14:48:16 +00:00
convert to nanos from seconds rather than milliseconds when parsing JUnit xml (#5666)
* convert to nanos from seconds rather than milliseconds * fix tests
This commit is contained in:
@ -328,7 +328,7 @@ public class TestDurationArtifacts {
|
|||||||
|
|
||||||
// If the test doesn't have a duration (it should), we return zero.
|
// If the test doesn't have a duration (it should), we return zero.
|
||||||
if (!(testName.isEmpty() || testClassName.isEmpty())) {
|
if (!(testName.isEmpty() || testClassName.isEmpty())) {
|
||||||
final long nanos = !testDuration.isEmpty() ? (long) (Double.parseDouble(testDuration) * 1000000.0) : 0L;
|
final long nanos = !testDuration.isEmpty() ? (long) (Double.parseDouble(testDuration) * 1_000_000_000.0) : 0L;
|
||||||
results.add(new Tuple2<>(testClassName + "." + testName, nanos));
|
results.add(new Tuple2<>(testClassName + "." + testName, nanos));
|
||||||
} else {
|
} else {
|
||||||
LOG.warn("Bad test in junit xml: name={} className={}", testName, testClassName);
|
LOG.warn("Bad test in junit xml: name={} className={}", testName, testClassName);
|
||||||
|
@ -38,7 +38,7 @@ public class TestDurationArtifactsTest {
|
|||||||
" </properties>\n");
|
" </properties>\n");
|
||||||
|
|
||||||
for (Tuple2<String, Long> test : tests) {
|
for (Tuple2<String, Long> test : tests) {
|
||||||
Double d = ((double) test.getSecond()) / 1_000_000;
|
Double d = ((double) test.getSecond()) / 1_000_000_000.0;
|
||||||
sb.append(" <testcase assertions=\"\" classname=\"" + CLASSNAME + "\" name=\""
|
sb.append(" <testcase assertions=\"\" classname=\"" + CLASSNAME + "\" name=\""
|
||||||
+ test.getFirst() + "\" status=\"\" time=\"" + d.toString() + "\">\n" +
|
+ test.getFirst() + "\" status=\"\" time=\"" + d.toString() + "\">\n" +
|
||||||
" <skipped/>\n" +
|
" <skipped/>\n" +
|
||||||
@ -67,7 +67,7 @@ public class TestDurationArtifactsTest {
|
|||||||
" </properties>\n");
|
" </properties>\n");
|
||||||
|
|
||||||
for (Tuple2<String, Long> test : tests) {
|
for (Tuple2<String, Long> test : tests) {
|
||||||
Double d = ((double) test.getSecond()) / 1_000_000;
|
Double d = ((double) test.getSecond()) / 1_000_000_000.0;
|
||||||
sb.append(" <testcase assertions=\"\" classname=\"" + CLASSNAME + "\" name=\""
|
sb.append(" <testcase assertions=\"\" classname=\"" + CLASSNAME + "\" name=\""
|
||||||
+ test.getFirst() + "\" status=\"\" time=\"\">\n" +
|
+ test.getFirst() + "\" status=\"\" time=\"\">\n" +
|
||||||
" <skipped/>\n" +
|
" <skipped/>\n" +
|
||||||
@ -88,8 +88,8 @@ public class TestDurationArtifactsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void fromJunitXml() {
|
public void fromJunitXml() {
|
||||||
List<Tuple2<String, Long>> tests = new ArrayList<>();
|
List<Tuple2<String, Long>> tests = new ArrayList<>();
|
||||||
tests.add(new Tuple2<>("TEST-A", 111_000_000L));
|
tests.add(new Tuple2<>("TEST-A", 111_000_000_000L));
|
||||||
tests.add(new Tuple2<>("TEST-B", 222_200_000L));
|
tests.add(new Tuple2<>("TEST-B", 222_200_000_000L));
|
||||||
final String xml = getXml(tests);
|
final String xml = getXml(tests);
|
||||||
|
|
||||||
List<Tuple2<String, Long>> results
|
List<Tuple2<String, Long>> results
|
||||||
@ -100,9 +100,9 @@ public class TestDurationArtifactsTest {
|
|||||||
Assert.assertFalse("Should have results", results.isEmpty());
|
Assert.assertFalse("Should have results", results.isEmpty());
|
||||||
Assert.assertEquals(results.size(), 2);
|
Assert.assertEquals(results.size(), 2);
|
||||||
Assert.assertEquals(CLASSNAME + "." + "TEST-A", results.get(0).getFirst());
|
Assert.assertEquals(CLASSNAME + "." + "TEST-A", results.get(0).getFirst());
|
||||||
Assert.assertEquals(111_000_000L, results.get(0).getSecond().longValue());
|
Assert.assertEquals(111_000_000_000L, results.get(0).getSecond().longValue());
|
||||||
Assert.assertEquals(CLASSNAME + "." + "TEST-B", results.get(1).getFirst());
|
Assert.assertEquals(CLASSNAME + "." + "TEST-B", results.get(1).getFirst());
|
||||||
Assert.assertEquals(222_200_000L, results.get(1).getSecond().longValue());
|
Assert.assertEquals(222_200_000_000L, results.get(1).getSecond().longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user