Functional tests
Functional tests in Drupal use a simulated browser (using the popular Mink emulator) that allows users to click links, navigate to pages, work with forms, and make assertions regarding HTML elements on the page. What they don't allow is testing JavaScript-based interactions (see the next section for those).
Functional tests extend the Drupal\Tests\BrowserTestBase
class, which is integrated with PHPUnit like the ones we've seen before. The base class contains loads of methods both for asserting things and for shortcuts to perform Drupal (and web)-related tasks: creating users, entities, navigating to pages, filling in and submitting forms, logging in, and so on. And just like before, each test (class method) runs in isolation, so things such as content and users cannot be shared across multiple tests but would have to be recreated (perhaps using the setUp()
method as we've already seen).
Browser tests perform a full Drupal installation with a minimal...