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

Test outcome #188

Closed
thekid opened this issue Oct 17, 2011 · 0 comments
Closed

Test outcome #188

thekid opened this issue Oct 17, 2011 · 0 comments

Comments

@thekid
Copy link
Member

thekid commented Oct 17, 2011

Scope of Change

At the moment, there are three possible outcomes of a unittest: Succeeded,
Skipped and Failed. This RFC suggests adding more kinds of outcomes:
Warnings, Error and NotRun.

Rationale

Be able to distinguish between the different non-success reasons.

Functionality

The new outcomes are represented by these new classes:

<?php
  // Test succeeded but PHP warnings and/or notices were raised
  class TestWarnings implements TestFailure {
  }

  // An exception other than unittest.AssertionFailedError was raised
  class TestError implements TestFailure {
  }

  // The test was not run because an @ignore annotation was present
  class TestNotRun implements TestSkipped {
  }
?>

The existing classes TestSuccess, TestFailure and TestSkipped are turned
into interfaces and the concrete implementations moved to the following
new classes:

<?php
  // Test succeeded
  class TestExpectationMet implements TestSuccess {
  }

  // An AssertionFailedError was thrown - e.g. because one of the 
  // assert*() methods failed or fail() was called explicitely
  class TestAssertionFailed implements TestFailure {
  }

  // A PrerequisitesNotMetError was thrown in setUp() or @beforeClass
  class TestPrerequisitesNotMet implements TestSkipped {
  }
?>

Definitions

These current outcomes are defined:

  • "." - Succeeded (Test was successful)
  • "S" - Skipped (Test was skipped by either an error inside setUp() or by
    an @ignore annotation)
  • "F" - Failed (Test failed due to an assertion error, an expected exception
    not being caught or by an exception raised by the code inside).

Example output:

  [..SSFFF]
  2 succeeded, 2 skipped, 3 failed

This RFC suggests to add the following new outcomes:

  • "W" - Warning (One or more PHP errors were raised)
  • "E" - Error (An exception other than AssertionFailedError was thrown when
    executing the test and no @expected annotation existed)
  • "N" - Not run (Test was ignored by @ignore, as stated above, this is currently
    also reported as "skipped")

Example output:

  [..SNFFE]
  2 succeeded, 2 skipped, 3 failed

Security considerations

n/a

Speed impact

n/a

Dependencies

No BC break: All instanceof checks on TestFailure, TestSuccess and
TestSkipped will continue to work as expected due to the classes being
converted to interfaces.

Related documents

Implementing patch:

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