sebastianbergmann / phpunit

The PHP Unit Testing framework.
https://phpunit.de/
BSD 3-Clause "New" or "Revised" License
19.68k stars 2.2k forks source link

PHPUnit internal error #5549

Closed hbrecht closed 11 months ago

hbrecht commented 11 months ago
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

sebastianbergmann commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

Hi,

you are correct. I changed to phpunit10 again today, however, I was not able to create the error anymore - when I opened the ticket all runs failed. Please close the ticket. When I reencounter the error, I will collect more information and also do the configuration as described below. Please apologize my wasting your time and many thanks for phpunit!

Best regards, Valeri

Am 12.11.23 um 07:05 schrieb Sebastian Bergmann:

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!

— Reply to this email directly, view it on GitHub https://github.com/sebastianbergmann/phpunit/issues/5549#issuecomment-1807014926, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIGEDNPQFT22TUF523RUGTYEBRL7AVCNFSM6AAAAAA6RF2DDGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBXGAYTIOJSGY. You are receiving this because you authored the thread.Message ID: @.***>

--

Bei Fragen oder Unklarheiten stehen wir Ihnen gerne zur Verfügung.

MFG, Valeri Geiser

CLSGmbH Hauptstraße 2 66459 Kirkel-Limbach

Phone: (+49) 684197593-19 Fax: (+49) 6841 97593-49

@.** Web:*https://www._cls-gmbh_.de https://www.cls-gmbh.de/

CLS Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: 66459 Kirkel | Geschäftsführer: Klaus Miosga | Registergericht: Homburg HRB 106139

--------------OuX0WmwdyB0VakM7YoHcCMG3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit

<!DOCTYPE html>

Hi,

you are correct. I changed to phpunit10 again today, however, I was not able to create the error anymore - when I opened the ticket all runs failed. Please close the ticket.
When I reencounter the error, I will collect more information and also do the configuration as described below.
Please apologize my wasting your time and many thanks for phpunit!

Best regards,
Valeri

Am 12.11.23 um 07:05 schrieb Sebastian Bergmann:

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!


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: <sebastianbergmann/phpunit/issues/5549/1807014926@github.com>


--

Bei Fragen oder Unklarheiten stehen wir Ihnen gerne zur Verfügung.

MFG, Valeri Geiser

CLS GmbH
Hauptstraße 2
66459 Kirkel-Limbach


Phone:
(+49) 6841 97593-19
Fax: (+49) 6841 97593-49

Email:
Web: https://www.cls-gmbh.de

CLS Gesellschaft mit beschränkter Haftung
Sitz der Gesellschaft: 66459 Kirkel | Geschäftsführer: Klaus Miosga | Registergericht: Homburg HRB 106139


--------------OuX0WmwdyB0VakM7YoHcCMG3--

hbrecht commented 11 months ago

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);
        }
}