Skip to content

Commit

Permalink
Cutting test names at the first '(' or '['.
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemen committed Jun 19, 2018
1 parent 437b3b0 commit 7aa0817
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -42,6 +42,7 @@ public final class TestXmlDisplayer {
private static final File[] NO_FILES = new File[0];
private static final String NEW_LINE_PATTERN = Pattern.quote("\n");
private static final String[] STACKTRACE_PREFIXES = {"at "};
private static final char[] TEST_NAME_TERMINATE_CHARS = "([".toCharArray();

private final Project project;
private final JavaExtension javaExt;
Expand Down Expand Up @@ -203,6 +204,17 @@ public boolean displayReport(Lookup runContext) {
return displayReport(runContext, reportFiles);
}

private static String extractTestMethodName(String testName) {
int minIndex = Integer.MAX_VALUE;
for (char endCh: TEST_NAME_TERMINATE_CHARS) {
int index = testName.indexOf(endCh);
if (index >= 0 && index < minIndex) {
minIndex = index;
}
}
return minIndex >= testName.length() ? testName : testName.substring(0, minIndex);
}

public class JavaRerunHandler implements RerunHandler {
private final Lookup rerunContext;

Expand All @@ -219,7 +231,7 @@ public void rerun() {
private List<SpecificTestcase> getSpecificTestcases(Set<Testcase> tests) {
List<SpecificTestcase> result = new ArrayList<>(tests.size());
for (Testcase test: tests) {
String name = test.getName();
String name = extractTestMethodName(test.getName());
String testClassName = test.getClassName();

if (name != null && testClassName != null) {
Expand Down

0 comments on commit 7aa0817

Please sign in to comment.