- 被测试的类继承AbstractTestNGSpringContextTests类
- 添加注解指定Spring的ApplicationContext文件的路径
- 代码中添加Autowired注解获取Spring的bean
@ContextConfiguration(locations = {"classpath:ApplicationContext.xml"})
public class BwsTesting extends AbstractTestNGSpringContextTests {
@Autowired
private ProductBillDetailDaoImpl pbdai;
}