PHP Class JohnKary\PHPUnit\Listener\SpeedTrapListener

Inheritance: implements PHPUnit_Framework_TestListener
Datei anzeigen Open project: johnkary/phpunit-speedtrap

Protected Properties

Property Type Description
$reportLength integer Number of tests to report on for slowness.
$slow array Collection of slow tests.
$slowThreshold integer Time in milliseconds at which a test will be considered "slow" and be reported by this listener.
$suites integer Increments as more suites are run, then decremented as they finish. All suites have been run when returns to 0.

Public Methods

Method Description
__construct ( array $options = [] ) Construct a new instance.
addError ( PHPUnit_Framework_Test $test, Exception $e, float $time ) An error occurred.
addFailure ( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, float $time ) A failure occurred.
addIncompleteTest ( PHPUnit_Framework_Test $test, Exception $e, float $time ) Incomplete test.
addRiskyTest ( PHPUnit_Framework_Test $test, Exception $e, float $time ) Risky test.
addSkippedTest ( PHPUnit_Framework_Test $test, Exception $e, float $time ) Skipped test.
endTest ( PHPUnit_Framework_Test $test, float $time ) A test ended.
endTestSuite ( PHPUnit_Framework_TestSuite $suite ) A test suite ended.
startTest ( PHPUnit_Framework_Test $test ) A test started.
startTestSuite ( PHPUnit_Framework_TestSuite $suite ) A test suite started.

Protected Methods

Method Description
addSlowTest ( PHPUnit_Framework_TestCase $test, integer $time ) Stores a test as slow.
getHiddenCount ( ) : integer Find how many slow tests occurred that won't be shown due to list length.
getReportLength ( ) : integer Calculate number of slow tests to report about.
getSlowThreshold ( PHPUnit_Framework_TestCase $test ) : integer Get slow test threshold for given test. A TestCase can override the suite-wide slow threshold by using the annotation @slowThreshold with the threshold value in milliseconds.
hasSlowTests ( ) : boolean Whether at least one test has been considered slow.
isSlow ( integer $time, integer $slowThreshold ) : boolean Whether the given test execution time is considered slow.
loadOptions ( array $options ) Populate options into class internals.
makeLabel ( PHPUnit_Framework_TestCase $test ) : string Label for describing a test.
renderBody ( ) Renders slow test report body.
renderFooter ( ) Renders slow test report footer.
renderHeader ( ) Renders slow test report header.
toMilliseconds ( float $time ) : integer Convert PHPUnit's reported test time (microseconds) to milliseconds.

Method Details

__construct() public method

Construct a new instance.
public __construct ( array $options = [] )
$options array

addError() public method

An error occurred.
public addError ( PHPUnit_Framework_Test $test, Exception $e, float $time )
$test PHPUnit_Framework_Test
$e Exception
$time float

addFailure() public method

A failure occurred.
public addFailure ( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, float $time )
$test PHPUnit_Framework_Test
$e PHPUnit_Framework_AssertionFailedError
$time float

addIncompleteTest() public method

Incomplete test.
public addIncompleteTest ( PHPUnit_Framework_Test $test, Exception $e, float $time )
$test PHPUnit_Framework_Test
$e Exception
$time float

addRiskyTest() public method

Risky test.
public addRiskyTest ( PHPUnit_Framework_Test $test, Exception $e, float $time )
$test PHPUnit_Framework_Test
$e Exception
$time float

addSkippedTest() public method

Skipped test.
public addSkippedTest ( PHPUnit_Framework_Test $test, Exception $e, float $time )
$test PHPUnit_Framework_Test
$e Exception
$time float

addSlowTest() protected method

Stores a test as slow.
protected addSlowTest ( PHPUnit_Framework_TestCase $test, integer $time )
$test PHPUnit_Framework_TestCase
$time integer Test execution time in milliseconds

endTest() public method

A test ended.
public endTest ( PHPUnit_Framework_Test $test, float $time )
$test PHPUnit_Framework_Test
$time float

endTestSuite() public method

A test suite ended.
public endTestSuite ( PHPUnit_Framework_TestSuite $suite )
$suite PHPUnit_Framework_TestSuite

getHiddenCount() protected method

Find how many slow tests occurred that won't be shown due to list length.
protected getHiddenCount ( ) : integer
return integer Number of hidden slow tests

getReportLength() protected method

Calculate number of slow tests to report about.
protected getReportLength ( ) : integer
return integer

getSlowThreshold() protected method

The following test will only be considered slow when its execution time reaches 5000ms (5 seconds): \@slowThreshold 5000 public function testLongRunningProcess() }
protected getSlowThreshold ( PHPUnit_Framework_TestCase $test ) : integer
$test PHPUnit_Framework_TestCase
return integer

hasSlowTests() protected method

Whether at least one test has been considered slow.
protected hasSlowTests ( ) : boolean
return boolean

isSlow() protected method

Whether the given test execution time is considered slow.
protected isSlow ( integer $time, integer $slowThreshold ) : boolean
$time integer Test execution time in milliseconds
$slowThreshold integer Test execution time at which a test should be considered slow (milliseconds)
return boolean

loadOptions() protected method

Populate options into class internals.
protected loadOptions ( array $options )
$options array

makeLabel() protected method

Label for describing a test.
protected makeLabel ( PHPUnit_Framework_TestCase $test ) : string
$test PHPUnit_Framework_TestCase
return string

renderBody() protected method

Renders slow test report body.
protected renderBody ( )

renderFooter() protected method

Renders slow test report footer.
protected renderFooter ( )

renderHeader() protected method

Renders slow test report header.
protected renderHeader ( )

startTest() public method

A test started.
public startTest ( PHPUnit_Framework_Test $test )
$test PHPUnit_Framework_Test

startTestSuite() public method

A test suite started.
public startTestSuite ( PHPUnit_Framework_TestSuite $suite )
$suite PHPUnit_Framework_TestSuite

toMilliseconds() protected method

Convert PHPUnit's reported test time (microseconds) to milliseconds.
protected toMilliseconds ( float $time ) : integer
$time float
return integer

Property Details

$reportLength protected_oe property

Number of tests to report on for slowness.
protected int $reportLength
return integer

$slow protected_oe property

Collection of slow tests.
protected array $slow
return array

$slowThreshold protected_oe property

Time in milliseconds at which a test will be considered "slow" and be reported by this listener.
protected int $slowThreshold
return integer

$suites protected_oe property

Increments as more suites are run, then decremented as they finish. All suites have been run when returns to 0.
protected int $suites
return integer