Skip to content

Assumptions can be used to skip tests when common preconditions, like the PHP Version or installed extensions, are not met.

License

Notifications You must be signed in to change notification settings

siad007/Assumptions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assumptions for PHPUnit.

Build Status Code Climate Test Coverage Dependency Status

Introduction

Assumptions can be used to skip tests when common preconditions, like the PHP Version or installed extensions, are not met.

The default PHPUnit runner treats tests with failing assumptions as skipped. Custom runners may behave differently.

We have included several assumptions like assumeTrue, assumeExtensionLoaded,... by default. All of those functions are subsumed in assumeThat, with the appropriate Hamcrest matcher.

A failing assumption in a @before or @beforeClass method will have the same effect as a failing assumption in each @test method of the class.


The concept behind Assumptions for PHPUnit is based on the adequate junit feature, which is documented on their wiki - Assumptions with assume

Note

There is a similar feature in PHPUnit called @requires!

If you are familiar in using @requires annotation to dedicate that a given requirement would be given and you are happy about, then you just do not need the use of Assumption for PHPUnit.

But if you want to have

  • code completion
  • better readability
  • finer control
  • more requirement abilities

then you should give Assumption for PHPUnit a try.


Installation

see wiki

Usage

public function testMethod()
{
    assumeTrue((bool) getenv('ENV_TEST'), 'Environment Variable not set.');
    // if environment variable ENV_TEST is not set, then the test will be skipped.
    ...
}

Requirements

  • PHP >= 5.6

About

Assumptions can be used to skip tests when common preconditions, like the PHP Version or installed extensions, are not met.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%