Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make unittests strict #145

Closed
kiesel opened this issue Oct 17, 2011 · 1 comment
Closed

Make unittests strict #145

kiesel opened this issue Oct 17, 2011 · 1 comment

Comments

@kiesel
Copy link
Member

kiesel commented Oct 17, 2011

Scope of Change

A new check will be introduced to the unittest.TestCase class that will assert
that no PHP notices have been produced while running a test.

Rationale

PHP notices often indicate some kind of defect in a software which is
not critical at first glance but can have a hidden impact whose source
then is hard to spot.
A recent test-run revealed some (real) bugs in XP core packages that went
unnoticed until now and which were found by checking the error stack.

Functionality

A new check will be performed after each test method run.

Note

  Checks on the error registry are only performed when a test case does not
  throw an exception.

Consider this:

<?php
  if (!($exif= exif_read_data('/tmp/image.jpg'))) {
    throw new FormatException('Cannot read EXIF data');
  }
?>
  • exif_read_data() will return FALSE which is checked and an exception
    is thrown. A unittest will test for this behaviour using @expect e.g.
  • exif_read_data() will also emit a warning explaining why it couldn't
    read the EXIF data.
  • This warning contains useful information, so it shouldn't be deleted
    in the above example.

Security considerations

n/a

Speed impact

n/a

Dependencies

n/a

Related documents

@kiesel kiesel closed this as completed Oct 17, 2011
@kiesel
Copy link
Member Author

kiesel commented Oct 17, 2011

Should this behavior be deactivateable by a @non-strict class annotation?

kiesel, Sun, 25 Nov 2007 12:40:06 +0100

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant