Thursday, August 27, 2009

Unexpected Groovy return value

I like Groovy's multiline Strings. I use them all the time in my test cases. Usually I have a utility class that returns whatever content I need.

Yesterday I decided to do the whole test in Groovy. Inside my TestNG test case I had a method that returned some xml :

    String createInputFile(){
return
'''
<xml><one>Hello</one><two>World!</two></xml>
'''
}


The output was null. Kind of silly of me. Adding a semicolon after the String didn't produce an output. Putting the opening quote on the same line as the return statement did.

I still don't miss semicolons though.

No comments: