idea 基於junit測試和自動生成測試類

①以前一直用myeclipse開發,習慣了junit測試。如今用idea開發,不可以測試,太不方便了,發現用@Test識別不了。因而查了poem.xml,發現個人mven裏面的jar包版本不對。eclipse

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
</dependency>

junit3 基於 繼承TextCaseide

junit 4 集成了@Text註釋測試

因此直接引入jar 包,版本改成4.10便可。idea

jar包下載地址:.net

http://download.csdn.net/download/gongweijiao/3783442插件

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    <scope>test</scope>
</dependency>

idea 能夠引入 JunitGenerator插件 自動生成測試代碼rest

②引入方式:xml

preference--->Plugins--->搜索框搜索JunitGenerator--->右鍵upload--->restart繼承

便可ip

③測試

找到類之後 

command+n ---->junit text --->junit4 便可

測試結果(自動生成)

public class CoachDaoImplTest {
@Before
public void before() throws Exception { 
} 

@After
public void after() throws Exception { 
} 

/** 
* 
* Method: saveCoach(CoachInfo coachInfo) 
* 
*/ 
@Test
public void testSaveCoach() throws Exception { 
//TODO: Test goes here... 
} 

/** 
* 
* Method: queryTrain(String level, String coachName, String siteProvince, Date start, Date end, String certNumber, String orderName, Integer orderBy, Integer page, Integer rows) 
* 
*/ 
@Test
public void testQueryTrain() throws Exception { 
//TODO: Test goes here... 
} 
}
相關文章
相關標籤/搜索