diff --git a/java/src/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlags.java b/java/src/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlags.java index ad30e98023b..44a1e7416e6 100644 --- a/java/src/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlags.java +++ b/java/src/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlags.java @@ -205,7 +205,7 @@ static String testFilterForClassAndMethods( } String methodNamePattern = concatenateMethodNames(methodFilters, jUnitVersion); if (Strings.isNullOrEmpty(methodNamePattern)) { - if (jUnitVersion == JUnitVersion.JUNIT_4 || jUnitVersion == JUnitVersion.JUNIT_5) { + if (jUnitVersion == JUnitVersion.JUNIT_4) { output.append('#'); } return output.toString(); diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java index e5850428c71..2329d40ada2 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java @@ -196,8 +196,9 @@ public void testConfigurationCreatedFromAbstractClass() throws Throwable { assertThat(blazeConfig.getTargets()) .containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:TestClass")); + String junit4Hash = (jUnitVersionUnderTest == JUnitVersion.JUNIT_4 ? "#" : ""); assertThat(getTestFilterContents(blazeConfig)) - .isEqualTo(BlazeFlags.TEST_FILTER + "=com.google.test.TestClass#"); + .isEqualTo(BlazeFlags.TEST_FILTER + "=com.google.test.TestClass" + junit4Hash); } @Test diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java index 035bbc7cf1c..29f78577c60 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java @@ -27,6 +27,7 @@ import com.google.idea.blaze.base.model.primitives.TargetExpression; import com.google.idea.blaze.base.model.primitives.WorkspacePath; import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration; +import com.google.idea.blaze.java.run.producers.BlazeJUnitTestFilterFlags.JUnitVersion; import com.google.idea.blaze.base.run.producers.TestContextRunConfigurationProducer; import com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState; import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager; @@ -69,7 +70,9 @@ public void testProducedFromPsiFile() throws Throwable { (BlazeCommandRunConfiguration) fromContext.getConfiguration(); assertThat(config.getTargets()) .containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:TestClass")); - assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=com.google.test.TestClass#"); + String junit4Hash = (jUnitVersionUnderTest == JUnitVersion.JUNIT_4 ? "#" : ""); + assertThat(getTestFilterContents(config)) + .isEqualTo("--test_filter=com.google.test.TestClass" + junit4Hash); assertThat(config.getName()).isEqualTo("Bazel test TestClass"); assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST); } @@ -94,7 +97,9 @@ public void testProducedFromPsiClass() throws Throwable { (BlazeCommandRunConfiguration) fromContext.getConfiguration(); assertThat(config.getTargets()) .containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:TestClass")); - assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=com.google.test.TestClass#"); + String junit4Hash = (jUnitVersionUnderTest == JUnitVersion.JUNIT_4 ? "#" : ""); + assertThat(getTestFilterContents(config)) + .isEqualTo("--test_filter=com.google.test.TestClass" + junit4Hash); assertThat(config.getName()).isEqualTo("Bazel test TestClass"); assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST); } diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java index c696b1f3cb5..bb455e3e916 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java @@ -284,8 +284,14 @@ public void testProducedFromTestFiles() throws Throwable { // THEN expect config to be correct assertThat(config.getTargets()) .containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:allTests")); + String junit4Hash = (jUnitVersionUnderTest == JUnitVersion.JUNIT_4 ? "#" : ""); assertThat(getTestFilterContents(config)) - .isEqualTo("--test_filter=\"com.google.test.TestClass1#|com.google.test.TestClass2#\""); + .isEqualTo( + "--test_filter=\"com.google.test.TestClass1" + + junit4Hash + + "|com.google.test.TestClass2" + + junit4Hash + + "\""); assertThat(config.getName()).isEqualTo("Bazel test TestClass1 and 1 others"); assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST); } diff --git a/java/tests/unittests/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlagsTest.java b/java/tests/unittests/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlagsTest.java index a8d8d5e2a0a..6da8d6725b0 100644 --- a/java/tests/unittests/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlagsTest.java +++ b/java/tests/unittests/com/google/idea/blaze/java/run/producers/BlazeJUnitTestFilterFlagsTest.java @@ -44,7 +44,7 @@ public void testSingleJUnit5ClassFilter() { assertThat( BlazeJUnitTestFilterFlags.testFilterForClassAndMethods( "com.google.idea.ClassName", JUnitVersion.JUNIT_5, ImmutableList.of(), null)) - .isEqualTo("com.google.idea.ClassName#"); + .isEqualTo("com.google.idea.ClassName"); } @Test @@ -82,7 +82,7 @@ public void testParameterizedIgnoredForSingleClassJUnit5() { JUnitVersion.JUNIT_5, ImmutableList.of(), ParameterizedTestInfo.create("ignored", "-ignored"))) - .isEqualTo("com.google.idea.ClassName#"); + .isEqualTo("com.google.idea.ClassName"); } @Test