From 54bc491d41b0e568ff44292b6354596c307b07b6 Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Fri, 10 Jul 2026 09:32:19 -0700 Subject: [PATCH] PUBLIC: Stop flagging `@Ignore` on JUnit3 tests. Internally, we've made our legacy JUnit3 runner skip tests with `@Ignore` (unknown commit). Externally, basically nobody uses JUnit3 anymore (and if someone does make this mistake, they'll quickly notice anyways). PiperOrigin-RevId: 945750863 --- .../bugpatterns/JUnit4ClassUsedInJUnit3.java | 5 +-- .../JUnit4ClassUsedInJUnit3Test.java | 40 ------------------- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3.java b/core/src/main/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3.java index 7be3a59889f..c6f2eef4d43 100644 --- a/core/src/main/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3.java +++ b/core/src/main/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3.java @@ -66,10 +66,7 @@ public Description matchAnnotation(AnnotationTree tree, VisitorState state) { if (!enclosingClass(isJUnit3TestClass).matches(tree, state)) { return NO_MATCH; } - // If we are inside a JUnit3 test class some annotation should not appear. - if (isType("org.junit.Ignore").matches(tree, state)) { - return makeDescription("@Ignore", tree); - } + // If we are inside a JUnit3 test class some annotations should not appear. if (isType("org.junit.Rule").matches(tree, state)) { return makeDescription("@Rule", tree); } diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3Test.java b/core/src/test/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3Test.java index 21aa2fdb302..fbdca15484b 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3Test.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/JUnit4ClassUsedInJUnit3Test.java @@ -197,46 +197,6 @@ public void testName3() {} .doTest(); } - @Test - public void positive_ignore_on_test() { - compilationHelper - .addSourceLines( - "Foo.java", - """ - import junit.framework.TestCase; - import org.junit.Ignore; - - public class Foo extends TestCase { - public void testName1() {} - - // BUG: Diagnostic contains: @Ignore - @Ignore - public void testName2() {} - } - """) - .doTest(); - } - - @Test - public void positive_ignore_on_class() { - compilationHelper - .addSourceLines( - "Foo.java", - """ - import junit.framework.TestCase; - import org.junit.Ignore; - - // BUG: Diagnostic contains: @Ignore - @Ignore - public class Foo extends TestCase { - public void testName1() {} - - public void testName2() {} - } - """) - .doTest(); - } - @Test public void positive_rule_in_junit3() { compilationHelper