spring3.0 使用 AbstractTransactionalJUnit4SpringContextTests 进行单元测试

@RunWith(Suite.class)
@Suite.SuiteClasses({
      TempTest.class
})
public class SuitTest {
}
/** 单元测试 **/
@ContextConfiguration(
        locations = {"classpath:applicationContext.xml"}
)
@RunWith(SpringJUnit4ClassRunner.class)
@Transactional
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
public class TempTest extends AbstractTransactionalJUnit4SpringContextTests {
    @Autowired
    private IService iService;
    @Before
    public void init() {
          String [] command = new String[5];
          command[0] = "....." 
          .....
          simpleJdbcTemplate.getJdbcOperations().batchUpdate(command);
    }
    @Test
    public void queryReport() {
        //......
        Assert.assertEquals(returnVal, expectVal);
    }
}

相关推荐