1. TestNg与Spring的集成

  1. 被测试的类继承AbstractTestNGSpringContextTests类
  2. 添加注解指定Spring的ApplicationContext文件的路径
  3. 代码中添加Autowired注解获取Spring的bean

@ContextConfiguration(locations = {"classpath:ApplicationContext.xml"})
public class BwsTesting extends AbstractTestNGSpringContextTests {

    @Autowired
    private ProductBillDetailDaoImpl pbdai;
}

相关推荐