您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > junit
Spring集成JUnit測試
作者:網(wǎng)絡轉載 發(fā)布時間:[ 2017/1/19 15:10:25 ] 推薦標簽:Junit 單元測試

  1.程序中有Junit環(huán)境
  2.導入一個jar包.spring與junit整合jar包
  spring-test-3.2.0.RELEASE.jar
  3.測試代碼
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext.xml")
public class SpringTest {
@Autowired
private UserService userService;
@Test
public void demo1(){
userService.sayHello();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="userService" class="cn.yzu.service.UserService"></bean>
</beans>

軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd