Skip to content

Only output slowness report when explicitly enabled #63

@johnkary

Description

@johnkary

PHPUnit may be configured with runtime options that alter its output or generated reports, such as --coverage-html or --log-junit or --testdox-html

Currently the slowness report is output on every test suite execution when SpeedTrapListener is enabled in phpunit.xml. This may not be desired when running PHPUnit with other options. For example, generating code coverage via --coverage-html is an opt-in runtime option. SpeedTrap should behave similarly.

Instead, the slowness report should only output when at least one of the following is true:

  1. Providing runtime command-line argument: --speedtrap
  2. PHP environment variable PHPUNIT_SPEEDTRAP has a string value of "enabled"

PHP environment variables can be set in php.ini or any method supported by PHP.

PHP environment variables can also be set using phpunit.xml:

<phpunit>
    <php>
        <env name="PHPUNIT_SPEEDTRAP" value="enabled" />
    </php>
</phpunit>

Feedback requested

  1. Are there any other ways we should support opt-in slowness reporting?
  2. What do you think of the name --speedtrap for runtime option? I'm not sure if/how this option's presence can be detected by the listener, but it can probably be done.
  3. What do you think of the name PHPUNIT_SPEEDTRAP for the environment variable? This name scopes it into a fake namespace (PHPUNIT) and specific to this library (SPEEDTRAP).
  4. Suggestions for PHPUNIT_SPEEDTRAP variable value to declare the listener should be enabled? I proposed string "enabled" because: 1) environment variables should always assume to be strings; 2) using a word prevents accidental type casting (i.e. "true" could become a boolean, "1" could be come an int or boolean; 3) the word definition of "enabled" declares exactly its effect on the listener behavior.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions