The modern, simple and intuitive PHP unit testing framework.

Overview

atoum's logo

atoum Package version Build Status Build status Coverage Status StyleCI Gitter

PHP version atoum version
5.3 -> 5.6 1.x -> 3.x
7.2 -> 8.x 4.x (current)

A simple, modern and intuitive unit testing framework for PHP!

Just like SimpleTest or PHPUnit, atoum is a unit testing framework specific to the PHP language. However, it has been designed from the start with the following ideas in mind:

  • Can be implemented rapidly,
  • Simplify test development,
  • Allow for writing reliable, readable, and clear unit tests.

To accomplish that, it massively uses capabilities provided by PHP, to give the developer a whole new way of writing unit tests. Therefore, it can be installed and integrated into an existing project extremely easily, since it is only a single PHAR archive, which is the one and only entry point for the developer. Also, thanks to its fluent interface, it allows for writing unit tests in a fashion close to natural language. It also makes it easier to implement stubbing within tests, thanks to intelligent uses of anonymous functions and closures. atoum natively, and by default, performs the execution of each unit test within a separate PHP process, to warrant isolation. Of course, it can be used seamlessly for continuous integration, and given its design, it can be made to cope with specific needs extremely easily. atoum also accomplishes all of this without affecting performance, since it has been developed to boast a reduced memory footprint while allowing for hastened test execution. It can also generate unit test execution reports in the Xunit format, which makes it compatible with continuous integration tools such as Jenkins. atoum also generates code coverage reports, in order to make it possible to supervise unit tests. Finally, even though it is developed mainly on UNIX, it can also work on Windows.

Why atoum?

  • atoum is really easy to install: clone it from github, download its PHAR or simply use composer,
  • atoum provides a high level of security during test execution by isolating each test method in its own PHP process. Of course, this feature is available out of the box, no need to install any additional extension,
  • atoum runs tests in a parallelized environment making the suite run as fast as possible by taking advantage of today's multi-core CPUs,
  • atoum provides a full-featured set of natural and expressive assertions making tests as readable as possible. Here is an example:
<?php

$this
    ->integer(150)
        ->isGreaterThan(100)
        ->isLowerThanOrEqualTo(200)
;
  • atoum supports a BDD-like syntax with a lot of structural keywords:
<?php

$this
    ->given($testedInstance = new testedClass())
    ->and($testedClass[] = $firstValue = uniqid())
    ->then
        ->sizeof($testedInstance)->isEqualTo(1)
        ->string($testedClass[0])->isEqualTo($firstValue)
;
  • atoum provides a dead simple, yet very powerful, mock engine:
<?php

$this
    ->given($testedInstance = new testedClass())
    ->and($aMock = new \mock\foo\bar()) // here a mock of the class \foo\bar is created dynamically
    ->and($this->calling($aMock)->doOtherThing = true) // each call to doOtherThing() by the instance will return true
    ->and($testedInstance->setDependency($aMock))
    ->then
        ->boolean($testedInstance->doSomething())->isTrue()
        ->mock($aMock)
            ->call('doOtherThing')->withArguments($testedInstance)->once() // Asserts that the doOtherThing() method of $aMock was called once
;
  • atoum provides a clear API to assert on exceptions:
<?php

$this
    ->given($testedInstance = new testedClass())
    ->and($aMock = new \mock\foo\bar()) // here a mock of the class \foo\bar is created dynamically
    ->and($this->calling($aMock)->doOtherThing->throw = $exception = new \exception()) // Call to doOtherThing() will throw an exception
    ->and($testedInstance->setDependency($aMock))
    ->then
        ->exception(function() use ($testedInstance) { $testedInstance->doSomething(); })
            ->isIdenticalTo($exception)
;
  • atoum also lets you mock native PHP functions. Again, this is available out of the box:
<?php

$this
    ->given($this->function->session_start = false)
    ->and($session = new testedClass())
    ->then
        ->exception(function () use ($session) { $session->start(); })
            ->isInstanceOf('project\namespace\exception')
            ->hasMessage('Unable to start session')
        ->function('session_start')->wasCalled()->once()
;
  • atoum is able to produce several reports like TAP, clover, xUnit to be easily integrated with Jenkins or any other continuous integration tool,
  • atoum supports data providers,
  • atoum tests support autorun: just include the atoum runner and launch your test using php path/to/test/file.php,
  • atoum's configuration file is exclusively written in PHP (no XML, YAML or any other format) giving you the best flexibility:
<?php

$script->addDefaultArguments('--test-it', '-ncc');

$runner->addTestsFromDirectory(__DIR__ . '/tests/units/classes');

$testGenerator = new atoum\atoum\test\generator();
$testGenerator
    ->setTestClassesDirectory(__DIR__ . '/tests/units/classes');
    ->setTestClassNamespace('atoum\atoum\tests\units');
    ->setTestedClassesDirectory(__DIR__ . '/classes');
    ->setTestedClassNamespace('atoum\atoum')
    ->setRunnerPath(__DIR__ . '/scripts/runner.php')
;

$runner->setTestGenerator($testGenerator);
  • atoum provides an automatic test template generator,
  • atoum provides a loop mode to easily retrigger failed tests,
  • atoum is full of other interesting features that you will discover over the time.

Prerequisites to use atoum

atoum absolutely requires PHP >= 5.6.0 or later to work. On UNIX, in order to check whether you have the right PHP version, you just need to run the following command in your terminal:

$ php -v | grep -oE 'php 5\.3\.(?:[3-9]|[1-9][0-9])|5\.[4-6]\.[0-9]+|[5-7]\.[0-9]+\.[0-9]+'

If PHP 5.6.x or equivalent gets displayed, then you have the right PHP version installed. Should you want to use atoum using its PHAR archive, you also need PHP to be able to access the phar module, which is normally available by default. On UNIX, in order to check whether you have this module or not, you just need to run the following command in your terminal:

$ php -m | grep -i phar

If Phar or equivalent gets displayed, then the module is properly installed. Generating reports in the Xunit format requires the xml module. On UNIX, in order to check whether you have this module or not, you just need to run the following command in your terminal:

$ php -m | grep -i xml

If Xml or equivalent gets displayed, then the module is properly installed. Should you wish to monitor the coverage rate of your code by the unit tests, the Xdebug 2.3 module will be required. On UNIX, in order to check whether you have this module or not, you just need to run the following command in your terminal:

$ php -v | grep -oi 'xdebug'

If Xdebug or equivalent gets displayed, then the module is properly installed.

A unit testing framework that can be made operational in 5 minutes!

Step 1: Install atoum

You just have to download its PHAR archive and store it where you wish, for example under /path/to/project/tests/atoum.phar. This PHAR archive contains the latest development version to pass the totality of atoum's unit tests. atoum's source code is also available via the GitHub repository. To check if atoum works correctly with your configuration, you can execute all its unit tests. To do that, you just need to run the following command in your terminal:

$ php atoum.phar --test-it

Step 2: Write your tests

Using your preferred text editor, create the file path/to/project/tests/units/helloWorld.php and add the following code:

<?php

namespace vendor\project\tests\units;

require_once 'path/to/atoum.phar';

include_once 'path/to/project/classes/helloWorld.php';

use atoum\atoum;
use vendor\project;

class helloWorld extends atoum\test
{
    public function testSay()
    {
        $helloWorld = new project\helloWorld();

        $this->string($helloWorld->say())->isEqualTo('Hello World!');
    }
}

Step 3: Run your test with the command line

Launch your terminal and run the following command:

$ php path/to/test/file[enter]

You should get the following result or something equivalent:

> atoum version XXX by Frédéric Hardy.
Error: Unattended exception: Tested class 'vendor\project\helloWorld' does not exist for test class 'vendor\project\tests\units\helloWorld'

Step 4: Write the class corresponding to your test

Using again your preferred text editor, create the file path/to/project/classes/helloWorld.php and add the following code:

<?php

namespace vendor\project;

class helloWorld
{
    public function say()
    {
        return 'Hello World!';
    }
}

Step 5: Run your test once more

In the same terminal, run the following command once again:

