When I run the following code I get exception, and this is OK because string [0] is “1” and not 2
So assert make this exception and break from code ….
But what I want to do:
is to print NOT equal in case assert string[0] isn’t 1 , and ignore the exception
Else
in case string[0] is 1
then the code will print equal
string = "1 2 3"
assert string[0] == '2'
println "continue"
.
Exception thrown
Assertion failed:
assert string[0] == '2'
| | |
1 2 3 1 false