Skip to content

Commit 74e4f13

Browse files
committed
Dump both acctural and expected results when test fails
1 parent cf6ba18 commit 74e4f13

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/PHPCtagsTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ public function testExport($testcase)
6565
$testcase_result = ob_get_contents();
6666
ob_end_clean();
6767

68-
$this->assertEquals(md5($testcase_result), md5($testcase_expect))
68+
$expected_result = __DIR__ . '/' . $testcase_id . '.testcase.expect';
69+
$acctural_result = __DIR__ . '/' . $testcase_id . '.testcase.result';
70+
71+
$msg = <<<EOF
72+
Test case '$testcase' has failed.
73+
Expected result has been dumped to '$expected_result'
74+
Acctural result has been dumped to '$acctural_result'
75+
EOF;
76+
77+
try {
78+
$this->assertEquals(md5($testcase_expect), md5($testcase_result), $msg);
79+
} catch (PHPUnit_Framework_ExpectationFailedException $e) {
80+
file_put_contents($expected_result, $testcase_expect);
81+
file_put_contents($acctural_result, $testcase_result);
82+
throw $e;
83+
}
6984
}
7085

7186
}

0 commit comments

Comments
 (0)