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

PHPUnit internal error #5549

Closed
hbrecht opened this issue Oct 26, 2023 · 4 comments
Closed

PHPUnit internal error #5549

hbrecht opened this issue Oct 26, 2023 · 4 comments
Labels
feature/logging Issues related to logging test results feature/test-runner CLI test runner type/bug Something is broken version/10 Something affects PHPUnit 10

Comments

@hbrecht
Copy link

hbrecht commented Oct 26, 2023

Q A
PHPUnit version 10.4.1 / 10.4.2
PHP version PHP 8.2.7 with PCOV 1.0.11
Installation Method PHAR

Summary

When running our test suite, after ~3000 tests the program stops with an internal error.

Current behavior

When running our test suite, suddenly below error occurs. There were only some code changes done in the code being tested; it was running on 10.4.1 this morning. Update to 10.4.2 does not help. Here is the complete error:

An error occurred inside PHPUnit.

Message: PHPUnit\Event\Telemetry\HRTime::duration(): Argument #1 ($start) must be of type PHPUnit\Event\Telemetry\HRTime, null given, called in phar:///usr/local/bin/phpunit/phpunit/Logging/JUnit/JunitXmlLogger.php on line 191

Location: phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php:48

#0 phar:///usr/local/bin/phpunit/phpunit/TextUI/Application.php(144): PHPUnit\TextUI\TestRunner->run()
#1 /usr/local/bin/phpunit(2976): PHPUnit\TextUI\Application->run()
#2 {main}

Caused by: phar:///usr/local/bin/phpunit/phpunit/Event/Value/Telemetry/HRTime.php:54

#0 phar:///usr/local/bin/phpunit/phpunit/Logging/JUnit/JunitXmlLogger.php(191): PHPUnit\Event\Telemetry\HRTime->duration()
#1 phar:///usr/local/bin/phpunit/phpunit/Logging/JUnit/JunitXmlLogger.php(148): PHPUnit\Logging\JUnit\JunitXmlLogger->handleFinish()
#2 phar:///usr/local/bin/phpunit/phpunit/Logging/JUnit/Subscriber/TestFinishedSubscriber.php(29): PHPUnit\Logging\JUnit\JunitXmlLogger->testFinished()
#3 phar:///usr/local/bin/phpunit/phpunit/Event/Dispatcher/DirectDispatcher.php(78): PHPUnit\Logging\JUnit\TestFinishedSubscriber->notify()
#4 phar:///usr/local/bin/phpunit/phpunit/Event/Dispatcher/DeferringDispatcher.php(41): PHPUnit\Event\DirectDispatcher->dispatch()
#5 phar:///usr/local/bin/phpunit/phpunit/Event/Emitter/DispatchingEmitter.php(548): PHPUnit\Event\DeferringDispatcher->dispatch()
#6 phar:///usr/local/bin/phpunit/phpunit/Framework/TestRunner.php(152): PHPUnit\Event\DispatchingEmitter->testFinished()
#7 phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php(436): PHPUnit\Framework\TestRunner->run()
#8 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(266): PHPUnit\Framework\TestCase->run()
#9 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(266): PHPUnit\Framework\TestSuite->run()
#10 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(266): PHPUnit\Framework\TestSuite->run()
#11 phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php(44): PHPUnit\Framework\TestSuite->run()
#12 phar:///usr/local/bin/phpunit/phpunit/TextUI/Application.php(144): PHPUnit\TextUI\TestRunner->run()
#13 /usr/local/bin/phpunit(2976): PHPUnit\TextUI\Application->run()
#14 {main}

How to reproduce

I do not have a way to reproduce this with a small example. However, since it is a type error, I would hope it might be possible to find it while analysing the code. I looked at the code and I see that there is an assert before, but it is most likely disabled.

Expected behavior

PHPUnit runs without internal error

@hbrecht hbrecht added type/bug Something is broken version/10 Something affects PHPUnit 10 labels Oct 26, 2023
@sebastianbergmann
Copy link
Owner

Thank you for your report.

Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting.

Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue.

@sebastianbergmann sebastianbergmann added status/waiting-for-feedback Waiting for feedback from original reporter feature/test-runner CLI test runner feature/logging Issues related to logging test results labels Nov 11, 2023
@sebastianbergmann
Copy link
Owner

I assume that you do not have your PHP interpreter configured to execute assert() statements. Can you post the output you get when you configure zend.assertions=1 and assert.exception=1? Thanks!

@hbrecht
Copy link
Author

hbrecht commented Nov 13, 2023 via email

@sebastianbergmann sebastianbergmann removed the status/waiting-for-feedback Waiting for feedback from original reporter label Nov 13, 2023
@hbrecht
Copy link
Author

hbrecht commented Nov 14, 2023

Hi Sebastian,

I now figured out a minimal example. We had an assertion in one setUp method - if this fails it produces the error described above. I agree that setUp might not be the best place for an assertion, so please let me know if this is not allowed anymore (documentation does only disallow in setUpBeforeClass).

Anyhow, here is the minimal example:

<?php
class DummyTest extends PHPUnit\Framework\TestCase {

        protected function setUp(): void {
            $this->assertTrue(false);
        }

        public function testDummy(): void {
            $this->assertTrue(true);
        }
}

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

No branches or pull requests

2 participants