Score:0

Browser test reports assertion success as an error

ai flag

I am running a Functional test in a class derived from BrowserTestBase. Line 105 of the test method has this assertion:

    $this->assertSession()->linkExists('10000003');

The test output says:

Behat\Mink\Exception\ExpectationException: Link with label 10000003 found.

identifying line 105 as the line where the exception occurred. If it found the link, why does it consider that an error?

id flag
I think the test did not find the link. Often test assertion messages are written in that way, meaning, that is the message you would expect if the test passes.
Score:0
ai flag

Aha! It appears that the WebAssert class is inconsistent in what it reports for testing errors. Sometimes it describes what shouldn't have happened: the previous error I got was described as

Input "relationship-type" cannot take "2" as a value, ...

For this latest test, however, it did the opposite, describing not what went wrong, but what the test wanted to happen. Despite the output which seemed to say the link was found, when I captured the output I discovered that the link was, in fact, not there. Others may disagree, but I think a consistent approach would be a good thing here.

[Edit: this is fixed in Drupal 10, which correctly reports what caused the failure.]

id flag
Yes. I don't know if there is an existing policy not being followed, no policy at all, or no plan for any of this.
ai flag
The [documentation](https://github.com/minkphp/Mink/blob/master/src/WebAssert.php#L784) for the `assert()` method (called by `WebAssert::linkExists()`) states that the `$message` argument is the "failure message." All of the invocations of `assert()` by the class implementing it confirm that the message is supposed to describe the failure, rather than assert what should have happened. I will file a bug report.
ai flag
I see someone beat me to the punch. It's fixed in Drupal 10.
ai flag
Here's the bug report: https://www.drupal.org/project/drupal/issues/3336981.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.