Mocking Procedure Return Values with JMockit
When automated testing with JUnit, you may want to hack the return value of a procedure call and intentionally make it non-zero (error). In such a case, write as follows.
You have to be careful not to write more than one @Mock in the new MockUp.
@Test public <T extends CallableStatement> void test01 { new MockUp<T>(){ @Mock int getInt(int i) throws SQLException { return -1; } @Mock String getString(int i) throws SQLException { return "error test"; } }; ~ ~ }
コメント