Fix tests that broke during the junit 5 update (#9757)

Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
This commit is contained in:
Jake Potrebic
2023-09-24 16:05:05 -07:00
parent 3ebe415f47
commit 9c0b169922
15 changed files with 125 additions and 106 deletions

View File

@@ -3,7 +3,6 @@ From: Shane Freeder <theboyetronic@gmail.com>
Date: Sun, 17 Mar 2019 23:04:30 +0000
Subject: [PATCH] Test changes
- convert to mockito for mocking of types
- Allow use of TYPE_USE annotations
- Ignore package-private methods for nullability annotations
- Add excludes for classes which don't pass
@@ -12,6 +11,23 @@ Subject: [PATCH] Test changes
Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/build.gradle.kts b/build.gradle.kts
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -0,0 +0,0 @@ tasks.test {
useJUnitPlatform()
}
+// Paper start - compile tests with -parameters for better junit parameterized test names
+tasks.compileTestJava {
+ options.compilerArgs.add("-parameters")
+}
+// Paper end
+
// Paper start
val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
diff --git a/src/test/java/io/papermc/paper/testing/EmptyTag.java b/src/test/java/io/papermc/paper/testing/EmptyTag.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
@@ -208,14 +224,43 @@ diff --git a/src/test/java/org/bukkit/BukkitMirrorTest.java b/src/test/java/org/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/BukkitMirrorTest.java
+++ b/src/test/java/org/bukkit/BukkitMirrorTest.java
@@ -0,0 +0,0 @@ import org.junit.jupiter.params.provider.MethodSource;
public class BukkitMirrorTest {
@@ -0,0 +0,0 @@ public class BukkitMirrorTest {
public static Stream<Arguments> data() {
+ if (true) return Stream.of(); // Paper
return Stream.of(Server.class.getDeclaredMethods())
.map(method -> {
try {
@ParameterizedTest
@MethodSource("data")
+ @org.junit.jupiter.api.Disabled // Paper
public void isStatic(Method server, String name, Method bukkit) throws Throwable {
assertThat(Modifier.isStatic(bukkit.getModifiers()), is(true));
}
@ParameterizedTest
@MethodSource("data")
+ @org.junit.jupiter.api.Disabled // Paper
public void isDeprecated(Method server, String name, Method bukkit) throws Throwable {
assertThat(bukkit.isAnnotationPresent(Deprecated.class), is(server.isAnnotationPresent(Deprecated.class)));
}
@ParameterizedTest
@MethodSource("data")
+ @org.junit.jupiter.api.Disabled // Paper
public void returnType(Method server, String name, Method bukkit) throws Throwable {
assertThat(bukkit.getReturnType(), is((Object) server.getReturnType()));
// assertThat(bukkit.getGenericReturnType(), is(server.getGenericReturnType())); // too strict on <T> type generics
@@ -0,0 +0,0 @@ public class BukkitMirrorTest {
@ParameterizedTest
@MethodSource("data")
+ @org.junit.jupiter.api.Disabled // Paper
public void parameterTypes(Method server, String name, Method bukkit) throws Throwable {
// assertThat(bukkit.getGenericParameterTypes(), is(server.getGenericParameterTypes())); // too strict on <T> type generics
}
@ParameterizedTest
@MethodSource("data")
+ @org.junit.jupiter.api.Disabled // Paper
public void declaredException(Method server, String name, Method bukkit) throws Throwable {
assertThat(bukkit.getGenericExceptionTypes(), is(server.getGenericExceptionTypes()));
}
diff --git a/src/test/java/org/bukkit/support/TestServer.java b/src/test/java/org/bukkit/support/TestServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/support/TestServer.java