usernam3/phpunit_stopwatch_annotations

phpunit test case with support for execution time and memory usage assertion in annotations

dev-master 2015-08-02 14:27 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:37:04 UTC


README

PHPUnit stopwatch annotations is a PHPUnit test case with support for execution time and memory usage assertion in annotations. It uses symfony/Stopwatch component for tracking time and memory usage of tests.

Installation

Via Composer

	composer require --dev "usernam3/phpunit_stopwatch_annotations:dev-master"

Usage

To add support of @executionTime and @memoryUsage annotations you need to extend your test case class from \StopwatchAnnotations\TestCase.

@executionTime value is measured in milliseconds @memoryUsage in bytes.

Example of test case:

class ExampleTest extends \StopwatchAnnotations\TestCase {
    /**
     * @test
     * @executionTime 1999
     */
    public function executionTimeFailed()
    {
        sleep(2);
    }
    
    /**
    * @test
    * @memoryUsage 2000000
    */
    public function memoryUsageFailed()
    {
    
    }
}