全部評(píng)論(1條)
-
- xiongbao880817 2016-06-28 00:00:00
- 生成接口: file --- new --interface 輸入名字就可以生成接口了 生成JUnit測(cè)試類: 首先導(dǎo)入測(cè)試類需要的jar包 ,網(wǎng)上找找很多了 然后新建一個(gè)類a ,a一定要繼承TestCase類,那么此時(shí)就可以在類a里面寫測(cè)試方法了
-
贊(16)
回復(fù)(0)
登錄或新用戶注冊(cè)
- 微信登錄
- 密碼登錄
- 短信登錄
請(qǐng)用手機(jī)微信掃描下方二維碼
快速登錄或注冊(cè)新賬號(hào)
微信掃碼,手機(jī)電腦聯(lián)動(dòng)
注冊(cè)登錄即表示同意《儀器網(wǎng)服務(wù)條款》和《隱私協(xié)議》
熱門問(wèn)答
- 用junit怎么自動(dòng)生成測(cè)試代碼
2016-06-27 08:48:04
546
1
- 如何在Eclipse中自動(dòng)生成接口和JUnit測(cè)試類
2018-11-11 10:13:08
310
0
- 如何在Eclipse中自動(dòng)生成接口和JUnit測(cè)試類
2017-03-21 12:04:49
369
1
- 如何在Eclipse中自動(dòng)生成接口和JUnit測(cè)試類
2017-07-11 20:41:21
414
1
- 以下junit測(cè)試代碼有錯(cuò)誤,不知道哪里錯(cuò)了
- 這是JUNIT測(cè)試代碼: import static org.junit.Assert.*; import 和 main 等前面的全部省略。。下面開始: protected ArrayCollection
AC; @Before public void runBeforeEveryTest(){ AC = new ArrayCollection(); AC.myStorage = (E[]) new Objec... 這是JUNIT測(cè)試代碼: import static org.junit.Assert.*; import 和 main 等前面的全部省略。。下面開始: protected ArrayCollection AC; @Before public void runBeforeEveryTest(){ AC = new ArrayCollection(); AC.myStorage = (E[]) new Object [10]; AC.mySize = 0; AC.add((E) "April"); AC.add((E) "Bob"); AC.add((E) "Cathy"); } @Test public void testRemove() { for (Iterator it = AC.iterator(); it.hasNext();) { String index = (String)it.next(); if (index=="Bob"){ it.remove(); assertTrue(AC.remove("Bob")); } } } @Test public void testEqualsObject() { boolean expected = true; ArrayCollection AC_new = new ArrayCollection(); AC_new.add((E) "April"); AC_new.add((E) "Bob"); AC_new.add((E) "Cathy"); assertEquals(expected, AC_new.equals(AC)); } 下面的是被測(cè)試的類, 其中的boolean remove()和equals()方法是我自己寫的,其他的是題目給出的。 public class ArrayCollection implements Collection { protected E[] myStorage; protected int mySize; public ArrayCollection() { myStorage = (E[]) new Object [10]; mySize = 0; } public String toString() { String result = ""; for (int i = 0; i < mySize; i++) result += myStorage [i] + "\n"; return result; } // method toString /** * Checks if this ArrayCollection object is empty. * * @return a boolean indicating whether this ArrayCollection object is empty or not. */ public boolean isEmpty() { return mySize == 0; } // method isEmpty /** * Checks if this ArrayCollection object contains a certain element. * * @param obj an Object that will be checked for. * * @return a boolean indicating whether this ArrayCollection object contains * obj. */ public boolean contains (Object obj) { for (int i = 0; i < mySize; i++) if (obj.equals (myStorage [i])) return true; return false; } // method contains public boolean remove(Object obj) { for(int i=0; i a=(ArrayCollection )obj; if(a.mySize != mySize) return false; return myStorage.equals(a.myStorage)&&((Integer)mySize).equals(a.mySize); } // method equals 由于字符限制,給出的被測(cè)試類里很多方法和拋出異常都省略??梢猿霈F(xiàn)問(wèn)題的地方只可能在我寫的方法remove(),equals()里面和JUNIT測(cè)試?yán)铩?請(qǐng)幫我看看那錯(cuò)了,測(cè)試的結(jié)果不管加多少@test都只顯示測(cè)試了一個(gè)。并且出現(xiàn)錯(cuò)誤: Tests failed = [initializationError(ArrayCollection): No runnable methods] 展開
2012-09-10 01:25:22
351
3
- 如何使用Junit測(cè)試使用Spring框架的代碼
2018-11-12 10:46:18
455
0
- myeclipse怎么使用junit測(cè)試接口
2018-11-18 13:21:38
281
0
- Eclipse中怎么使用junit測(cè)試
2016-01-10 23:46:13
445
2
- junit測(cè)試類怎么打包成jar文件
2018-05-18 21:49:25
409
1
- uu 代碼怎么用
- uu代碼怎么用... uu 代碼怎么用 展開
2018-11-20 23:08:17
437
0
- junit找不到測(cè)試類,Junit測(cè)試類里面有多個(gè)test,每個(gè)test之間
2017-06-29 21:57:39
426
1
- idea怎么使用idea添加junit case測(cè)試類
2017-05-23 05:06:37
598
1
- 如何使用junit編寫測(cè)試類
2017-04-02 20:40:22
376
1
- 如何使用junit編寫測(cè)試類
2016-12-20 08:09:56
312
1
- 如何使用eclipse進(jìn)行junit測(cè)試
2018-12-03 08:26:48
265
0
- 如何使用eclipse進(jìn)行junit測(cè)試
2017-06-13 10:34:17
387
1
- mastercam x8生成nc,刀路什么已經(jīng)設(shè)置好了,怎么生成CNC代碼
2018-11-30 01:17:19
293
0
- myeclipse怎么導(dǎo)入junit
2018-11-15 21:43:33
320
0
- myeclipse中Junit測(cè)試類怎么在里面添加已有類?
2018-11-13 12:06:24
327
0
- 什么是測(cè)試代碼
- 什么是測(cè)試代碼... 什么是測(cè)試代碼 展開
2011-03-29 23:00:42
455
2
4月突出貢獻(xiàn)榜
推薦主頁(yè)
最新話題





參與評(píng)論
登錄后參與評(píng)論