From f9e49cf712e8f3444e82b0fa4845442a0b7d3ddb Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Thu, 3 Feb 2022 05:14:59 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> --- .../agent/rt/internal/CoverageTransformerTest.java | 11 ++++++++--- .../jacoco/agent/rt/internal/ExceptionRecorder.java | 3 +-- org.jacoco.core/src/org/jacoco/core/JaCoCo.java | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/CoverageTransformerTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/CoverageTransformerTest.java index 2f1a6cdce5..a16e70dbac 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/CoverageTransformerTest.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/CoverageTransformerTest.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.jacoco.agent.rt.internal; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -214,11 +215,15 @@ public void testTransformFailure() { protectionDomain, null); fail("IllegalClassFormatException expected."); } catch (IllegalClassFormatException e) { - assertTrue(e.getMessage(), e.getMessage() - .startsWith("Error while instrumenting org.jacoco.Sample")); + assertEquals(String.format( + "Error while instrumenting %s with JaCoCo %s/%s.", + "org.jacoco.Sample", JaCoCo.VERSION, JaCoCo.COMMITID_SHORT), + e.getMessage()); } recorder.assertException(IllegalClassFormatException.class, - "Error while instrumenting org.jacoco.Sample", + String.format("Error while instrumenting %s with JaCoCo %s/%s.", + "org.jacoco.Sample", JaCoCo.VERSION, + JaCoCo.COMMITID_SHORT), IOException.class); recorder.clear(); } diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/ExceptionRecorder.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/ExceptionRecorder.java index 20dd14951f..b756b992d2 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/ExceptionRecorder.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/ExceptionRecorder.java @@ -14,7 +14,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; /** * {@link IExceptionLogger} implementation for testing purposes. @@ -51,7 +50,7 @@ public void assertException(final Class exceptionType, public void assertException(final Class exceptionType, final String message, final Class causeType) { assertEquals(exceptionType, this.exceptionType); - assertTrue(this.message, this.message.startsWith(message)); + assertEquals(message, this.message); assertEquals(causeType, this.causeType); } diff --git a/org.jacoco.core/src/org/jacoco/core/JaCoCo.java b/org.jacoco.core/src/org/jacoco/core/JaCoCo.java index 42bccf1c3c..6a07341c7f 100644 --- a/org.jacoco.core/src/org/jacoco/core/JaCoCo.java +++ b/org.jacoco.core/src/org/jacoco/core/JaCoCo.java @@ -19,7 +19,7 @@ */ public final class JaCoCo { - /** Version of JaCoCo core. */ + /** Qualified version of JaCoCo core. */ public static final String VERSION; /** Commit ID of the source tree of JaCoCo core. */