Download the PHP package atoum/bdd-extension without Composer
On this page you can find all versions of the php package atoum/bdd-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download atoum/bdd-extension
More information about atoum/bdd-extension
Files in atoum/bdd-extension
Package bdd-extension
Short Description atoum Spec BDD extension
License BSD-3-Clause
Homepage http://www.atoum.org
Informations about the package bdd-extension
atoum/bdd-extension
This extensions helps you to write your tests (specs) in a Behavior Driven development fashion.
Example
and the output will look like this :
Install it
Install extension using composer:
Enable the extension using atoum configuration file:
Use it
Your first spec
The extension requires you to place your specs in a specs
namespace and make them extend atoum\spec
. Let's write a
spec for the jubianchi\example\formatter
class:
Running your first spec
And run it again until you get green:
You can use the --loop
flag to work incrementally: vendor/bin/atoum -d specs --loop
Reading the report
The spec report uses a set of icon to identify examples' statuses:
✘
to mark failed examples (error, exception or assertion failure)✔
to mark passed examples↣
to mark skipped examples∅
to mark void examples (not implemented specs)
Spec syntax
Invoking methods
Invoking a method is the process of calling a method on a tested object in a way that will allow the tester to assert on method behavior:
This example will invoke the format
method of the $formatter
object with one argument, __FUNCTION__
.
There are several way of invoking method, depending on which syntax you prefer:
Asserting on returned values
The spec extension provides some shortcut to assert on method return value.
As you can see, shouldReturn
lets you assert on invoked method return value. Again, there are several way of doing the
same:
Calling shouldReturn
with a parameter will fallback on the atoum\asserters\variable::isEqual
assertion which is the
less strict one in atoum. You can of course use strict assertions to do some type checking:
Asserting on thrown exceptions
Asserting on exception is quite simple and similar to asserting on returned values:
As for shouldReturn
, shouldThrow
provides some alternative synatxes:
Calling shouldThrow
this way will fallback on atoum\asserters\exception::isInstanceOf
, if you don't want to check
the exception type, you can simple omit the argument:
Of course, you can also check the exception message using regular assertions:
Links
Licence
bdd-extension is released under the BSD-3-Clause. See the bundled LICENSE file for detail.