亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源單元測試工具 > junit
IDEA中利用JUnit進行單元測試
作者:網絡轉載 發布時間:[ 2016/8/1 17:19:41 ] 推薦標簽:單元測試

 打開IntelliJ IDEA工具,Alt+Ctrl+S,彈出窗口如下:

在文本框中輸入Plugin進行插件搜索設置。

點擊按鈕,從插件資源庫中安裝新的插件。
從插件資源庫中搜索JunitGenerator V2.0版本,在插件位置,鼠標右擊



選擇Download and Install ,在彈出的對話框中選擇yes按鈕,點擊OK之后在需要重啟下工具,選擇Restart按鈕,到此JunitGenerator2.0 插件安裝完畢.
現在可通過此工具自動完成test類的生成了,在需要進行單元測試的類中Alt+Insert,

測試類中使用的相關注解跟代碼如下:
 

打開IntelliJ IDEA工具,Alt+Ctrl+S,彈出窗口如下:


在文本框中輸入Plugin進行插件搜索設置。

 

點擊按鈕,從插件資源庫中安裝新的插件。

從插件資源庫中搜索JunitGenerator V2.0版本,在插件位置,鼠標右擊

 

 

 

選擇Download and Install ,在彈出的對話框中選擇yes按鈕,點擊OK之后在需要重啟下工具,選擇Restart按鈕,到此JunitGenerator2.0 插件安裝完畢.

現在可通過此工具自動完成test類的生成了,在需要進行單元測試的類中Alt+Insert,

 


測試類中使用的相關注解跟代碼如下:

 


[java] view plain copy
package test.RXTemplateService; 
 
import RXTemplateService.YhService; 
import org.junit.After; 
import org.junit.Before; 
import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.springframework.test.annotation.Rollback; 
import org.springframework.test.context.ContextConfiguration; 
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 
import org.springframework.test.context.transaction.TransactionConfiguration; 
import org.springframework.transaction.annotation.Transactional; 
 
import javax.annotation.Resource; 
 
/**
 * YhService Tester.
 *
 * @author <Authors name>
 * @version 1.0
 * @since <pre>���� 19, 2013</pre>
 */ 
 
/*用于配置spring中測試的環境*/ 
@RunWith(SpringJUnit4ClassRunner.class) 
/*
用來指定加載的Spring配置文件的位置,會加載默認配置文件
@ContextConfiguration 注解有以下兩個常用的屬性:
locations:可以通過該屬性手工指定 Spring 配置文件所在的位置,可以指定一個或多個 Spring 配置文件。
inheritLocations:是否要繼承父測試用例類中的 Spring 配置文件,默認為 true。
*/ 
@ContextConfiguration(locations = "classpath:test/RXTemplateService/applicationContext.xml") 
/*
@TransactionConfiguration是配置事務情況的注解.
第一個參數transactionManager是你在applicationContext.xml或bean.xml中定義的事務管理器的bean的id;
第二個參數defaultRollback是表示測試完成后事務是否會滾 參數是布爾型的 默認是true 但強烈建議寫上true
*/ 
@TransactionConfiguration(defaultRollback = true) 
@Transactional 
public class YhServiceTest { 
    @Resource 
    private YhService yhService; 
 
    @Before 
    public void before() throws Exception { 
    } 
 
    @After 
    public void after() throws Exception { 
    } 
 
    /**
     * Method: checkDlzhAndDlmm(String dlzh, String dlmm)
     */ 
    @Test 
    public void testCheckDlzhAndDlmm() throws Exception { 
        assert true : yhService.checkDlzhAndDlmm("wbb", "wbb"); 
    } 
 
    /**
     * Method: resetMm(String xmm, Integer id)
     */ 
    @Test 
    public void testResetMm() throws Exception { 
        yhService.resetMm("admin", 1); 
    } 
 
    /**
     * Method: yhSave(T_XT_YH yh)
     */ 
    @Test 
    @Rollback(false) 
    public void testYhSave() throws Exception { 
//TODO: Test goes here... 
    } 
 
    /**
     * Method: yhDelete(String ids)
     */ 
    @Test 
    public void testYhDelete() throws Exception { 
//TODO: Test goes here... 
    } 
 
    /**
     * Method: checkDlzh(String dlzh, Integer id)
     */ 
    @Test 
    public void testCheckDlzh() throws Exception { 
//TODO: Test goes here... 
    } 
 
    /**
     * Method: findYhById(Integer id)
     */ 
    @Test 
    public void testFindYhById() throws Exception { 
//TODO: Test goes here... 
    } 
 
    /**
     * Method: getYhList(int pageNo, int pageSize, Integer ssjgId)
     */ 
    @Test 
    public void testGetYhList() throws Exception { 
//TODO: Test goes here... 
    } 
}  

關鍵詞閱讀
軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 看全色黄大色大片免费久久 | 天天干天天干天天操 | 久久综合婷婷香五月 | 最近中文字幕版免费 | 亚洲国产一 | 黄网站色 | 国产欧美亚洲另类第一页 | 手机看片高清国产日韩片 | 一区欧美| 亚洲色图欧美另类 | 91福利免费体验区观看区 | 美国一级做a爰片性色毛片 美国一级做a一级视频 | 中国女人三级在线播放 | 一个人在线观看视频www | 一级片视频免费观看 | 手机看片久久高清国产日韩 | 黄色网在线免费观看 | 日韩欧美一区黑人vs日本人 | 18av黄动漫网站在线观看 | 国产精品1区2区3区在线播放 | 特级黄国产片一级视频播放 | 在线播放a 1 | 国产亚洲精品国产福利在线观看 | 亚洲黄色免费网址 | 黄a在线| 欧美tube6最新69 | 日本经典在线三级视频 | 欧美日韩一本 | 很很色在线视频 | 免费99精品国产自在现线观看 | 杏色国产成人精品视频 | 男女做羞羞的网站视频 | 黄色福利视频网站 | 日本韩国三级在线 | 任我鲁这里有精品视频在线播 | 国产综合在线播放 | 婷婷开心激情网 | 日本在线一区 | 国产片a | 日本xxxx色视频在线观看免 | 国产麻豆一级在线观看 |