溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

spring項目實現單元測試過程解析

發布時間:2020-10-19 07:55:41 來源:腳本之家 閱讀:153 作者:不良帥~ 欄目:編程語言

后臺開發過程中,寫單元測試是非常重要的,對于我們開發人員調試、排查問題是很方便的,

但是我們在啟動項目的時候,需要將所以類交給spring托管,在單元測試中需要怎么實現類的注入呢?

直接上圖

繼續上代碼

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
<br data-filtered="filtered">@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
    "classpath:application-context.xml",
    "classpath:application-database.xml",
    "classpath:application-redis.xml"})
public class PartRelevanceTest {
	@Resource
	  private PartRelevanceMapper partRelevanceMapper;
	@Test
	  public void selectTypeNumOne() {
		PartRelevanceTypeNum record = new PartRelevanceTypeNum();
		record.setRelCode("2222112");
		record.setType("2");
		PartRelevanceTypeNum typeNum = partRelevanceMapper.selectTypeNumOne(record);
		System.out.println(typeNum==null?"typeNum-數據為空":typeNum.toString());
	}
}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女