class SomeService{
public String getValue(){
return SomeUtil.generateValue();
}
}
class SomeUtil{
public static String generateValue() {
return "yahoo";
}
}
I want to unit test the SomeService.getValue
method.
I am trying the following:
@Test
void "getValue should return whatever util gives"(){
def mockSomeUtil = mock(SomeUtil)
mockSomeUtil.static.generateValue().returns("blah")
play {
Assert.assertEquals(someService.getValue(), "blah")
}
}
But it fails as the util method isn't actually getting mocked.
Question:
How can I unit test my service method?