KP Solutions

Solutions for Day to Day Technical Problems

CakePHP Test Failure with Error PHPUnit_Framework_AssertionFailedError::getComparisonFailure()

| 1 Comment

If you are using CakePHP 2.2 and are developing code with unit testing, then chances are you have stumbled on the error “Fatal error: Call to undefined method PHPUnit_Framework_AssertionFailedError::getComparisonFailure() in E:\…\lib\Cake\TestSuite\Reporter\CakeHtmlReporter.php on line 252” with no real useful message.

Default test Case pushed out Cake Baking system has just two methods setup and teardown. So if your test file doesn’t have any test methods then this error will come up. So to fix it, add a test case and the error will go away.

For eg. if you are looking to test your Model ‘User’ and there’s no test case in the UserTest.php file, then you would get above error. To fix it, add ‘public function testUser() { }’. This will fix that error and then you can start creating proper test cases.

  • alexbain

    Thanks for this. I created a smoke test (called testSmokeTest) that just asserted true was true to fix this error.