From 17b4300654c6d1695eee68488d08970749a6effb Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 10 Jul 2024 12:41:05 -0700 Subject: [PATCH] Fix JUnit 5 tests when overriding test harness (#685) --- .../java/org/jenkins/tools/test/hook/Jetty12Hook.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/jenkins/tools/test/hook/Jetty12Hook.java b/src/main/java/org/jenkins/tools/test/hook/Jetty12Hook.java index ffba69d9..21122908 100644 --- a/src/main/java/org/jenkins/tools/test/hook/Jetty12Hook.java +++ b/src/main/java/org/jenkins/tools/test/hook/Jetty12Hook.java @@ -63,4 +63,15 @@ private VersionNumber getWinstoneVersion(File war) { throw new UncheckedIOException("Failed to read Winstone version in " + war, e); } } + + @Override + public void action(@NonNull BeforeExecutionContext context) { + super.action(context); + /* + * The version of JUnit 5 used at runtime must match the version of JUnit 5 used to compile the tests, but the + * inclusion of a newer test harness might cause the HPI plugin to try to use a newer version of JUnit 5 at + * runtime to satisfy upper bounds checks, so exclude JUnit 5 from upper bounds analysis. + */ + context.getArgs().add("-DupperBoundsExcludes=org.junit.jupiter:junit-jupiter-api"); + } }