Skip to content

qase-tms/qase-phpunit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Qase TMS PHPUnit Reporter

Publish test results easily and efficiently.

Installation

To install the latest version, run:

composer require qase/phpunit-reporter 

Getting Started

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

Parallel Execution

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

Configuration

Qase PHPUnit Reporter can be configured using:

  1. A separate configuration file qase.config.json.
  2. 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
    }
  }
}

Requirements

We maintain the reporter on LTS versions of PHP.

  • php >= 8.0
  • phpunit >= 9.5