Opened 3 years ago
Last modified 3 years ago
#53781 new defect (bug)
Tests_Embed_Template tests fail when run in isolation
Reported by: | jrf | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | |
Component: | Build/Test Tools | Keywords: | needs-patch |
Focuses: | coding-standards | Cc: |
Description
When running the Tests_Embed_Template
test in isolation, two of the tests fail.
phpunit --filter Tests_Embed_Template
#) Tests_Embed_Template::test_oembed_output_post_with_thumbnail DOMDocument::loadHTML(): AttValue: " expected in Entity, line: 10 path/to/wp/tests/phpunit/tests/oembed/template.php:66 #) Tests_Embed_Template::test_oembed_output_attachment DOMDocument::loadHTML(): AttValue: " expected in Entity, line: 10 path/to/wp/tests/phpunit/tests/oembed/template.php:110
Accidentally discovered when I added the import
group to the <groups>
<excludes>
and ran the complete test suite and those two tests - which are unrelated to the import
tests - started erroring out.
A tentative conclusion from that can be that:
- The
Tests_Embed_Template
tests have an undeclared dependency on the tests in theimport
group. - The
Tests_Embed_Template
tests only pass by accident due to the order in which the tests are run, which is not guaranteed and can be influenced in more recent PHPUnit versions, so cannot be relied upon.
Also see: https://phpunit.readthedocs.io/en/stable/configuration.html#the-executionorder-attribute
This needs further investigation.
Solution direction: The test should be made independent of the import
tests.
Originally reported in https://core.trac.wordpress.org/ticket/53363#comment:39
Change History (4)
#2
@
3 years ago
Tests to reproduce
Env
PHP: 7.4.18
PHPUnit: 9.5.10
Localhost: WSL2 with Ubuntu 18.04
OS: Windows 10
In Isolation (--filter Tests_Embed_Template)
import
added togroups
excludes
.'import' => true,
added to$skipped_groups
inbootstrap.php
.- Both of the above added.
Complete Test Suite
import
added togroups
excludes
.'import' => true,
added to$skipped_groups
inbootstrap.php
.- Both of the above added.
Results
Couldn't reproduce - all tests pass.
What PHPUnit version are you running?
#3
@
3 years ago
@costdev Thanks for trying to reproduce. I can currently reproduce it even without the exclude for the import
group and the standard config.
Command phpunit -c phpunit.xml.dist --filter Tests_Embed_Template
Tested against PHP: 7.2.34, 7.3.31, 7.4.24, 8.0.11, 8.1.0rc2 (other PHP versions probably as well, but stopped testing)
Tested with PHPUnit: 7.5.20, 8.5.21, 9.5.10 (PHAR)
OS: Windows 10 64x
Output of php -m
:
[PHP Modules] bcmath bz2 calendar Core ctype curl date dom exif fileinfo filter gd gettext gmp hash iconv imap intl json ldap libxml mbstring mysqli mysqlnd openssl pcre PDO pdo_mysql pdo_sqlite Phar readline Reflection session SimpleXML soap sockets SPL standard tokenizer xml xmlreader xmlrpc xmlwriter xsl zip zlib [Zend Modules]
#4
@
3 years ago
Command: phpunit -c phpunit.xml.dist --filter Tests_Embed_Template
PHP: 7.4.24
PHPUnit: 9.5.10 (Used PHAR to see if that made any difference on my end)
Results: Tests pass
Diff output of php -m
- Modules only you have - bcmatch - bz2 - gmp - imap - ldap - pdo_sqlite - soap - xmlrpc + Modules only I have + FFI + ftp + imagick + pcntl + posix + shmop + sodium + sysvmsg + sysvsem + sysvshm + xdebug + Zend OPcache
Thanks for the ticket!
Just noting that I cannot seem to reproduce yet, these tests run as expected for me:
That said, there might indeed be something unstable about these tests that needs further investigation.