KernelTestBaseTest::tearDown() should not perform assertions

Created on 4 February 2021, about 4 years ago
Updated 27 August 2024, 8 months ago

Problem/Motivation

In #2571475: Outbound HTTP requests fail with KernelTestBase โ†’ we added a test without an assertion. PHPunit usually fails if a test does not assert anything, but because KernelTestBaseTest::tearDown() performs an assertion, all KernelTestBaseTests are considered to assert something.

Steps to reproduce

Proposed resolution

Refactor KernelTestBaseTest::tearDown() so it does not perform an assertion but still fails if the teardown conditions are not met.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Fixed

Version

11.0 ๐Ÿ”ฅ

Component
PHPUnitย  โ†’

Last updated about 12 hours ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Maybe time to try again in PHPUnit 10.

  • Merge request !9122Closes #3196507 โ†’ (Open) created by mondrake
  • Pipeline finished with Failed
    9 months ago
    Total: 632s
    #247228
  • Issue was unassigned.
  • Status changed to Postponed 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Postponed on ๐Ÿ› Fix โ€˜riskyโ€™ tests Fixed

  • Assigned to mondrake
  • Status changed to Active 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Blocker is in.

  • Pipeline finished with Failed
    9 months ago
    Total: 154s
    #252052
  • Pipeline finished with Success
    9 months ago
    #252054
  • Pipeline finished with Failed
    9 months ago
    Total: 248s
    #252092
  • Pipeline finished with Failed
    9 months ago
    Total: 152s
    #252093
  • Pipeline finished with Failed
    9 months ago
    Total: 554s
    #252102
  • Pipeline finished with Success
    9 months ago
    #252123
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to RTBC 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Refactor seems fine, accomplishes the task without breaking anything

  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    Is it not simpler just to do this to explicitly test the tearDown() method, and avoid this code running on all other teardowns in this class?

    -  protected function tearDown(): void {
    +  public function testTearDown(): void {
         parent::tearDown();
    
  • Status changed to RTBC 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Uhm we shouldnโ€™t call tearDown() from a test directly IMHO. The tear down process involves the framework calling methods marked with PostCondition and After attributes - tearDown is just โ€˜oneโ€™ of such methods nowadays.

  • Status changed to Fixed 9 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    Fair enough. Let's get this in.

    Committed d38aac1 and pushed to 11.x. Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024