PHP

User Contributed:

ATOUM

atoum is a modern, simple and intuitive PHP 5.3+ unit testing framework which aims to provide the best tools to help PHP developpers test their code: that's why it natively provides coveralls report generation.

ENABLING THE REPORT

Enabling the coveralls report is really simple: you will only need to add some lines to your configuration file:

<?php
//.atoum.php

use mageekguy\atoum;
use mageekguy\atoum\reports;

$coveralls = new reports\asynchronous\coveralls('src', 'myCoverallsProjectToken');
$coveralls->addWriter();
$runner->addReport($coveralls);

$script->addDefaultReport();

This simple configuration will allow you to publish reports to Coveralls, be your build ran locally or on a CI system.

CI SYSTEMS

As Coveralls supports many CI systems, the atoum's report is made to also supports these systems. For example, if you are using Travis CI, you will want to get your Coveralls build linked to the Travis one and also get Git informations:

<?php
//.atoum.php

use mageekguy\atoum;
use mageekguy\atoum\reports;

$coveralls = new reports\asynchronous\coveralls('src', 'myCoverallsProjectToken');
$defaultFinder = $coveralls->getBranchFinder();
$coveralls
        ->setBranchFinder(function() use ($defaultFinder) {
                if (($branch = getenv('TRAVIS_BRANCH')) === false)
                {
                        $branch = $defaultFinder();
                }

                return $branch;
        })
        ->setServiceName(getenv('TRAVIS') ? 'travis-ci' : null)
        ->setServiceJobId(getenv('TRAVIS_JOB_ID') ?: null)
        ->addWriter()
;
$runner->addReport($coveralls);

$script->addDefaultReport();

An annotated sample configuration is available in atoum's repository.

TESTING AND PUBLISHING REPORTS

Once you wrote your configuration, the only thing you will have to do is launching your test suite as usual: atoum will handle all the steps to produce and publish the report on coveralls:

$ bin/atoum --test-all
$ bin/atoum -d path/to/unit/tests
$ bin/atoum -f path/to/unit/test.php

If you are building through a CI system, again, the only thing you will have to do is write the right configuration (see the previous example): no change to your build script is needed:

#.travis.yml

language: php
php:
  - 5.3
  - 5.4
script:
  - bin/atoum --test-all
Have more questions? Submit a request

Comments

Powered by Zendesk