Search code examples
javaunit-testingjmockit

JMockit match against null


      new Expectations() {{
        someMethod.getLocalObj().getValue((SomeClass)any);
        returns(1);
        times=1;

        request.doSomething().setTransaction((null)any); // HERE****how to match ??
        times=0;
    }};

Hi. I'm trying to match against a method that sets a variable to null. How can I do this in JMockit?

Thanks.


Solution

  • You are looking for this method here: withNull():

    Same as withEqual(Object), but checking that an invocation argument in the replay phase is null.