drupalextension icon indicating copy to clipboard operation
drupalextension copied to clipboard

Assertion for multiple messages potentially getting it wrong

Open jurgenhaas opened this issue 10 years ago • 1 comments

In class MessageContext I have contributed some code for multiple message assertions about a year ago and only today have I realised that this code potentially gets it wrong if the syntax of the step definition is wrong but the parser wouldn't even recognise that wrong syntax.

Here is an example:

  Then I should see the following error messages:
    | Something is wrong. |
    | And something else is wrong. |

The problem is that this assertion expects a TableNode as a parameter and then loops through $messages->getHash() which assumes the first row to be the header of the TableNode and simply skips that and only walks through row 2 and following.

At least that's what my debugging session highlighted and if that conclusion is correct, then I wonder what could be done to make sure that an editor of tests doesn't forget about the table header and therefore the first row never gets tested at all.

This is not only in assertMultipleErrors() but also in a couple of similar assertions in the same class.

jurgenhaas avatar Dec 14 '15 17:12 jurgenhaas

Can we fix this via documentation and make people always use the header?

jhedstrom avatar Dec 05 '17 18:12 jhedstrom