|
From: Jason S. <jsw...@ya...> - 2004-02-15 04:06:08
|
--- Jeff Moore <je...@pr...> wrote:
> Hello,
>
> I was looking for some advise regarding testing for errors. If I have
> some code that I want to test of the form:
>
> if (condition1) {
> trigger_error()
> }
>
> if (condition2) {
> trigger_error()
> }
>
> And I have the following test case
>
> // trigger error condition 1
> $this->assertError();
Marcus has conditioned me to use the assertErrorPattern() method.
http://simpletest.sourceforge.net/api/SimpleTest/UnitTester/UnitTestCase.html#assertErrorPattern
I would say your best bet would be to set up the test to meet each or none, one
or both of the conditions (perhaps four separate methods in the test case?),
and then explicitly test for the expected errors.
> Should I put a swallowErrors() call after my assertError() to prevent
> the exceptions?
>
> If so, should I put a swallowErrors() call at the end of every test
> case that calls assertError?
I would avoid use of swallowErrors at all, I have found this got rid of error
that crept in unexpectedly on me. YMMV
Regards,
Jason
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
|