I'm new to groovy and I have doubt. Lets say I have this statement:
assert "king" == "kin"
which will give me the assert failure as
Assertion failed:
assert "king" == "kin"
|
false
and stops the program. But what I want is, store the result (the failure message, if any say in GString
) and proceed with the program.
Is that possible to do so?
You can catch the AssertionError
exception. Something like this:
try {
assert ["hello"] == ["A"]
}
catch(AssertionError e) {
result = e.getMessage()
}
println result
This should work.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments