Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Drupal community has deprecated SimpleTest and the Webform module needs to switch over using PHPUnit (https://www.drupal.org/docs/8/phpunit) based tests.
Concepts
- Tests confirm expectations.
- Tests should be repeatable, maintainable, and easy to execute
- Tests are documentation.
Notes
- Webform module requires that all features, functionality and even form elements have an example/test page that developer or an automated test can review and fix expecting
- Simple test has better ui integration but is deprecated.
- JavaScript testing is now supported
Things that don't need 100% test coverage.
- Features that extend core systems which already include test coverage
- Features that are too time consuming to write tests for, especially if it is less time and effort to assume that users and developer will create issues if the feature fails to meet expectations.
Features that lack good test coverage
- Translations
- States API JS
- Webform fields
Tasks
- Setup Drupal\Tests\BrowserTestBase example
- Setup WebformBrowserTestBase
- Setup Webform loader.
References
- https://www.drupal.org/docs/8/phpunit
- https://www.drupal.org/docs/8/phpunit/running-phpunit-tests
- https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial
- https://docs.acquia.com/article/lesson-104-phpunit-doubles-mocks-stubs
- http://softpixel.com/~mradcliffe/files/dco2015-mocking-drupal.pdf
- http://www.pixelite.co.nz/article/writing-phpunit-tests-for-your-custom-...
- https://www.previousnext.com.au/blog/drupal-8-ftw-it-test-or-it-form-act...
- https://www.chapterthree.com/blog/javascript-testing-comes-to-drupal-8
- https://www.phase2technology.com/blog/ajax-testing-in-drupal-8/
Comments
Comment #2
anpolimusComment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer commentedComment #4
anpolimus@jrockowitz, do you have any description for the Drupal\Tests\BrowserTestBase?
What core methods do we need?
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI have not ported any SImpleTests to BrowserTests. I am not really ready to use BrowserTests because the SimpleTest UI is so convenient. I also think that over the next few months there will be more documentation and tools to help convert SimpleTests to BrowserTests.
The Webform module does not have any JavaScript tests and needs more PHP Unit tests.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented