Opened 7 years ago
Closed 7 years ago
#40531 closed task (blessed) (fixed)
Avoid test skipping for multisite only or single site only tests
Reported by: | johnbillion | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | needs-patch |
Focuses: | multisite | Cc: |
Description
When running the core test suite with PHPUnit you'll never see a nice green OK
result, because there are always skipped tests for multisite specific and single site specific tests.
Example:
if ( ! is_multisite() ) { $this->markTestSkipped( 'This test requires multisite.' ); }
The consequence is that it's difficult to spot unexpectedly skipped tests or incomplete tests, because there are always skipped tests polluting the results.
Instead of using the is_multisite() -> markTestSkipped
pattern, all these tests should be put into ms-required
and ms-only
groups, and then the phpunit.xml
/multisite.xml
configuration files should be updated to control whether the corresponding groups are skipped.
The is_multisite() -> markTestSkipped
code should remain (at least for now, maybe permanently) so the tests in those groups don't cause failures if they are run when they shouldn't be.
The aim is to attempt to remove all skipped tests when running the test suite, at least on Travis and ideally locally too. TDB whether or not this is achievable.
Change History (10)
#8
follow-up:
↓ 9
@
7 years ago
Instead of the new skip methods, you could do something like I did for my plugin tests by creating a custom `@requires` annotation. You could probably make it so that the @group
annotations automatically triggered these methods, so that there'd be no need to call them manually. Just a thought.
#9
in reply to:
↑ 8
@
7 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Replying to jdgrimes:
You could probably make it so that the
@group
annotations automatically triggered these methods, so that there'd be no need to call them manually.
I did consider this but for some reason I thought that custom annotations required PHPUnit 4.x+, which only works on PHP 5.3+. It would be preferable to only have to specify once that the test requires or excludes multisite.
I am +1 on this. We have a bunch of skipped tests in the bbPress suite, and yellow has become our new green, which is obviously not ideal.