LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

kahlan

BDD testing framework for PHP

TLDR

Run all specs in the spec directory
$ vendor/bin/kahlan
copy
Run a specific spec file or directory
$ kahlan --spec=[spec/MySpec.php]
copy
Match spec files by a filename pattern
$ kahlan --grep="[*Test.php]"
copy
Show a code coverage summary (detail level 0-4)
$ kahlan --coverage=[4]
copy
Show detailed coverage for a specific class or method
$ kahlan --coverage="[App\Service::run()]"
copy
Export coverage in Clover XML format for CI
$ kahlan --clover=[clover.xml]
copy
Use a different reporter and also write TAP output to a file
$ kahlan --reporter=[verbose] --reporter=[tap]:[results.tap]
copy
Stop after the first failure
$ kahlan --ff=1
copy

SYNOPSIS

kahlan [options]

DESCRIPTION

Kahlan is a BDD testing framework for PHP. It uses a describe-it syntax similar to Jasmine and RSpec, with expect() matchers such as toBe, toEqual and toThrow.It supports stubbing and mocking of classes and functions, including monkey patching of core PHP functions without extensions, by patching source code on the fly when it is loaded. Built-in code coverage and several reporters are included, and runs are customized through a kahlan-config.php file.

PARAMETERS

--config=FILE

PHP configuration file (default: kahlan-config.php).
--src=PATH
Source directories (default: src). Repeatable.
--spec=PATH
Spec files or directories (default: spec). Repeatable.
--grep=PATTERN
Shell wildcard for spec files (default: \*Spec.php and \*.spec.php).
--reporter=NAME[:FILE]
Reporter: dot (default), bar, json, tap, tree or verbose; optionally redirected to a file. Repeatable.
--coverage=LEVEL|SCOPE
Coverage report detail (0-4), or a namespace, class or method for a detailed report. Requires Xdebug or PCOV.
--clover=FILE
Export coverage as Clover XML.
--istanbul=FILE
Export coverage as istanbul-compatible JSON.
--lcov=FILE
Export coverage in lcov format.
--part=N/M
Run only part N of M, for parallel testing (default: 1/1).
--ff=N
Fast fail after N failures; 0 means unlimited (default: 0).
--no-colors
Disable colored output.
--no-header
Do not print the header.
--include=PATH, --exclude=PATH
Paths to include or exclude from code patching.
--persistent=BOOL
Cache patched files (default: true).
--cc
Clear the cache before running specs.
--help
Display help information.
--version
Print the Kahlan version.

CAVEATS

Usually installed per project via Composer, so the binary lives at vendor/bin/kahlan. Code coverage needs Xdebug or PCOV. The syntax differs from PHPUnit, so test suites are not interchangeable.

HISTORY

Kahlan was created by Simon Jaillet in 2013 and is developed on GitHub under the kahlan organization.

SEE ALSO

phpunit(1), phpspec(1), pest(1), composer(1)

RESOURCES

Copied to clipboard
Kai