Reputation: 97
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
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