-
-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Labels
Description
Hey,
we are using this library for asserting the content of JSON responses in our functional tests. Apart from a few minor issues, this is working great. So thanks for your effort!
After updating from version 3 to version 4, the output of the PHPMatcherConstraint
got a lot more verbose. It looks like the output includes a backtrace now, if an assertion fails. If more than one test fails, this makes things hard to grasp in our case because it requires a lot of scrolling to find the next failed test case.
For example, the following test case leads to the output below:
public function testMatcher(): void
{
$pattern = <<<EOF
{
"name": "test-1"
}
EOF;
$value = <<<EOF
{
"name": "test-2"
}
EOF;
TestCase::assertThat(
$value,
new PHPMatcherConstraint($pattern)
);
}
Failed asserting that ' {\n
"name": "test-2"\n
}' matches given pattern.
Pattern: ' {\n
"name": "test-1"\n
}'
Error: Value {"name":"test-2"} does not match pattern {"name":"test-1"}
Backtrace:
#1 Matcher Coduo\PHPMatcher\Matcher matching value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#2 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (all) matching value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#3 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) can match pattern "{"name":"test-1"}"
#4 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) matching value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#5 Matcher Coduo\PHPMatcher\Matcher\CallbackMatcher can't match pattern "{"name":"test-1"}"
#6 Matcher Coduo\PHPMatcher\Matcher\ExpressionMatcher can't match pattern "{"name":"test-1"}"
#7 Matcher Coduo\PHPMatcher\Matcher\NullMatcher can't match pattern "{"name":"test-1"}"
#8 Matcher Coduo\PHPMatcher\Matcher\StringMatcher can't match pattern "{"name":"test-1"}"
#9 Matcher Coduo\PHPMatcher\Matcher\IntegerMatcher can't match pattern "{"name":"test-1"}"
#10 Matcher Coduo\PHPMatcher\Matcher\BooleanMatcher can't match pattern "{"name":"test-1"}"
#11 Matcher Coduo\PHPMatcher\Matcher\DoubleMatcher can't match pattern "{"name":"test-1"}"
#12 Matcher Coduo\PHPMatcher\Matcher\NumberMatcher can't match pattern "{"name":"test-1"}"
#13 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher can match pattern "{"name":"test-1"}"
#14 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher matching value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#15 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher failed to match value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#16 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher error: "{"name":"test-2"}" does not match "{"name":"test-1"}".
#17 Matcher Coduo\PHPMatcher\Matcher\WildcardMatcher can't match pattern "{"name":"test-1"}"
#18 Matcher Coduo\PHPMatcher\Matcher\UuidMatcher can't match pattern "{"name":"test-1"}"
#19 Matcher Coduo\PHPMatcher\Matcher\JsonObjectMatcher can't match pattern "{"name":"test-1"}"
#20 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) failed to match value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#21 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) error: "{"name":"test-2"}" does not match "{"name":"test-1"}".
#22 Matcher Coduo\PHPMatcher\Matcher\JsonMatcher can match pattern "{"name":"test-1"}"
#23 Matcher Coduo\PHPMatcher\Matcher\JsonMatcher matching value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#24 Matcher Coduo\PHPMatcher\Matcher\ArrayMatcher matching value "Array(1)" with "Array(1)" pattern
#25 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (array) can match pattern "test-1"
#26 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (array) matching value "test-2" with "test-1" pattern
#27 Matcher Coduo\PHPMatcher\Matcher\OrMatcher can't match pattern "test-1"
#28 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) can match pattern "test-1"
#29 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) matching value "test-2" with "test-1" pattern
#30 Matcher Coduo\PHPMatcher\Matcher\CallbackMatcher can't match pattern "test-1"
#31 Matcher Coduo\PHPMatcher\Matcher\ExpressionMatcher can't match pattern "test-1"
#32 Matcher Coduo\PHPMatcher\Matcher\NullMatcher can't match pattern "test-1"
#33 Matcher Coduo\PHPMatcher\Matcher\StringMatcher can't match pattern "test-1"
#34 Matcher Coduo\PHPMatcher\Matcher\IntegerMatcher can't match pattern "test-1"
#35 Matcher Coduo\PHPMatcher\Matcher\BooleanMatcher can't match pattern "test-1"
#36 Matcher Coduo\PHPMatcher\Matcher\DoubleMatcher can't match pattern "test-1"
#37 Matcher Coduo\PHPMatcher\Matcher\NumberMatcher can't match pattern "test-1"
#38 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher can match pattern "test-1"
#39 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher matching value "test-2" with "test-1" pattern
#40 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher failed to match value "test-2" with "test-1" pattern
#41 Matcher Coduo\PHPMatcher\Matcher\ScalarMatcher error: "test-2" does not match "test-1".
#42 Matcher Coduo\PHPMatcher\Matcher\WildcardMatcher can't match pattern "test-1"
#43 Matcher Coduo\PHPMatcher\Matcher\UuidMatcher can't match pattern "test-1"
#44 Matcher Coduo\PHPMatcher\Matcher\JsonObjectMatcher can't match pattern "test-1"
#45 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) failed to match value "test-2" with "test-1" pattern
#46 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) error: "test-2" does not match "test-1".
#47 Matcher Coduo\PHPMatcher\Matcher\TextMatcher can match pattern "test-1"
#48 Matcher Coduo\PHPMatcher\Matcher\TextMatcher matching value "test-2" with "test-1" pattern
#49 Matcher Coduo\PHPMatcher\Matcher\TextMatcher failed to match value "test-2" with "test-1" pattern
#50 Matcher Coduo\PHPMatcher\Matcher\TextMatcher error: "test-2" does not match "test-1" pattern
#51 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (array) failed to match value "test-2" with "test-1" pattern
#52 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (array) error: "test-2" does not match "test-1" pattern
#53 Matcher Coduo\PHPMatcher\Matcher\ArrayMatcher failed to match value "Array(1)" with "Array(1)" pattern
#54 Matcher Coduo\PHPMatcher\Matcher\ArrayMatcher error: "test-2" does not match "test-1" pattern
#55 Matcher Coduo\PHPMatcher\Matcher\JsonMatcher failed to match value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#56 Matcher Coduo\PHPMatcher\Matcher\JsonMatcher error: Value {"name":"test-2"} does not match pattern {"name":"test-1"}
#57 Matcher Coduo\PHPMatcher\Matcher\XmlMatcher can't match pattern "{"name":"test-1"}"
#58 Matcher Coduo\PHPMatcher\Matcher\OrMatcher can't match pattern "{"name":"test-1"}"
#59 Matcher Coduo\PHPMatcher\Matcher\TextMatcher can't match pattern "{"name":"test-1"}"
#60 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (all) failed to match value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#61 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (all) error: Value {"name":"test-2"} does not match pattern {"name":"test-1"}
#62 Matcher Coduo\PHPMatcher\Matcher failed to match value "{"name":"test-2"}" with "{"name":"test-1"}" pattern
#63 Matcher Coduo\PHPMatcher\Matcher error: Value {"name":"test-2"} does not match pattern {"name":"test-1"}.
--- Expected
+++ Actual
@@ @@
{
- "name": "test-1"
+ "name": "test-2"
}
Is it possible to disable the output of the backtrace when our test suite is executed?
Thanks in advance!
TomBerriot, Mateuszry and FilipBenco