Forum Discussion
KarelHusa
4 years agoSuper Contributor
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
- 10 years ago
- 5 years ago
- 10 years ago
- 12 years ago
Recent Discussions
- 15 days ago
- 16 days ago