4

My SUT may call a method on my mock with any object as paramter, including null.

So, does EasyMock.anyObject() match a null parameter? or can I use something else instead of anyObject() which will also match null ?

Bjarke Freund-Hansen
  • 28,728
  • 25
  • 92
  • 135

2 Answers2

7

Since EasyMock also offers matchers for notNull() and null(), I assume the answer is yes - otherwise anyObject() and notNull() would be redundant (if anyObject() did not match null).

A simple test confirms this.

matt b
  • 138,234
  • 66
  • 282
  • 345
3

eq((String) null) will work for a String param which is null.

Robert
  • 5,278
  • 43
  • 65
  • 115
fortycoats
  • 31
  • 1