@RunWith就是一个运行器
@RunWith(JUnit4.class)就是指用JUnit4来运行
@RunWith(SpringJUnit4ClassRunner.class),让测试运行于Spring测试环境
@RunWith(Suite.class)的话就是一套测试集合,
单个文件
@ContextConfiguration(Locations="classpath:applicationContext.xml")@ContextConfiguration(classes = SimpleConfiguration.class)
多个文件时,可用{}
@ContextConfiguration(locations = { "classpath:spring1.xml", "classpath:spring2.xml" })
本文介绍如何使用JUnit4进行单元测试,并与Spring框架整合,实现自动化测试。通过@RunWith注解指定测试运行器,@ContextConfiguration注解加载Spring配置文件。
1255

被折叠的 条评论
为什么被折叠?



