diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java index de220a7b724574..9f670c14783433 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/BazelJavaSemantics.java @@ -158,7 +158,8 @@ private String getMainClassFromRule(RuleContext ruleContext) { } private boolean isExperimentalJavaTest(RuleContext ruleContext) { - return TargetUtils.isTestRule(ruleContext.getRule()) + return ruleContext.attributes().has("$experimental_testsupport") + && TargetUtils.isTestRule(ruleContext.getRule()) && getMainClassFromRule(ruleContext).equals(EXPERIMENTAL_TEST_RUNNER_MAIN_CLASS); }