Giter Site home page Giter Site logo

qase-phpunit's Introduction

Qase TMS PHPUnit reporter

Publish results simple and easy.

How to integrate

composer require qase/phpunit-reporter

Example of usage

The PHPUnit reporter has the ability to auto-generate test cases and suites from your test data.

But if necessary, you can independently register the ID of already existing test cases from TMS before the executing tests. For example:

/**
 * @qaseId 3
 */
public function testCanBeUsedAsString(): void
{
    $this->assertEquals(
        '[email protected]',
        Email::fromString('[email protected]')
    );
}

To run tests and create a test run, execute the command:

$ ./vendor/bin/phpunit

Output of run

A test run will be performed and available at:

https://app.qase.io/run/QASE_PROJECT_CODE

If test fails, a defect will be automatically created

Using parameterization

PHPUnit reporter also allows you to perform parameterization of the test case. To do this, you need to specify a dataprovider. Example:

    /**
     * @dataProvider additionProvider
     */
    public function testUsingProvider($a, $b, $expected)
    {
        $this->assertSame($expected, $a + $b);
    }

    public function additionProvider()
    {
        return [
            [0, 0, 0],
            [0, 1, 1],
            [1, 0, 1],
            [1, 1, 3]
        ];
    }

dashboard

Configuration

Add to your phpunit.xml extension:

<extensions>
  <extension class="Qase\PHPUnit\Reporter"/>
</extensions>

Reporter options (* - required):

  • QASE_REPORT - toggles sending reports to Qase.io, set 1 to enable
  • *QASE_API_TOKEN - access token, you can find more information here.
  • *QASE_PROJECT_CODE - code of your project (can be extracted from main page of your project, as example, for https://app.qase.io/project/DEMO -> DEMO is project code here.
  • *QASE_API_BASE_URL - URL endpoint API from Qase TMS, default is https://api.qase.io/v1.
  • QASE_RUN_ID - allows you to use an existing test run instead of creating new.
  • QASE_RUN_NAME - Set custom Run name, when new run is created.
  • QASE_RUN_DESCRIPTION - Set custom Run description, when new run is created.
  • QASE_RUN_COMPLETE - performs the "complete" function after passing the test run.
  • QASE_ENVIRONMENT_ID - environment ID from Qase TMS
  • QASE_LOGGING - toggles debug logging, set 1 to enable

The configuration file should be called phpunit.xml, an example of such a file:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
  <extensions>
    <extension class="Qase\PHPUnit\Reporter"/>
  </extensions>
  <testsuites>
    <testsuite name="qase-phpunit">
      <directory>./tests</directory>
    </testsuite>
  </testsuites>
  <php>
    <env name="QASE_REPORT" value="1" force="true" />
    <env name="QASE_API_TOKEN" value="<api_key>" force="true" />
    <env name="QASE_PROJECT_CODE" value="<project_code>" force="true" />
    <env name="QASE_API_BASE_URL" value="https://api.qase.io/v1" force="true" />
    <env name="QASE_RUN_ID" value="" force="true" />
    <env name="QASE_RUN_NAME" value="PHPUnit run" force="true" />
    <env name="QASE_RUN_DESCRIPTION" value="PHPUnit automated run" force="true" />
    <env name="QASE_RUN_COMPLETE" value="1" force="true" />
    <env name="QASE_ENVIRONMENT_ID" value="1" force="true" />
    <env name="QASE_LOGGING" value="1" force="true" />
  </php>
</phpunit>

qase-phpunit's People

Contributors

1ivliev avatar in4s avatar kamilsk avatar n3r avatar sklmx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sklmx 1ivliev in4s

qase-phpunit's Issues

Add support for custom run description

Must be transmitted through a variable - QASE_RUN_DESCRIPTION.
In case of absence, print a standard inscription - PHPUnit automated run.
Need to update the documentation with examples, add unit tests.

Issue with arg QASE_RUN_COMPLETE

If you use a new test run and set QASE_RUN_COMPLETE=0 (or skip entering this parameter), the run will still close, but if you put it into a previously created one, then the option works correctly.
We need to separate the application of this argument. If you specify type = 0, the run should not be closed.

Add support for create custom run name

Must be transmitted through a variable - QASE_RUN_NAME.
In case of absence, print a standard inscription.
Need to update the documentation with examples, add unit tests.

PHP Unit Test Runs has no Test Cases

Description:
When running PHP Unit tests, the test run that gets generated in QASE shows no test cases

Expected Result:
Running automated tests will generate an automated test run with test cases in QASE

Actual Result:
Running automated tests generates an automated test run with no test cases in QASE

Steps to Reproduce

  1. Install QASE reporter docker compose exec <container> composer require qase/phpunit-reporter
  2. Update the phpunit.xml file to include the QASE reporter (test suites information was redacted)
    image
  3. From the Project Settings Page, enable auto test case creation
    image
  4. Run the tests docker compose exec <container> php vendor/bin/phpunit. Notice that although the test run is generated, the test cases are appearing as empty. --> [PROBLEM]
    image

Additional Notes:
Test cases can't be run locally due to dependency issues, so the setup is being run on docker

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.