What is the difference between this:
ResultSet set = EasyMock.createNiceMock(ResultSet.class);
EasyMock.expect(set.getInt("col1")).andReturn(1);
EasyMock.expect(set.wasNull()).andReturn(false);
EasyMock.expect(set.getInt("col2")).andReturn(2);
EasyMock.expect(set.wasNull()).andReturn(false);
EasyMock.replay(set);
assertEquals(1, set.getInt("col1"));
assertEquals(false, set.wasNull());
assertEquals(2, set.getInt("col2"));
assertEquals(false, set.wasNull());
And this:
ResultSet set = EasyMock.createNiceMock(ResultSet.class);
EasyMock.expect(set.getInt("col1")).andReturn(1);
EasyMock.expect(set.getInt("col2")).andReturn(2);
EasyMock.expect(set.wasNull()).andReturn(false).times(2);
EasyMock.replay(set);
assertEquals(1, set.getInt("col1"));
assertEquals(false, set.wasNull());
assertEquals(2, set.getInt("col2"));
assertEquals(false, set.wasNull());
?
Note. Both sets of code compile and execute successfully as jUnit tests. Also, please note that using a βniceβ layout is intentional here.
source
share