$ php path/to/test/file[enter]

You should get the following result, or something equivalent:

> atoum version 288 by Frédéric Hardy.
> Run vendor\project\tests\units\helloWorld...
[S___________________________________________________________][1/1]
=> Test duration: 0.00 second.
=> Memory usage: 0.25 Mb.
> Total test duration: 0.00 second.
> Total test memory usage: 0.25 Mb.
> Code coverage value: 100.00%
> Running duration: 0.08 second.
> Success (1 test, 1 method, 2 assertions, 0 error, 0 exception)!

Step 6: Complete your tests and restart the cycle from Step 3

<?php

namespace vendor\project\tests\units;

require_once 'path/to/atoum.phar';

include_once 'path/to/project/classes/helloWorld.php';

use atoum\atoum;
use vendor\project;

class helloWorld extends atoum\test
{
    public function test__construct()
    {
        $helloWorld = new project\helloWorld();

        $this
            ->string($helloWorld->say())->isEqualTo('Hello!')
            ->string($helloWorld->say($name = 'Frédéric Hardy'))->isEqualTo('Hello ' . $name . '!')
        ;
    }
}

To go further

atoum's documentation is still being written. Any help to improve it will be appreciated. However, if you want to further explore immediately atoum's possibilities, we recommend:

  • Running in your terminal, either the command php atoum.phar -h, or the command php scripts/runner.php -h,
  • Exploring the contents of the configurations directory in atoum's source, as it contains configuration file samples,
  • Exploring the contents of the tests/unit/classes directory in atoum's source, as it contains all of the unit tests,
  • Read the (french) conference slides about it, available online,
  • Read the (french) wiki,
  • Join the IRC channel ##atoum on the Freenode network,
  • Ask questions by e-mail at the address support[AT]atoum(DOT)org.

Troubleshooting

atoum's PHAR archive seems to not be working

In this case, the first thing you will want to do is confirm whether you have the latest version of the archive. You just need to download it again. If it still doesn't work, run the following command in a terminal window:

$ php -n atoum.phar -v

If you get atoum's version number, then the problem is coming from your PHP configuration. In most cases, the cause would be within extensions, that might be incompatible with the PHAR format, or that would prevent executing PHAR archives as a security measure. The ioncube extension for instance seems incompatible with PHAR archives, and you must, therefore, deactivate it if you are using it, by commenting the following line out of your php.ini, by prefixing it with the ; character:

zend_extension = /path/to/ioncube_loader*.*

The suhosin extension prevents executing PHAR archives, therefore its default configuration must be modified in order to be able to use atoum, by adding the following line in your php.ini file:

suhosin.executor.include.whitelist="phar"

Finally, if running atoum causes the screen to display characters looking like ???%, this would be because the detect_unicode directive inside your php.ini file is set to 1. To fix the problem, you just need to set it to 0 by editing your php.ini file or by running atoum with the following command:

$ php -d detect_unicode=0 atoum.phar [options]

If these three operations do not allow atoum to work, we suggest you send an e-mail to the address support[AT]atoum(DOT)org, describing in detail your configuration and your problem. You can also ask for help from the atoum development staff on the IRC channel ##atoum on the Freenode network.

Error: Constant __COMPILER_HALT_OFFSET__ already defined /path/to/atoum.phar

This error comes from the fact the atoum PHAR archive is included in more than one place within your code using include or require. To fix this problem, you just need to include the archive by using only include_once or require_once, in order to ensure it is not included several times.

APC seems not work with atoum

APC is a free, open, and robust framework for caching and optimizing PHP intermediate code distributed under the form of a PHP extension. When testing classes that use APC, you may get some failure message showing that apc_fetch function is unable to retrieve a value. As all PHP extension, APC has some configuration options to enable it:

  • apc.enabled whether to enable or disable APC,
  • apc.enable_cli, whether to enable or disable APC for PHP CLI.

In order to use APC with atoum, you have to set apc.enabled and apc.enable_cli to 1, otherwise, it won't be enabled for the PHP CLI version, which is used by atoum.

Getting segfault when mocking objects

