Download the PHP package johnkary/phpunit-speedtrap without Composer

On this page you can find all versions of the php package johnkary/phpunit-speedtrap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpunit-speedtrap

phpunit-speedtrap

Integrate

SpeedTrap reports on slow-running PHPUnit tests right in the console.

Many factors affect test execution time. A test not properly isolated from variable latency (database, network, etc.) and even basic load on the test machine will cause test execution times to fluctuate.

SpeedTrap helps identify slow tests but cannot explain why those tests are slow. Consider using Blackfire.io to profile the test suite to specifically identify slow code.

Screenshot of terminal using SpeedTrap

Installation

SpeedTrap is installed using Composer. Add it as a require-dev dependency:

composer require --dev johnkary/phpunit-speedtrap

Usage

Enable with all defaults by adding the following code to your project's phpunit.xml file:

Now run the test suite. If one or more test executions exceed the slowness threshold (500ms by default), SpeedTrap will report on those tests in the console after all tests have completed.

Config Parameters

SpeedTrap also supports these parameters:

Each parameter is set in phpunit.xml:

Custom slowness threshold per-test case

Some projects have a few complex tests that take a long time to run. It is possible to set a different slowness threshold for individual test cases.

The annotation @slowThreshold can set a custom slowness threshold for each test case. This number may be higher or lower than the default threshold and is used instead of the default threshold for that specific test.

Setting @slowThreshold 0 will never report that test as slow.

Disable slowness profiling using an environment variable

SpeedTrap profiles for slow tests when enabled in phpunit.xml. But using an environment variable named PHPUNIT_SPEEDTRAP can enable or disable the extension:

$ PHPUNIT_SPEEDTRAP="disabled" ./vendor/bin/phpunit

Use case: Disable profiling in development, but profile with Travis CI

Travis CI is popular for running tests in the cloud after pushing new code to a repository.

Step 1) Enable SpeedTrap in phpunit.xml, but set PHPUNIT_SPEEDTRAP="disabled" to disable profiling when running tests.

Step 2) Configure .travis.yml with PHPUNIT_SPEEDTRAP="enabled" to profile for slow tests when running on Travis CI:

Step 3) View the Travis CI build output and read the slowness report printed in the console.

Travis CI Documentation - Environment Variables

Use case: Enable profiling in development, but disable with Travis CI

Step 1) Enable SpeedTrap in phpunit.xml. The slowness report will output during all test suite executions.

Step 2) Configure .travis.yml with PHPUNIT_SPEEDTRAP="disabled" to turn off profiling when running on Travis CI:

Step 3) View the Travis CI build output and confirm the slowness report is not printed in the console.

Use case: Only enable SpeedTrap on demand via command-line

Useful when you only want to profile slow tests once in a while.

Step 1) Setup phpunit.xml to enable SpeedTrap, but disable slowness profiling by setting PHPUNIT_SPEEDTRAP="disabled" like this:

Step 2) When executing phpunit from the command-line, enable slowness profiling only for this run by passing the environment variable PHPUNIT_SPEEDTRAP="enabled" like this:

Using with Symfony Framework

Symfony Framework comes with package symfony/phpunit-bridge that installs its own version of PHPUnit and ignores what is defined in your project's composer.json or composer.lock file. See the PHPUnit versions it installs with command ls vendor/bin/.phpunit/

symfony/phpunit-bridge allows environment variable SYMFONY_PHPUNIT_REQUIRE to define additional dependencies while installing phpunit.

The easiest way to set environment variables for the script simple-phpunit is via phpunit.xml.dist:

Using the above example, running vendor/bin/simple-phpunit will now install the latest PHPUnit 9 and require the latest phpunit-speedtrap v4.

Development

Follow these steps to add new features or develop your own fork:

Inspiration

SpeedTrap was inspired by RSpec's --profile option that displays feedback about slow tests.

License

phpunit-speedtrap is available under the MIT License.


All versions of phpunit-speedtrap with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
phpunit/phpunit Version ^7.0 || ^8.0 || ^9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package johnkary/phpunit-speedtrap contains the following files

Loading the files please wait ....