gavask
gavask

Reputation: 97

Jmockit, MOCKING METHODS

How do I mock the method getProperty using JMockit? Here is the code:

LWPropertyResource props = LWSupportFactoryImpl.getInstance().getPropertyResource(VALIDATE_HANDLER_PROPS);

String endDate = props.getProperty("endDate");

Upvotes: 1

Views: 81

Answers (1)

CoderDre
CoderDre

Reputation: 94

you need to mock the props class:

@Mocked LWPropertyResource props; //instance variable

new NonStrictExpectations {{
    props.getProperty("endDate"); result="My fake prop";
}};

Upvotes: 1

Related Questions