When using atoum and mocking objects, you will sometime get segfaults coming from PHP. These segfaults are caused by XDebug in version less than 2.1.0 which has problem handling reflection in some cases. To check the current version of XDebug, you can run php -v. To fix this issue, you have to update XDebug to the latest stable version. If you can't update XDebug on your system, you can still disable the extension to avoid getting segfaults. To be sure that XDebug has been successfully updated or disabled, you can run php -v. When you are done updating or disabling XDebug, run php atoum.phar --test-it to be sure that all the segfaults have gone and that atoum is working.


Roadmap

Looking for a roadmap?

Credits

atoum has been created by Frédéric Hardy. It is now led by a strong community of contributors. You can find them in the committer list or in the Contributors team.

License

atoum is released under the BSD-3-Clause License. See the bundled LICENSE file for details.

Comments
  • Rolling and tagging

    Rolling and tagging

    I think discussions about rolling-releases and tag strategy are a bit messy and also dispatched among several issues, so let's try to gather evrything here:

    • in #281
    • in #285, starting from : https://github.com/atoum/atoum/pull/285#issuecomment-27682792
    • twitter, IRC, ...

    So let me sum-up:

    • atoum is actually not tagged
    • atoum follows the rolling-release principle
    • atoum contributors are working hard to maintain a maximum BC
    • no tag could lead to undesirable side-effects on projects using atoum
    • adopting tags would "ease" working with composer

    What has been proposed:

    • adopting tags in conjuction with rolling-release: the two concepts are not exclusive, the master branch could still be used as the rolling one and the tags would be here for those who don't want to adopt rolling-release
    • being semver compliant: to me, if we adopt tag, we should (must ?) follow semver for several reason. Tags would have semantical meanings, everybody understand that and it works great with composer and version constraints
    • using a custom tag format (like the one @Hywan proposed)

    What we have to define before doing anything:

    • What would be the release cycle ? we put a tag on each push ? each day/week/month ? ...
    • What would be the mainteannce policy ? should we maintain minor versions or encourage users to update to the next release when they get a bug ?
    • Who will be the release manager ? a bot ?
    • What is the tag format ? x.y.z is a good scheme but it does not do everything:
      • x would start at 0 or 1 ?
      • should we only increment z on minor (non breaking) changes and y otherwize ?
    • Where do we put/ talk about those decisions ? In the readme via the #285 ? in the FAQ ?

    There could be some more questions to answer, please, let us know if you see something missing here :)

    opened by jubianchi 50
  • PHP5.3 is reaching its EOL, PHP5.4 FTW?

    PHP5.3 is reaching its EOL, PHP5.4 FTW?

    Hello :-),

    atoum requires PHP5.3 as the lowest PHP version needed to run it (we will call it LRPV, standing for Lowest Required PHP Version). PHP5.3 is reaching its EOL (this month). Thus, I propose to use PHP5.4 as the new LRPV.

    This is for the sake of good practises and the PHP ecosystem. However, I understand that some users are still using PHP5.3 and won't be able to migrate as soon as possible. That's why I am opening this discussion.

    Pros of using PHP5.4 as the LRPV:

    • some tricky code will be dropped (and we are talking about several hundreds of LOC),
    • (consequentely) code will be easier to maintain,
    • global performances.

    Cons of using PHP5.4 as the LRPV:

    • some users are not using 5.4, even if they must (because 5.3 will be definitively dead).

    As a reminder, PHP5.2 is dead since 3 years and 6 months. See others. I don't know what is the plan for Symfony but Hoa will use 5.4 as the LRPV in the following weeks. Laravel is already using 5.4 etc. However, I admit the constraints are not the same for those projects.

    Thoughts?

    opened by Hywan 46
  • Remove implementation of test hooks

    Remove implementation of test hooks

    This will help us make the phpunit extension work.

    PHPUnit also defines hooks which are in conflict with atoum ones. We make the method "virtual" by removing their implementations and using a runtime check to see if they are implemented in test classes.

    ready 
    opened by jubianchi 36
  • Organization account for atoum ?

    Organization account for atoum ?

    This is kind of related to #88, but now that atoum starts to live his own life, won't it be a good time for him to leave his father's home ?

    We could transfer ownership of current repositories to this new organization.

    What do you think about it ?

    opened by geraldcroes 36
  • Test protected method

    Test protected method

    Hi,

    since the documentation was not up to date and I don't follow recent features of atoum, I would like to know if it is always not possible to test a protected method directly or via a mock or via an other wonderfull technical.

    I know this is a delicate question and @mageekguy did not want to implement this feature, but I just want to know if it is possible right now.

    If it is still not, I would like to open peaceful discussion about that point because I think this is a convenient feature for all testers.

    During our last discussion about that, @mageekguy tell us (on irc chan) that a unit test should test only public API, so only public method. He asks us why this methods are not public and he suggests to modify method we want to test to public visibility. In my mind (and I'm not the only one to think like that), as a class developper, I want to expose a public API of my class and "hide" internal methods with protected methods. I use very rarely private visibility because I think that all can be modified by inheritance. (But for that point, it's my only point of view and, this is not the subject of this issue). So, I want to test my public API and atoum offer me all the tools I need to do that (and very big thank you about that !). But, sometimes (frequently, in fact), I want to test an internal method because it contains some sensible piece of code.

    In my mind, I could compare public/protected tests with functional/unit tests. If I functionaly test only my application, it's good, but I only test the results and I can't be "sure" that all the internal bricks work. So i unit test. If I test only public methods, it's good, but I only test the results again and I can't be "sure" that all the internal bricks work...

    I don't want to use reflection to change visibility, it's a very dirty hack which cause much problem that it resolves. I thought about automatic/magic "test{methodName}" methods who call parent "methodName" method and return result that we could test with all wonderful tools that offer atoum.

    Because I do not have much hope to see this feature added, what technical solution I can use to add this feature in my atoum configuration. In another words, how can create "plugins" to atoum ? (Maybe, I should open a new ticket for this last question ?)

    opened by marmotz 35
  • The road to 3.0

    The road to 3.0

    Everything in the following list is under discussion, feel free to send feedback on anything. Additionally, If you see something missing, please tell me.

    • [x] Require a higher PHP version (at least >= 5.6) (#643)
    • [x] #646 - Require a higher xDebug version (>= 2.3.0) and add it to suggest in composer.json (#651)
    • [x] #653 - Remove all code relying on method_exists
      • [x] in mageekguy\atoum\factory\builder\closure::isVariadic()
      • [x] in mageekguy\atoum\mock\generator::getParameterType() (line 699)
      • [x] in mageekguy\atoum\mock\generator::isVariadic()
      • [x] in mageekguy\atoum\php\mocker\funktion::getParameterType()
      • [x] in mageekguy\atoum\score\coverage::getDeclaringClass()
    • [x] #647 - Remove all tests that are not relevant on the minimum PHP version (< 5.6) (#657)
    • [x] #647 - Remove PHP version filter where it target >= 5.6 (#657)
    • [x] Remove all PHP versions that are not relevant from CI (#643)
    • [x] #648 - Remove deprecated methods (#650)
      • [x] mageekguy\atoum\asserters\dateTime::isInYear()
      • [x] mageekguy\atoum\asserters\dateTime::isInMonth()
      • [x] mageekguy\atoum\asserters\dateTime::isInDay()
      • [x] mageekguy\atoum\asserters\stream::isWrited()
    • [x] #652 - Remove deprecated CLI flags (#656)
      • [x] --test-all and its handler (in mageekguy\atoum\scripts\runner, line 1014)
      • [x] mageekguy\atoum\scripts\runner::addTestAllDirectory()
    • [x] Merge #615
    • [x] Revert 9c6772ad6: closure are bound to te current object context, no need to pass the test instance anymore
    • [x] Remove all $this assignation that are only for closures uses (#658)
    • [x] #645 - Remove all code relying on version_compare (#649):
      • [x] in mageekguy\atoum\autoloader::exists() (5.4.0)
      • [x] in mageekguy\atoum\asserters\dateTime::isImmutable() (5.5.0)
      • [x] in mageekguy\atoum\asserters\dateTime::isDateTime() (5.5.0)
      • [x] in mageekguy\atoum\test\adapter\invoker::isBindable() (5.4.0)
    • [x] Move fancy reports to the reports-extension (santa, nyancat, logo, ...) (https://github.com/atoum/atoum/pull/644 / https://github.com/atoum/reports-extension/pull/26)
    • [x] Apply PSR-1 and PSR-2 (#642)
    • [x] Make atoum\atoum the real root namespace and alias it to mageekguy\atoum
    • [ ] Extract builder, pusher and other tools to a dedicated repository
    • [ ] Add a test on mock auto-binding (in tests/functionals)
    • [x] Add a generator asserter: (#664)
      • [x] with a yields assertion
      • [x] with a returns assertion (PHP >= 7.0)
    • [x] Write a UPGRADE guide (#697)

    Experiment / Discuss

    • [ ] Extract asserters to a dedicated library atoum/asserters to ease reuse in other tools (Behat for example)
    • [ ] Extract the mock engine to a dedicated library atoum/mock to ease reuse in other testing frameworks
    • [ ] Replace all \closure typehint with a callable typehint
    • [ ] Make the test namespace configurable without having to extend the base test class
    • [x] Write an Homebrew formula
    • [x] #694 - Extract the VIM plugin to its own repository (atoum/vim-plugin)
    • [ ] Extract the Phing task to a dedicated library/repository (#654)
    opened by jubianchi 34
  • PHAR build broken ?

    PHAR build broken ?

    The last PHAR archive seems to be old:

    $ php mageekguy.atoum.phar -version
    atoum version nightly-2416-201402121146 by Frédéric Hardy
    
    $ php -d phar.readonly=0 vendor/mageekguy.atoum.phar -update
    Checking if a new version is available... Done !
    There is no new version available !
    
    bug in progress 
    opened by marmotz 33
  • How to do conditionnal assertions ?

    How to do conditionnal assertions ?

    Hello as a beginner Atoum user I'm confronted to a problem. I want to make different assertions depending of the return value of a method.

    Here is a quick example :

    class Armaggedon
    {
            private EndDate;
    
        public function __construct($aParam)
        { 
            $this->EndDate= $aParam; 
        } 
        public function apocalypse()
        {
            if($this->EndDate==2012)
                return true;
                    else
                    return false;
        }
    }
    

    I want to test if the return value is a boolean, but also if it's true when value of EndDate is 2012 and false in other case.

    How can I implement the test class of Armaggedon ?

    Thanks for your future answers.

    opened by glonglon 32
  • Semver

    Semver

    Hey,

    I am really surprised to notice that there is not tag/branch alias on packagist. Could you start tagging releases, have branch aliases etc please ?

    opened by adrienbrault 31
  • Replace void by blank

    Replace void by blank

    Void is now a reserved keyword in PHP-7.1. This patch replace all required call from void to blank

    This PR fix https://github.com/atoum/atoum/issues/598

    bug ready 
    opened by vonglasow 29
  • Introduce the constant mocker

    Introduce the constant mocker

    Fix #511.

    In 2 steps

    Split PHP mocker

    The PHP mocker is splitted into 2 layers:

    1. Abstract mocker, containing all namespace logic,
    2. Function mocker.

    The goal is to be able to introduce another mocker. So we must decouple this part first.

    Introduce the constant mocker

    We use it the same way we use the function mocker:

    $this->constant->PHP_VERSION_ID = '606060'; // troll \o/
    

    Note: This is used to mock constants, not class constants.

    Thoughts?

    in progress enhancement 
    opened by Hywan 29
  • Silent failures (when ini_set('display_errors', 0))

    Silent failures (when ini_set('display_errors', 0))

    It's unfortunately a quite common case: running tests fails without any error, causes can be multiple:

    • a syntax error in a php file
    • inheritance issue (try for example to override a protected method with a private one),
    • ...

    That's annoying, but syntax errors can be checked with php -l, and looking deep at the code permit to solve several other ones.

    This time, I'm trying to run my test suite with php 8.1 on github actions and it fails silently. I have absolutely no idea what goes wrong. Tests are just running fine locally :/ See for example: https://github.com/galette/galette/runs/4053979832?check_suite_focus=true

    Any idea how to get more info on that fail? Thanks!

    enhancement 
    opened by trasher 2
  • How to use atoum on a project with no classes?

    How to use atoum on a project with no classes?

    I am trying to test functions in a given .php file using atoum. These functions are namespaced, but are not part of a class. atoum appears to expect a class to exist which has the same name of the test class, and so then fails outright as a result. Is there a way to use atoum without needing to use classes?

    opened by samuelludwig 3
  • Question about execution order

    Question about execution order

    Hello, I have a test class with 5 functions to test. I have a function beforeTestMethod. My question is: Why is beforeTestMethod executed 5 times before the test functions are executed? I thought that beforeTestMethod was executed just before the tested function. In the doc

    The methods beforeTestMethod() and afterTestMethod() allows respectively to initialize and clean up the execution environment of the individual tests for all test method of the class. In contrast of setUp() and tearDown(), they are executed in the same subprocess

    In my mind:

    beforeTestMethod()
    testOne()
    beforeTestMethod()
    testTwo()
    ....
    beforeTestMethod()
    testFive()
    

    actual

    beforeTestMethod()
    beforeTestMethod()
    beforeTestMethod()
    beforeTestMethod()
    beforeTestMethod()
    testOne()
    testTwo()
    testThree()
    testFour()
    testFive()
    

    Is it normal ? REgards

    opened by nenes82 4
  • HTML coverage not produced using --use-dot-report

    HTML coverage not produced using --use-dot-report

    I've configured both HTML and clover coverage reports like this:

    $coverage_dir = __DIR__ . '/tests/';
    $coverageField = new atoum\atoum\report\fields\runner\coverage\html(
        'GLPI',
        $coverage_dir
    );
    $coverageField->setRootUrl('file://' . realpath($coverage_dir));
    
    $script
        ->addDefaultReport()
        ->addField($coverageField);
    
    $cloverWriter = new atoum\atoum\writers\file($coverage_dir . 'clover.xml');
    $cloverReport = new atoum\atoum\reports\asynchronous\clover();
    $cloverReport->addWriter($cloverWriter);
    
    $runner->addReport($cloverReport);
    

    When running tests with the standard output; both clover and HTML are present in the coverage directory. When using the --use-dot-report flag; only the clover.xml file is generated. Have I missed something?

    bug 
    opened by trasher 2
  • strign contains in array has a strange behavior

    strign contains in array has a strange behavior

    There are several strange behaviors when trying to tests array values from the array asserter.

    An example I've just fixed (see https://github.com/glpi-project/glpi/commit/01e3e101c8614d5e9494ca55130c881f6d1ea149).

    The $this->array($event->fields)->string['name']->contains('Copy of %s') should have fail because the name is "Copy of test event to clone". Most strange is I have the same code working and not working on different glpi branches, but the same atoum, php, etc... versions (I still cannot explain that).

    In GLPI team, several person (incluging myself) already has quite strange issues with assertions on array values; but I cannot give more details, nor always reproducible use case right now.

    opened by trasher 0
  • Mocking an Throwable interface produces an error

    Mocking an Throwable interface produces an error

    Given we have:

    <?php
    
    interface MyThrowable extends Throwable {
        //...
    }
    

    If we try to mock this interface, it results in an error:

    Class MyThrowable cannot implement interface Throwable, extend Exception or Error instead
    
    bug 
    opened by jubianchi 1
Releases(4.1.0)
Owner
atoum
Home of the modern, simple and intuitive PHP unit testing framework.
atoum
SimpleTest is a framework for unit testing, web site testing and mock objects for PHP

SimpleTest SimpleTest is a framework for unit testing, web site testing and mock objects for PHP. Installation Downloads All downloads are stored on G

SimpleTest 147 Jun 20, 2022
vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.

vfsStream vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with

null 1.4k Dec 23, 2022
PHP unit testing framework with built in mocks and stubs. Runs in the browser, or via the command line.

Enhance PHP A unit testing framework with mocks and stubs. Built for PHP, in PHP! Quick Start: Just add EnhanceTestFramework.php and you are ready to

Enhance PHP 67 Sep 12, 2022
The PHP Unit Testing framework.

PHPUnit PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks. Installat

Sebastian Bergmann 18.8k Jan 4, 2023
Unit testing tips by examples in PHP

Unit testing tips by examples in PHP Introduction In these times, the benefits of writing unit tests are huge. I think that most of the recently start

Kamil Ruczyński 894 Jan 4, 2023
Real-world Project to learning about Unit Testing/TDD with Laravel for everybody

KivaNote - a Laravel TDD Sample Project Let me introduce you to KivaNote, a simple real-world application using Laravel to show you how the TDD & Unit

(Seth) Phat Tran 10 Dec 31, 2022
Package for unit testing Laravel form request classes

Package for unit testing Laravel form request classes. Why Colin DeCarlo gave a talk on Laracon online 21 about unit testing Laravel form requests cla

null 18 Dec 11, 2022
Learn unit testing with PHPUnit.

PHPUnit Exercise Running PHPUnit ./vendor/bin/phpunit # with filter which tests to run ./vendor/bin/phpunit --filter <pattern> Running Pint ./vendor/

Nopal 2 Aug 23, 2022
Mock HTTP requests on the server side in your PHP unit tests

HTTP Mock for PHP Mock HTTP requests on the server side in your PHP unit tests. HTTP Mock for PHP mocks the server side of an HTTP request to allow in

InterNations GmbH 386 Dec 27, 2022
PHP Test Generator - A CLI tool which generates unit tests

This project make usages of PHPStan and PHPParser to generate test cases for a given PHP File.

Alexander Schranz 7 Dec 3, 2022
To run time/IO related unit tests (e.g., sleep function calls, database queries, API calls, etc) faster using Swoole.

To run time/IO related unit tests (e.g., sleep function calls, database queries, API calls, etc) faster using Swoole.

Demin Yin 11 Sep 9, 2022
Full-stack testing PHP framework

Codeception Modern PHP Testing for everyone Codeception is a modern full-stack testing framework for PHP. Inspired by BDD, it provides an absolutely n

Codeception Testing Framework 4.6k Jan 7, 2023
AST based PHP Mutation Testing Framework

Infection - Mutation Testing framework Please read documentation here: infection.github.io Twitter: @infection_php Discord: https://discord.gg/ZUmyHTJ

Infection - Mutation Testing Framework for PHP 1.8k Jan 2, 2023
Pest is an elegant PHP Testing Framework with a focus on simplicity

Pest is an elegant PHP Testing Framework with a focus on simplicity. It was carefully crafted to bring the joy of testing to PHP. Explore the docs: pe

PEST 5.9k Dec 27, 2022
Humbug - a Mutation Testing framework for PHP

Humbug is a Mutation Testing framework for PHP to measure the real effectiveness of your test suites and assist in their improvement. It eats Code Coverage for breakfast.

Humbug 1.1k Dec 28, 2022
A drop in fake logger for testing with the Laravel framework.

Log fake for Laravel A bunch of Laravel facades / services are able to be faked, such as the Dispatcher with Bus::fake(), to help with testing and ass

Tim MacDonald 363 Dec 19, 2022
Very simple mock HTTP Server for testing Restful API, running via Docker.

httpdock Very simple mock HTTP Server for testing Restful API, running via Docker. Start Server Starting this server via command: docker run -ti -d -p

Vo Duy Tuan 4 Dec 24, 2021
Infrastructure and testing helpers for creating CQRS and event sourced applications.

Broadway is a project providing infrastructure and testing helpers for creating CQRS and event sourced applications. Broadway tries hard to not get in your way.

null 1.5k Dec 30, 2022
PHP libraries that makes Selenium WebDriver + PHPUnit functional testing easy and robust

Steward: easy and robust testing with Selenium WebDriver + PHPUnit Steward is a set of libraries made to simplify writing and running robust functiona

LMC s.r.o. 219 Dec 17, 2022