Forum Discussion
KarelHusa
3 years agoChampion Level 2
there are many options, how to check the string, I would recommend:
if (! myString?.trim() ) {
Which checks, whether the string (please note the logical not !):
- is null or
- is empty or
- contains only whitespace chars
The usage could be:
if (! context.testCase.getPropertyValue('myProperty')?.trim()) {
log.info("Empty, whitespaces or null")
}
I would avoid comparing with == in similar cases as it has different meaning in Groovy and Java and does not check the whitespaces.
Best regards,
Karel
Related Content
- 9 years ago
- 5 years ago
- 9 years ago
- 11 years ago