Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startTestSuite is call on every unit test #3877

Closed
fezfez opened this issue Oct 2, 2019 · 3 comments
Closed

startTestSuite is call on every unit test #3877

fezfez opened this issue Oct 2, 2019 · 3 comments
Labels
feature/test-runner CLI test runner type/bug Something is broken

Comments

@fezfez
Copy link

fezfez commented Oct 2, 2019

Q A
PHPUnit version 8.3.5, 8.2.5, 8.1.6, 8.0.6, 7.5.16, 7.4.5, 7.3.5, 7.2.7, 7.1.5
PHP version 7.3.4, 7.4RC1, 7.2.25
Installation Method Composer

Summary

i have added

var_dump(__METHOD__.' '.$suite->getName()); 

on

public function startTestSuite(TestSuite $suite): void
{
if ($this->topTestSuite === null) {

and

var_dump(__METHOD__.' '. $result->count());

on

Current behavior

PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.0RC1
Configuration: /var/www/phpunit.xml.dist
Random seed:   1570011937

string(34) "PHPUnit\Framework\TestSuite::run 0"
string(45) "PHPUnit\Framework\TestResult::startTestSuite "
string(34) "PHPUnit\Framework\TestSuite::run 0"
string(49) "PHPUnit\Framework\TestResult::startTestSuite unit"
string(34) "PHPUnit\Framework\TestSuite::run 0"
string(103) "PHPUnit\Framework\TestResult::startTestSuite RoaveUnitTest\NoLeaks\PHPUnit\EmptyBaselineMemoryUsageTest"
.string(34) "PHPUnit\Framework\TestSuite::run 1"
string(115) "PHPUnit\Framework\TestResult::startTestSuite RoaveUnitTest\NoLeaks\PHPUnit\CollectTestExecutionMemoryFootprintsTest"
......string(34) "PHPUnit\Framework\TestSuite::run 7"
string(104) "PHPUnit\Framework\TestResult::startTestSuite RoaveUnitTest\NoLeaks\PHPUnit\MeasuredTestRunMemoryLeakTest"
.......string(35) "PHPUnit\Framework\TestSuite::run 14"
string(109) "PHPUnit\Framework\TestResult::startTestSuite RoaveUnitTest\NoLeaks\PHPUnit\MeasuredBaselineTestMemoryLeakTest"
......                                              20 / 20 (100%)

Time: 32 ms, Memory: 6.00 MB

OK (20 tests, 27 assertions)

How to reproduce

run https://github.com/Roave/no-leaks unit

Expected behavior

PHPUnit 8.3.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.0RC1
Configuration: /var/www/phpunit.xml.dist
Random seed:   1570011937

string(34) "PHPUnit\Framework\TestSuite::run 0"
string(49) "PHPUnit\Framework\TestResult::startTestSuite unit"
string(34) "PHPUnit\Framework\TestSuite::run 0"
.string(34) "PHPUnit\Framework\TestSuite::run 1"
......string(34) "PHPUnit\Framework\TestSuite::run 7"
.......string(35) "PHPUnit\Framework\TestSuite::run 14"
......                                              20 / 20 (100%)

Time: 32 ms, Memory: 6.00 MB

OK (20 tests, 27 assertions)

related : Roave/no-leaks#22

@fezfez fezfez added the type/bug Something is broken label Oct 2, 2019
@epdenouden
Copy link
Contributor

This is one to investigate, also in light of the upcoming dataprovider improvements. Providers are wrapped in a suite, too

Might be just the logging. We'll have a looksy during the hackathon this weekend

@fezfez
Copy link
Author

fezfez commented Oct 2, 2019

Maybe repeat option is buggy too because she is considering a testsuite is same thing as a test (addTest instead of addTestSuite if it's a testsuite)

if (\is_int($arguments['repeat']) && $arguments['repeat'] > 0) {
$_suite = new TestSuite;
/* @noinspection PhpUnusedLocalVariableInspection */
foreach (\range(1, $arguments['repeat']) as $step) {
$_suite->addTest($suite);
}
$suite = $_suite;
unset($_suite);
}

fezfez added a commit to fezfez/phpunit that referenced this issue Oct 3, 2019
@sebastianbergmann sebastianbergmann added event/eu-fossa/2019-10 EU-FOSSA Hackathon: October 2019 and removed event/eu-fossa/2019-10 EU-FOSSA Hackathon: October 2019 labels Oct 4, 2019
@sebastianbergmann
Copy link
Owner

For each test method of a test case class an object of that test case class is created. These objects are aggregated in a TestSuite object. It is that TestSuite object which is repeatedly executed when --repeat is used. Therefore this is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants