mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
comparison failure: match when one pattern per failure (IDEA-131329)
This commit is contained in:
+6
-3
@@ -18,7 +18,6 @@ package com.intellij.rt.execution.testFrameworks;
|
||||
import com.intellij.rt.execution.junit.ComparisonFailureData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -33,8 +32,12 @@ public class AbstractExpectedPatterns {
|
||||
protected static ComparisonFailureData createExceptionNotification(String message, List patterns) {
|
||||
for (int i = 0; i < patterns.size(); i++) {
|
||||
final Matcher matcher = ((Pattern)patterns.get(i)).matcher(message);
|
||||
if (matcher.matches()) {
|
||||
return new ComparisonFailureData(matcher.group(1).replaceAll("\\\\n", "\n"), matcher.group(2).replaceAll("\\\\n", "\n"));
|
||||
if (matcher.find()) {
|
||||
String expected = matcher.group(1).replaceAll("\\\\n", "\n");
|
||||
String actual = matcher.group(2).replaceAll("\\\\n", "\n");
|
||||
if (!matcher.find()) {
|
||||
return new ComparisonFailureData(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -25,6 +25,12 @@ public class JUnitExpectedPatternsTest {
|
||||
Assert.assertNotNull(ExpectedPatterns.createExceptionNotification("arrays first differed at element [0]; expected: java.lang.String<Text> but was: java.lang.StringBuilder<Text>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiplePatternsInOneAssertion() {
|
||||
Assert.assertNull(ExpectedPatterns.createExceptionNotification("line1 expected:<java.lang.String<Text>> but was:<java.lang.StringBuilder<Text>>\n" +
|
||||
"line2 expected:<java.lang.String<Text1>> but was:<java.lang.StringBuilder<Text1>>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHamcrestAssertThatWithReason() {
|
||||
Assert.assertNotNull(ExpectedPatterns.createExceptionNotification("reason\n" +
|
||||
|
||||
@@ -27,13 +27,13 @@ public class ExpectedPatterns extends AbstractExpectedPatterns {
|
||||
|
||||
private static final String[] PATTERN_STRINGS = new String[]{
|
||||
"\nexpected: is \"(.*)\"\n\\s*got: \"(.*)\"\n",
|
||||
".*?\nexpected: is \"(.*)\"\n\\s*but: was \"(.*)\"",
|
||||
".*?\nexpected: (.*)\n\\s*got: (.*)",
|
||||
".*?\\s*expected same:<(.*)> was not:<(.*)>",
|
||||
".*?\\s*expected:<(.*?)> but was:<(.*?)>",
|
||||
"\nexpected: is \"(.*)\"\n\\s*but: was \"(.*)\"",
|
||||
"\nexpected: (.*)\n\\s*got: (.*)",
|
||||
"expected same:<(.*)> was not:<(.*)>",
|
||||
"expected:<(.*?)> but was:<(.*?)>",
|
||||
"\nexpected: \"(.*)\"\n\\s*but: was \"(.*)\"",
|
||||
"\\s*expected: (.*)\\s*but: was (.*)",
|
||||
".*?\\s*expected: (.*)\\s*but was: (.*)"
|
||||
"expected: (.*)\\s*but: was (.*)",
|
||||
"expected: (.*)\\s*but was: (.*)"
|
||||
};
|
||||
|
||||
private static final String MESSAGE_LENGTH_FOR_PATTERN_MATCHING = "idea.junit.message.length.threshold";
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.testng;
|
||||
|
||||
import com.intellij.rt.execution.testFrameworks.AbstractExpectedPatterns;
|
||||
import com.intellij.rt.execution.junit.ComparisonFailureData;
|
||||
import com.intellij.rt.execution.testFrameworks.AbstractExpectedPatterns;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -25,12 +25,12 @@ class TestNGExpectedPatterns extends AbstractExpectedPatterns {
|
||||
private static final List PATTERNS = new ArrayList();
|
||||
|
||||
private static final String[] PATTERN_STRINGS = new String[]{
|
||||
".*expected same with:\\<(.*)\\> but was:\\<(.*)\\>",
|
||||
".*expected:\\<(.*)\\> but was:\\<(.*)\\>",
|
||||
".*expected \\[(.*)\\] but got \\[(.*)\\]",
|
||||
".*expected not same with:\\<(.*)\\> but was same:\\<(.*)\\>",
|
||||
".*expected \\[(.*)\\] but found \\[(.*)\\]",
|
||||
".*\nExpected: .*?\"(.*)\"\n\\s*but: .*?\"(.*)\""
|
||||
"expected same with:\\<(.*)\\> but was:\\<(.*)\\>",
|
||||
"expected:\\<(.*)\\> but was:\\<(.*)\\>",
|
||||
"expected \\[(.*)\\] but got \\[(.*)\\]",
|
||||
"expected not same with:\\<(.*)\\> but was same:\\<(.*)\\>",
|
||||
"expected \\[(.*)\\] but found \\[(.*)\\]",
|
||||
"\nexpected: .*?\"(.*)\"\n\\s*but: .*?\"(.*)\""
|
||||
};
|
||||
|
||||
static {
|
||||
|
||||
Reference in New Issue
Block a user