why me can't mock static method?

55 views
Skip to first unread message

meishild

unread,
Sep 16, 2011, 3:13:47 AM9/16/11
to gmock-user, johnny...@gmail.com
public class NumberUtils {
public static int toInt(String str) {
if (str == null) {
return 0;
}
try {
return Integer.parseInt(str);
} catch (Exception e) {
return 0;
}
}

public static int toInt() {
Random random = new Random();
return random.nextInt();
}
}

def void testGetInteger(){
def number = new Number()
mock(NumberUtils).static.toInt("123").returns(2)

play{
assert 2 == number.getInteger("123")
}
}

I want mock the toInt static method ,but use gmock,I can't do it
Reply all
Reply to author
Forward
0 new messages