From f7e0ce6f0b2aa58a8c7540d399cba68763bbf55c Mon Sep 17 00:00:00 2001 From: Stefano Franz Date: Mon, 4 Nov 2019 15:17:57 +0000 Subject: [PATCH] convert to nanos from seconds rather than milliseconds when parsing JUnit xml (#5666) * convert to nanos from seconds rather than milliseconds * fix tests --- .../net/corda/testing/TestDurationArtifacts.java | 2 +- .../net/corda/testing/TestDurationArtifactsTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/groovy/net/corda/testing/TestDurationArtifacts.java b/buildSrc/src/main/groovy/net/corda/testing/TestDurationArtifacts.java index 173c8fcbbe..103bae6939 100644 --- a/buildSrc/src/main/groovy/net/corda/testing/TestDurationArtifacts.java +++ b/buildSrc/src/main/groovy/net/corda/testing/TestDurationArtifacts.java @@ -328,7 +328,7 @@ public class TestDurationArtifacts { // If the test doesn't have a duration (it should), we return zero. 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)); } else { LOG.warn("Bad test in junit xml: name={} className={}", testName, testClassName); diff --git a/buildSrc/src/test/groovy/net/corda/testing/TestDurationArtifactsTest.java b/buildSrc/src/test/groovy/net/corda/testing/TestDurationArtifactsTest.java index 021b220e4e..c2a079771d 100644 --- a/buildSrc/src/test/groovy/net/corda/testing/TestDurationArtifactsTest.java +++ b/buildSrc/src/test/groovy/net/corda/testing/TestDurationArtifactsTest.java @@ -38,7 +38,7 @@ public class TestDurationArtifactsTest { " \n"); for (Tuple2 test : tests) { - Double d = ((double) test.getSecond()) / 1_000_000; + Double d = ((double) test.getSecond()) / 1_000_000_000.0; sb.append(" \n" + " \n" + @@ -67,7 +67,7 @@ public class TestDurationArtifactsTest { " \n"); for (Tuple2 test : tests) { - Double d = ((double) test.getSecond()) / 1_000_000; + Double d = ((double) test.getSecond()) / 1_000_000_000.0; sb.append(" \n" + " \n" + @@ -88,8 +88,8 @@ public class TestDurationArtifactsTest { @Test public void fromJunitXml() { List> tests = new ArrayList<>(); - tests.add(new Tuple2<>("TEST-A", 111_000_000L)); - tests.add(new Tuple2<>("TEST-B", 222_200_000L)); + tests.add(new Tuple2<>("TEST-A", 111_000_000_000L)); + tests.add(new Tuple2<>("TEST-B", 222_200_000_000L)); final String xml = getXml(tests); List> results @@ -100,9 +100,9 @@ public class TestDurationArtifactsTest { Assert.assertFalse("Should have results", results.isEmpty()); Assert.assertEquals(results.size(), 2); 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(222_200_000L, results.get(1).getSecond().longValue()); + Assert.assertEquals(222_200_000_000L, results.get(1).getSecond().longValue()); } @Test