I want to use either a value of expected property or a specified default. How to achieve this in groovy?
Let\'s look at the example:
def printName(ob
If I simply want to assert that an object has some property, I just test the following:
assertNotNull(myObject.hasProperty('myProperty').name)
If myObject
does not have myProperty
the assertion will fail with a null pointer exception:
java.lang.NullPointerException: Cannot get property 'name' on null object