Problem/Motivation
The test coverage for theme output across core is patchy, and in some places not well implemented.
Tests that compare one string of HTML output to another are fragile, and failures are not necessarily representitive of a failure to the user (perhaps because an elements attributes are in a different order.
Proposed resolution
Improve coverage of themed output
Test core themes separately
Use superior analysis tools such as CSS Selectors or XPath/SimpleXml to perform assertions with rendered output.
More - TBD
Remaining tasks
Everything!
User interface changes
N/A
API changes
TBD
Related Issues
#1971860: Document that Twig debug mode breaks tests
#1959660: Replace xpath() with WebTestBase::cssSelect() by leveraging Symfony CssSelector
Comment | File | Size | Author |
---|---|---|---|
#2 | improve-theme-tests-1972786-2.patch | 2.34 KB | shanethehat |
|
Comments
Comment #1
shanethehat CreditAttribution: shanethehat commentedTo get the ball rolling, here is an XPath test approach that allows a rendered string to be compared against an element name and array of attributes. Attributes that are missing will fail the test, as will unexpected additional attributes.
Comment #2
shanethehat CreditAttribution: shanethehat commentedModified (shortened) version of the above code as a patch to WebtestBase
Comment #2.0
shanethehat CreditAttribution: shanethehat commentedUsing issue summary template
Comment #2.1
shanethehat CreditAttribution: shanethehat commentedwrong issue number
Comment #3
star-szrComment #4
joelpittetThis looks kinda neat. Probably could use some tests to give it a try. Leaving this at 8.0.x because it's test improvements and can make it into a patch release.