armygrad
1 year agoContributor
Boolean check
Hi All I'm almost there, i need to check that a json response contains 1234 within an array, and return true. and if it doesn't return false. boolean check = "FAIL"
if (response.contains("1234") ...
Hello armygrad
Is this a json or groovy question? Your first line defining the 'check' variable starts the whole thing off on a bad foot... Unless you are meaning to do some tricky groovyish stuff, i apologize...
I don't know what groovy does when you mix data types... line one you are setting a boolean type to a string type... If you purposely add the boolean type why set to string value?
You might get more consistent results with exacting code:
.
.
.
check = false;
if (response.contains("1234") ) {
check = true;
};
log.info "check=$check";
.
.
.
Regards,
Todd
Hi,
The result in quotes was part of a solution from another Q last week. The Groovy check returns a String, which in turn is persisted in a Datasink step. This part of the solution was not to assert as fail stops the test. Instead, this part was to report all passes and fails.