Taz
2 years agoContributor
How to stop "assert" to display junk at the end of a failed assertion message?
There is an annoying side effect when using "assert" in a groovy script to verify items from a property. It often displays too much junk at the end of it:
Assertion failed:
assert ep.Flow == sp.flow
| | | | |
| '0' | | 0.0
| | ['startDate':'2020-09-02T15:30:00', 'endDate':'2020-09-02T16:24:00', 'flow':0.0, 'flowUnit':['unit':'', 'flowTimeUnit':'Unspecified', 'version':'2.5.0'], .
| false
EP@66f5016c
error at line: 10
If however the value is first copied into another variable, then it displays correctly.
def f = sp.flow
assert ep.Flow == f;
Assertion failed:
assert ep.Flow == f
| | | |
| '0' | 0.0
| false
EP@eeab99e
error at line: 10
However, this bloats the code unnecessarily. Is there a better way to deal with it?