亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-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
主站蜘蛛池模板: 国产深夜福利 | 日本xxxⅹ69xxxx护士 | 99久久免费国产精精品 | 天天做天天爱夜夜爽女人爽宅 | 美日韩在线观看 | 国产第一页久久亚洲欧美国产 | 亚洲欧美日产综合一区二区三区 | 免费一级国产生活片 | 一个人看的www网站 一个人看的www在线 | 色www永久免费视频 色www亚洲 | 国产高清一区二区三区免费视频 | 韩国三级伦理片床在线播放 | 免费丝袜足控网站 | 久久合 | 成人18网址在线观看 | 波多野结衣综合 | 久爱视频www在线播放 | 99资源在线 | 精品国产品国语在线不卡丶 | 午夜影视在线免费观看 | 国产成人精品视频免费 | 国产欧美日韩综合二区三区 | 128tv在线观看 | 免费a级毛片在线观看 | 欧美一区日韩精品 | 成人影院在线观看免费 | 日本深夜18免费看片高清网 | 男女靠逼网站 | 成年性生交大片免费看 | 97欧美精品激情在线观看最新 | 日本久久久久久久中文字幕 | 97久久精品人人澡人人爽 | 黄色免费观看视频 | 中文字幕人成乱码在线观看 | 国产成人精品免费视 | 亚洲视频在线观看 | 1204国产成人精品视频 | 亚洲最色网站 | 青青青国产免费线在 | 亚洲免费大全 | h国产在线观看 |