全部評論(0條)
熱門問答
- 如何使用Junit測試使用Spring框架的代碼
2018-11-12 10:46:18
455
0
- 如何使用junit編寫測試類
2017-04-02 20:40:22
376
1
- 如何使用junit編寫測試類
2016-12-20 08:09:56
312
1
- 如何使用eclipse進行junit測試
2018-12-03 08:26:48
265
0
- 如何使用eclipse進行junit測試
2017-06-13 10:34:17
389
1
- spring junit 集成測試怎么做
2018-11-16 05:18:20
323
0
- myeclipse怎么使用junit測試接口
2018-11-18 13:21:38
281
0
- Eclipse中怎么使用junit測試
2016-01-10 23:46:13
447
2
- 如何使用junit進行單元測試面試題
2017-02-06 12:14:55
599
1
- 用junit怎么自動生成測試代碼
2016-06-27 08:48:04
546
1
- idea怎么使用idea添加junit case測試類
2017-05-23 05:06:37
598
1
- 以下junit測試代碼有錯誤,不知道哪里錯了
- 這是JUNIT測試代碼: import static org.junit.Assert.*; import 和 main 等前面的全部省略。。下面開始: protected ArrayCollection
AC; @Before public void runBeforeEveryTest(){ AC = new ArrayCollection(); AC.myStorage = (E[]) new Objec... 這是JUNIT測試代碼: 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)); } 下面的是被測試的類, 其中的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 由于字符限制,給出的被測試類里很多方法和拋出異常都省略。可以出現(xiàn)問題的地方只可能在我寫的方法remove(),equals()里面和JUNIT測試里。 請幫我看看那錯了,測試的結果不管加多少@test都只顯示測試了一個。并且出現(xiàn)錯誤: Tests failed = [initializationError(ArrayCollection): No runnable methods] 展開
2012-09-10 01:25:22
351
3
- 海天注塑機使用代碼和使用密碼
- 是弘訊電腦,HT360W3型... 是弘訊電腦,HT360W3型 展開
2011-01-06 09:25:48
2112
3
- 如何測試使用加速度計的應用程序
2017-01-11 03:05:04
345
1
- 如何使用cc2521測試接地電阻
2012-12-12 21:11:14
381
1
- 接口測試框架中,使用的log4j工具包,reportng工具包有什么用途
2017-01-09 07:11:41
476
1
- 中小型軟件企業(yè)開發(fā)使用什么框架?
- 我們一般都用了SSH,但效果不太理想,因為速度太慢了!一般的軟件公司都有什么框架的呢?
2013-08-02 05:27:28
331
4
- 如何使用拉力試驗機測試材料的抗拉強度
2018-12-01 08:10:26
373
0
- 如何使用網(wǎng)絡分析儀測試天線的阻抗
2017-07-30 20:22:01
329
1
4月突出貢獻榜
推薦主頁
最新話題





參與評論
登錄后參與評論