Skip to Main Content
Menu
Close Menu

Updating deprecated test classes extending WebTestBase in Drupal 8

Summary

This covers only the most common use cases.

Instead of extending Drupal\simpletest\WebTestBase, extend Drupal\Tests\BrowserTestBase.

Due to extensive changes, you may need to rewrite your tests to use the new base class..

A little more information

The new test classes are similar, but not similar enough to be automatically updated.

Drupal.org recommends reading https://www.drupal.org/docs/8/testing/converting-d7-and-d8-simpletests-to-drupal-8-phpunit-tests.

Automating updates with Drupal Rector

Drupal Rector is an open source tool built using Rector which can help automate this deprecation as well as other common deprecations.

For more information, see https://github.com/palantirnet/drupal-rector.

What is covered by the rector

This deprecation is not currently covered by Drupal Rector.

Deprecation background

The new test classes use PhpUnit and Mink and take advantage of community tools outside of Drupal.

References

The Drupal change record for this deprecation is available at https://www.drupal.org/node/3030340.  

Let's work together.

Have an exceptional idea? Let's talk and see how we can help.
New Call-to-action