Brian,
You are right that the expected value is listed in the debug output.
What's curious is that, when the comparison (between actual and
expected values) fails, I only see the expected value if I use a
waitFor() as suggested by Marcin. If I don't use waitFor(), I instead
get a StaleElementReferenceException and the expected value isn't
shown (though, as noted previously, if the comparison succeeds, the
waitFor isn't needed for the test to pass).
Another curiousity: If I pass in a smaller value for the timeout (say
1 second), geb still shows the expected value on failure, but I don't
have to wait the default duration of 30 seconds. Instead, Geb shows
the expected value after only 1 second of waiting:
waitFor(1) {
labRequest[0].dateField == requestDate
}
Output:
condition did not pass in 1.0 seconds (failed with exception)
geb.waiting.WaitTimeoutException: ......
...
Caused by: Assertion failed:
labRequest[0].dateField == requestDate
| | | | |
| | | | 2016-03-02T00:00
| | | false
| | dateField - SimplePageContent (owner: labRequest -
LabAnalysisRequestRow (owner: ProjectDetailPage, args: [], value:
null), args: [], value: 2016-02-03T00:00)
| labRequest - LabAnalysisRequestRow (owner:
ProjectDetailPage, args: [], value: null)
[labRequest - LabAnalysisRequestRow (owner: ProjectDetailPage, args:
[], value: null)]
So it looks like, in this case, some waiting period is needed before
geb is able to fully report test error information, but not for geb to
process a successful comparison.
Incidentally, I thought this behavior might only be occurring for date
fields, but have verified it occurs for other types of fields as well
(e.g. string).
Brian W.