Publish test results easily and efficiently.
To install the latest version, run:
composer require qase/phpunit-reporter
The PHPUnit reporter can auto-generate test cases and suites based on your test data. Test results of subsequent test runs will match the same test cases as long as their names and file paths don’t change.
You can also annotate tests with the IDs of existing test cases from Qase.io before executing them. This is a more reliable way to bind automated tests to test cases, ensuring they persist when you rename, move, or parameterize your tests.
For example:
<?php
namespace Tests;
use Exception;
use PHPUnit\Framework\TestCase;
use Qase\PHPUnitReporter\Attributes\Field;
use Qase\PHPUnitReporter\Attributes\Parameter;
use Qase\PHPUnitReporter\Attributes\QaseId;
use Qase\PHPUnitReporter\Attributes\Suite;
use Qase\PHPUnitReporter\Attributes\Title;
#[Suite("Main suite")]
class SimplesTest extends TestCase
{
#[
Title('Test one'),
Parameter("param1", "value1"),
]
public function testOne(): void
{
$this->assertTrue(true);
}
#[
QaseId(123),
Field('description', 'Some description'),
Field('severity', 'major')
]
public function testTwo(): void
{
$this->assertTrue(false);
}
#[
Suite('Suite one'),
Suite('Suite two')
]
public function testThree(): void
{
throw new Exception('Some exception');
}
}
To execute PHPUnit tests and report them to Qase.io, run the command:
QASE_MODE=testops ./vendor/bin/phpunit
or, if configured in a script:
composer test
A test run will be created and accessible at:
https://app.qase.io/run/QASE_PROJECT_CODE
The reporter supports parallel execution of tests using the paratest
package.
To run tests in parallel, use the following command:
QASE_MODE=testops ./vendor/bin/paratest
Qase PHPUnit Reporter can be configured using:
- A separate configuration file qase.config.json.
- Environment variables (which override the values in the configuration file).
For a full list of configuration options, refer to the Configuration Reference.
Example qase.config.json
{
"mode": "testops",
"debug": true,
"testops": {
"api": {
"token": "api_key"
},
"project": "project_code",
"run": {
"complete": true
}
}
}
We maintain the reporter on LTS versions of PHP.
- php >= 8.0
- phpunit >= 9.5