WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 9 months ago

#40538 accepted task (blessed)

Fix or remove useless PHPUnit tests

Reported by: johnbillion Owned by: johnbillion
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-unit-tests ongoing has-patch
Focuses: Cc:

Description

There are 29 tests in the test suite which don't perform an assertion. They should be fixed or removed.

PHPUnit 6 has switched to being strict about useless tests by default, so that gives us an additional reason to address them. In addition, there's no reason for core's default PHPUnit configuration to not be strict about useless tests so the same behaviour is seen when running older versions of PHPUnit.

Previously: #36016

Attachments (1)

40538.diif (2.7 KB) - added by Mte90 9 months ago.
new 4 tests for rest api

Download all attachments as: .zip

Change History (11)

#1 @johnbillion
13 months ago

  • Owner set to johnbillion
  • Status changed from new to accepted

#2 @johnbillion
13 months ago

In 40534:

Build/Test Tools: Be strict about tests that do not test anything.

See #40538

#3 @johnbillion
13 months ago

In 40535:

Build/Test Tools: Ensure that WP_UnitTestCase::expectedDeprecated() performs an assertion to avoid risky test notices.

See #40538

#4 @johnbillion
13 months ago

In 40541:

Build/Test Tools: Only perform an assertion for deprecated calls and wrongdoings if any are expected.

This avoids masking risky tests that don't otherwise perform an assertion.

See #40538

#5 @johnbillion
13 months ago

In 40542:

Build/Test Tools: More tweaks to the deprecated calls assertion. This needs to be triggered when there are unexpected deprecated calls or wrongdoings too.

See #40538

This ticket was mentioned in Slack in #core by obenland. View the logs.


12 months ago

#7 @obenland
12 months ago

@johnbillion Can this be closed for 4.8?

#8 @johnbillion
12 months ago

  • Keywords needs-unit-tests ongoing added
  • Milestone changed from 4.8 to Future Release

There are still a bunch of tests that don't perform any assertions.

@Mte90
9 months ago

new 4 tests for rest api

#9 @Mte90
9 months ago

  • Keywords has-patch added

This patch remove the empty units for 4 tests :-)

Are missing:

There were 4 risky tests:

1) WP_Test_REST_Pages_Controller::test_prepare_item
This test did not perform any assertions

2) WP_Test_REST_Settings_Controller::test_context_param
This test did not perform any assertions

3) WP_Test_REST_Settings_Controller::test_prepare_item
This test did not perform any assertions

4) WP_Test_REST_Settings_Controller::test_get_item_schema
This test did not perform any assertions

I am not sure about prepare, context and get_item_schema tests about what they have to do.

#10 @johnbillion
9 months ago

Thanks for the patch, @Mte90. AFAICT these tests are actually blocked by a bug I found when working on #41463. See 4:ticket:41463.

Note: See TracTickets for help on using tickets.