2017 © Pedro Peláez
 

library failuretest

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

image

backendtea/failuretest

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  • Thursday, January 25, 2018
  • by BackEndTea
  • Repository
  • 0 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

FailureTest

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed., (*1)

Installation

  • Using Composer: composer require backendtea/failuretest

Or simply copy the AllowFailure.php into your project and include it yourself., (*2)

Requirements

  • PHP version 5.6 or higher
  • PHPUnit version 5.0 or higher.

Usage

These traits make us of PHPUnits tearDown() function. If you override it, don't forget to call parent::tearDown();, (*3)

Any test that has failed will show up as incomplete, with its original failure message attached. Once a test actually passes all its criteria, it will be marked as a failure, with an error message explaining you can move it to the normal tests., (*4)

AllowFailure

<?php 

use FailureTest\AllowFailure;

class AllowFailureTest extends \PHPUnit\Framework\TestCase
{
    use AllowFailure;

    /** 
     * @allowedFailure
     */
    public function test_it_handles_a_failure()
    {
        //This doesn't cause errors
        $this->assertTrue(false);
    }

    /** 
     * @allowedFailure
     */
    public function test_a_success_is_allowed()
    {
        //This doesn't cause errors
        $this->assertTrue(true);
    }

    /** 
     * @mustFail
     */
    public function test_it_checks_out()
    {
        //This doesn't cause errors
        $this->assertTrue(false);
    }

    /**
     * @mustFail
     */
    public function test_it_goes_wrong()
    {
        //This will give a failed test
        $this->assertTrue(true);
    }
}

The AllowFailure trait gives you access to two annotations: @allowedFailure and @mustFail. Both work on method or class level., (*5)

  • @allowedFailure Will simply mark a test as incomplete if it 'fails', and if it passes it does nothing.
  • @mustFail works the same as the FailureTestCase. Except you can configure it on function level.

@allowedFailure overrides @mustfail. So if both are present, be it on class or method, the test will not error if it succeeds., (*6)

Why

Instead of just creating an issue when finding a bug, someone can also contribute a failing test case. This makes sure the issue won't be forgotten, and it also allows another developer to better make sure they fixed the issue., (*7)

It can also serve as a nice 'todo' list, which can move with your code to another VCS if you so desire., (*8)

Contributing

If you find a bug, or want a feature, open an issue, or create a PR., (*9)

All tests in the Failure sub folder are supposed to fail, and the ones in the Success folder should not fail., (*10)

The Versions

25/01 2018

dev-master

9999999-dev

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

25/01 2018

v1.0.0

1.0.0.0

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

25/01 2018

dev-cleanup

dev-cleanup

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

25/01 2018

dev-feature/support-lower-versions

dev-feature/support-lower-versions

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

25/01 2018

v0.1.0

0.1.0.0

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

25/01 2018

dev-feature/allowed-failure

dev-feature/allowed-failure

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

24/01 2018

v0.0.2

0.0.2.0

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

24/01 2018

dev-clean-up

dev-clean-up

Allow failing PHPUnit tests and keep a close eye on issues until they are fixed.

  Sources   Download

MIT

The Requires

 

phpunit php unit testing failures

24/01 2018

v0.0.1

0.0.1.0

A way to include failing tests in your PHP project

  Sources   Download

MIT

The Development Requires