Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop adding a trailing # when filtering tests for JUnit 5 #7060

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down