PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Testing » PHPUnit2 » Bug #5769

Errors aren't displayed

Details

Request #5769Errors aren't displayed
Submitted2005-10-24 16:15 UTC
Frombokelley at rightmedia dot com
Assignedsebastian
StatusNo Feedback
PackagePHPUnit2
PHP Version5.0.5
OSLinux
Roadmaps(Not assigned)

Comments

[2005-10-24 16:15 UTC] bokelley at rightmedia dot com

Description:
------------
I'm writing a fairly simple test harness for some classes that hit a database. When a query is misformed (or whatever) an exception is thrown.

When the exception hits the PHPUnit tests, they record an error. This is great. However, they don't display what the exception was:

There were 2 errors:
1) testInsertThenLoadTiesOut(CreativeTest)

/home/bok/php/soap/types/creative.inc:195
/home/bok/php/soap/types/CreativeTest.php:79

The exception contains plenty of information about why it failed (the exact query text, for instance) but now I have to add a printf in the code (if query fails, print error info, then throw error info).

Would be great to have the exception message be printed out on error.

[2005-10-24 16:57 UTC] sebastian at php dot net

This should already happen, have a look at the following example:

<?php
require_once 'PHPUnit2/Framework/TestCase.php';

class ErrorTest extends PHPUnit2_Framework_TestCase {
public function testError() {
throw new Exception('Error message.');
}
}
?>

$ phpunit ErrorTest
PHPUnit 2.3.2 by Sebastian Bergmann.

E

Time: 0.000703
There was 1 error:
1) testError(ErrorTest)
Error message.
/home/sb/ErrorTest.php:6

FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1, Incomplete Tests: 0.

Which version of PHPUnit2 are you using? Does the getMessage() method of your Exception class return the message string properly?

[2005-12-19 05:50 UTC] sebastian at php dot net

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.