Skip to content

[PhpUnitBridge] Cannot silence no assertions warning when using ExpectDeprecationTrait #41444

@ostrolucky

Description

@ostrolucky

Symfony version(s) affected: 6.0.x-dev fb21447

Description
When Symfony\Bridge\PhpUnit\ExpectDeprecationTrait is used in your PhpUnit test (because one of the test scenario methods in current class are doing deprecations), despite calling $this->expectNotToPerformAssertions();, output of phpunit is changed to warning, compared to no-warning/green output when not using the trait.

How to reproduce
Output for this

use PHPUnit\Framework\TestCase;

class CacheCompatibilityPassTest extends TestCase
{
    public function test(): void
    {
        $this->expectNotToPerformAssertions();
    }
}

is

OK (1 test, 0 assertions)
Process finished with exit code 0

but output for this

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;

class CacheCompatibilityPassTest extends TestCase
{
    use ExpectDeprecationTrait;

    public function test(): void
    {
        $this->expectNotToPerformAssertions();
    }
}

is

This test did not perform any assertions


Time: 00:00.031, Memory: 8.00 MB


OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Risky: 1.
Process finished with exit code 0

Additional context:
Starts happening in doctrine-bundle since doctrine/DoctrineBundle#1352

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy