LinuxCommandLibrary

kahlan

Run and test applications written with Kahlan

TLDR

Run all specifications in the "spec" directory

$ kahlan
copy

Run specifications using a specific configuration file
$ kahlan --config=[path/to/configuration_file]
copy

Run specifications and output using a reporter
$ kahlan --reporter=[dot|bar|json|tap|verbose]
copy

Run specifications with code coverage (detail can be between 0 and 4)
$ kahlan --coverage=[detail_level]
copy

SYNOPSIS

kahlan [options] [spec_directory]

PARAMETERS

--reporter=
    Sets the reporter to use. Common reporters include `verbose`, `dot`, and `json`.

--coverage
    Enables code coverage analysis.

--clover=
    Saves code coverage data to a Clover XML file.

--phpunit=
    Saves code coverage data to a PHPUnit XML file.

--fast-fail
    Stop execution on first failure.

--grep=
    Filter specs by matching against their description.

--not-grep=
    Exclude specs by matching against their description.

DESCRIPTION

Kahlan is a Behavior-Driven Development (BDD) test framework written in PHP.
It provides a clean and intuitive syntax for writing expressive and readable tests. Kahlan focuses on simplicity, speed, and flexibility, offering features such as spies, stubs, mocks, and code coverage.

It is designed to be easy to integrate with existing PHP projects and supports a wide range of testing scenarios, from unit to integration to functional testing.
Kahlan's core philosophy revolves around describing the behavior of your code, leading to tests that are more maintainable and easier to understand.
It promotes writing tests that read like specifications, fostering better communication between developers and stakeholders.

CAVEATS

Kahlan requires PHP 7.2 or greater. Proper setup of autoloading and the Kahlan environment is crucial for successful test execution.

SPEC DIRECTORY

The `spec_directory` argument specifies the directory where your Kahlan specification files (specs) are located. If not provided, it defaults to `spec`.

REPORTERS

Kahlan utilizes reporters to output test results. The `verbose` reporter provides detailed output, while the `dot` reporter displays a dot for each spec. The `json` reporter outputs the results in JSON format which can be used for automation and CI integration.

CONFIGURATION

Kahlan can be configured via a `kahlan-config.php` file in your project's root directory. This file allows you to customize various settings, such as autoloading, code coverage, and reporters.

Copied to clipboard