Make WordPress Core

Opened 14 months ago

Closed 10 months ago

Last modified 10 months ago

#58955 closed task (blessed) (fixed)

Test tool and unit test improvements for 6.4

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by:
Milestone: 6.4 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Previously:

This ticket is for various fixes and improvements in PHPUnit tests that don't have a more specific ticket, as well as general improvements to the GitHub Actions workflows that run automated testing.

Attachments (1)

58955-group-notation.diff (11.1 KB) - added by afercia 12 months ago.

Download all attachments as: .zip

Change History (16)

This ticket was mentioned in PR #4954 on WordPress/wordpress-develop by @hellofromTonya.


13 months ago
#1

  • Keywords has-patch has-unit-tests added

Fixes tests leaking into other tests by:

  • Restoring the original $hook_suffix global value. Rather than modifying the global for all tests, restore the original value between tests. Why? To ensure each test starts at a known state.
  • Using a new instance of WP_List_Table for each test. A test may modify the $list_table object. If it does, it could impact tests yet to run. By instantiating a new instance in the set_up() test fixture, each test is isolated from the others.

Note: This was original found and resolved in https://github.com/WordPress/wordpress-develop/pull/4905, but the fix is unrelated to that scope of work. Separating the fix for its own commit.

Trac ticket: https://core.trac.wordpress.org/ticket/58955

#2 @hellofromTonya
13 months ago

In 56348:

Tests: Fix leakage in WP_List_Table tests.

Fixes WP_List_table tests leaking into other tests by:

  • Restores the original $hook_suffix global value.

Rather than modifying the global for all tests, it now restores the original value between tests. Why? To ensure each test starts at a known state.

  • Uses a new instance of WP_List_Table for each test.

A test may modify the $list_table object. If it does, it could impact tests yet to run. By instantiating a new instance in the set_up() test fixture, each test is isolated from the others.

Follow-up to [53868], [54215].

Props hellofromTonya, antonvlasenko.
See #58955, #58896.

#4 @johnbillion
13 months ago

In 56479:

Editor: Replace some accidental double setting up of tests with proper tearing down.

See #55505, #58955

This ticket was mentioned in PR #5100 on WordPress/wordpress-develop by @johnbillion.


13 months ago
#5

Trac ticket: https://core.trac.wordpress.org/ticket/58955

This changes several instances of test skipping to test failures, and removes some unnecessary function_exists() checks for compat functions.

If any of the checks in these test aren't satisfied then the test should fail rather than be skipped.

#6 @afercia
12 months ago

Attaching a patch containing some initial work to improve the @group notation accuracy and consistency across the tests. Team work made during a mob-coding session together with @SergeyBiryukov, @aristath, and @poena.

This ticket was mentioned in PR #4132 on WordPress/wordpress-develop by @Rahmohn.


12 months ago
#7

This PR updates the test test_wp_count_attachments_should_cache_the_result to check the properties of the object returned instead of checking the object with assertEquals. That way, we guarantee the expected properties of the object.

Trac ticket: https://core.trac.wordpress.org/ticket/58955

#8 @SergeyBiryukov
12 months ago

In 56669:

Build/Test Tools: Remove random_compat from PHPCS and PHPUnit configuration files.

This package was removed in WP 6.3, so these exclusion entries are no longer necessary.

Follow-up to [42346], [42665], [49797], [56141], [56667].

See #58831, #58955.

#9 @desrosj
11 months ago

In 56831:

Build/Test Tools: Remove hardcoded PHPUnit config files.

The configuration file passed to the callable workflow contains the correct one to use.

See #58955.

#10 @SergeyBiryukov
11 months ago

In 56936:

Tests: Reset the current user before performing assertions in some comment tests.

This aims to avoid affecting other tests in case of failure.

Follow-up to [54527].

See #58955.

#11 @hellofromTonya
11 months ago

#59647 is now open for the 6.5 cycle.

#12 @jorbin
10 months ago

Closing since we are past RC3.

#13 @jorbin
10 months ago

  • Resolution set to fixed
  • Status changed from new to closed

#14 @peterwilsoncc
10 months ago

In 57058:

Build/Test Tools: Fix group for wp_unique_prefixed_id() tests.

Change the group from functions.php to functions to match other tests.

Reviewed by jorbin.
Merges [57057] to the 6.4 branch.

See #59647, #58955.

#15 @peterwilsoncc
10 months ago

In 57059:

Build/Test Tools: Revert [57058].

Revert group name change in the 6.4 branch as the functions.php group was renamed functions after the branch was forked.

Props SergeyBiryukov.
See #59647, #58955.

Note: See TracTickets for help on using tickets.