1
我正在嘗試編寫一個單元測試,我似乎無法弄清楚如何編寫Integer.class的Mockito匹配器。如何爲Integer.class編寫一個匹配器
我試圖測試下面的方法:通過磕碰我嘲笑的JdbcTemplate
public List<Integer> getAllParticipatingChallengesByTeamId(int teamId) {
List<Integer> challengeIds = new ArrayList<Integer>();
MapSqlParameterSource args = new MapSqlParameterSource();
args.addValue("teamId", teamId);
try {
challengeIds = jdbcTemplate.queryForList(SQL_STRING, args, Integer.class);
} catch (Exception e) {
challengeIds = null;
}
return challengeIds;
}
返回使用的匹配這樣的值:當然,任何整數匹配
when(mockJdbc.queryForList(anyString(), any(SqlParameterSource.class), any(Integer.class)).thenReturn(integerList);
但是,沒有任何課程!我嘗試過Class.class,但是我似乎無法通過網絡或通過我自己的方式找出它。
平等匹配嘿,這很酷,和它的工作!謝謝。 – CorayThan