QuickTip (Spock): Stubbing with null

This is less of a problem and more of a code style thing, but I noticed recently that some of our Spock code has several instances of >> null.

For example:


...
then:
result
1 * service.doSomething() >> new Blah()
1 * service.doSomethingElse() >> null
...


It's nice to see that the interactions are written in the same style, but for many methods1, Spock returns null by default so writing the >> null is redundant and I prefer to remove it.

Do you agree or not? Feel free to comment below. If this is something we agree on, perhaps it should be a new codenarc rule.

Comments