Allure PHPUnit configuration

This page describes the configuration options that can be set in the configuration file for Allure PHPUnit.

By default, the configuration file is looked up at config/allure.config.php, but this location can be overridden, see Prepare your project.

outputDirectory

Path to the directory where Allure PHPUnit will save the test results, see How it works. If the directory does not exist, it will be created. Defaults to build/allure-results.

PHP
<?php return [ 'outputDirectory' => 'build/allure-results', ];

linkTemplates

A mapping of templates that can be used to construct full URLs from short identifiers, see the reference.

Each key must be a link type identifier, and each value must be a class implementing the LinkTemplateInterface interface, or an object of such a class. When processing a link of the given type, Allure PHPUnit will call the buildUrl() method of the class.

PHP
<?php use Qameta\Allure\Setup\LinkTemplateInterface; return [ 'linkTemplates' => [ 'issue' => new class implements LinkTemplateInterface { public function buildUrl(?string $name): ?string { return "https://issues.example.com/$name"; } }, 'tms' => new class implements LinkTemplateInterface { public function buildUrl(?string $name): ?string { return "https://tms.example.com/$name"; } }, 'jira' => new class implements LinkTemplateInterface { public function buildUrl(?string $name): ?string { return "https://jira.example.com/browse/$name"; } }, ], ];

setupHook

A function that will be called before initializing the Allure PHPUnit lifecycle.

PHP
<?php return [ 'setupHook' => function () { // ... }, ];

lifecycleHooks

An array of one or more classes, each implementing one or more lifecycle hook interfaces for Allure PHPUnit. For example, such a class can modify test results before or after Allure PHPUnit's standard processing.

PHP
<?php use Qameta\Allure\Hook\AfterTestStopHookInterface; use Qameta\Allure\Hook\BeforeTestStartHookInterface; use Qameta\Allure\Model\TestResult; return [ 'lifecycleHooks' => [ new class implements BeforeTestStartHookInterface, AfterTestStopHookInterface { public function beforeTestStart(TestResult $test): void { // ... } public function afterTestStop(TestResult $test): void { // ... } }, ], ];

threadDetector

A class implementing the ThreadDetectorInterface interface, or an object of such a class. If set, Allure PHPUnit will use its getHost() and getThread() methods to determine the host and thread identifiers for a current test. The test results will be placed on the Timeline tab accordingly.

The example below assumes that you use pthreads for running your PHPUnit tests in parallel.

PHP
<?php use Qameta\Allure\PHPUnit\Setup\ThreadDetectorInterface; return [ 'threadDetector' => new class implements ThreadDetectorInterface { function getHost(): ?string { return gethostname(); } function getThread(): ?string { return strval(Thread::getCurrentThread() . getThreadId()); } }, ];
Powered by
logo

Join our newsletter

Join our community

We aim to make Allure Report as reliable and user-friendly as possible, and together with the community, we're here to help when problems arise.

© 2024 Qameta Software Inc. All rights reserved.