我有以下代码:
@Override
public long getUniqueId() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateAndTime= dateFormat.format(new Date());
jdbcTemplate.update(someSqlQuery, dateAndTime);
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("IDENTITY").withReturnValue();
}
return 0;
}
我想编写简单的单元测试,但是只要代码到达该行并SimpleJdbcCall
抛出“未指定数据源”的异常。到目前为止,这是我的测试:
@Test
public void testGetBatchId() {
transactionImpl.getUniqueId();
}
我的设置有什么问题?
如果要进行集成测试,则需要在测试范围中定义的数据源
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = GatewayApplication.class)
@WebAppConfiguration
@Transactional
public class ControllerIT {
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句