Automated Testing: Check Validation Message

markclemarkcle Member Posts: 65
Hi All

I'm writing automated tests for one of our extensions and I need to confirm that the validation message is correct as part of the test.

Let's take a simple (made up) case

Record.Field1 cannot be more than 2x it's current value.
The extension would have an Subscription to the OnAfterValidateEvent and raise an error such as this:

Error(StrSubstNo(QtyTooHighMsg, Format(MaxQty)));

In the UI, I get the red X and when I hover over it I see a message that is something like this "The number entered is too high. The max value is 20"

So My test would create a record with value 10 and then do record.Validate(Field1, 25). My asserterror catches the error and the test continues. but I want an assertion that the validation message did, in fact say "The number entered is too high. The max value is 20"

I don't see any kind of HandlerFunction Attribute that I can use to test this. Did I miss something?

If not, is there another way?

Finally is here a way in the test to "click" revert?

Thanks

Mark
Sign In or Register to comment.