国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Spring集成單元測試

2019-11-11 01:53:50
字體:
來源:轉載
供稿:網友

SPRing集成單元測試

@(Spring)[單元測試, Spring, 集成]

Spring集成單元測試第一步導入jar包第二步創建一個類第三步集成Spring單元測試第四步編寫測試代碼

第一步:導入jar包

Spring單元測試需要導入spring-test-4.x.x.RELEASE.jarjunit4的jar包

第二步:創建一個類

public class Test1 { public void test1() { }}

第三步:集成Spring單元測試

// 設置Spring單元測試運行環境@RunWith(SpringJUnit4ClassRunner.class)// 設置Spring配置文件@ContextConfiguration("classpath:applicationContext.xml")public class Test1 { @Test public void test1() { }}

第四步:編寫測試代碼

package com.pc.crm.test;import java.util.List;import javax.annotation.Resource;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import com.pc.crm.domain.Customer;import com.pc.crm.service.CustomerService;// 設置Spring單元測試運行環境@RunWith(SpringJUnit4ClassRunner.class)// 設置Spring配置文件@ContextConfiguration("classpath:applicationContext.xml")public class Test1 { /** * 注入依賴 */ @Resource(name = "customerService") private CustomerService customerService; @Test public void test1() { List<Customer> list = customerService.findAllCustomer(); System.out.println(list); }}

PS:單元測試中不需要使用注解掃描<context:annotation-config/><context:component-scan base-package="com.xx" /> 也可以注入依賴。


上一篇:遞歸解決2的冪次方

下一篇:無序廣播

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 郯城县| 禄劝| 米林县| 尤溪县| 南京市| 南岸区| 马鞍山市| 余江县| 松原市| 和龙市| 尼木县| 黑河市| 屏山县| 互助| 外汇| 邳州市| 井陉县| 德州市| 中阳县| 岢岚县| 垦利县| 福鼎市| 富源县| 双流县| 自贡市| 新昌县| 健康| 甘孜县| 金塔县| 玉环县| 福贡县| 略阳县| 徐水县| 永丰县| 永清县| 同仁县| 鄂托克旗| 久治县| 吕梁市| 海盐县| 长岛县|