仪器网(yiqi.com)欢迎您!

| 注册2 登录
网站首页-资讯-专题- 微头条-话题-产品- 品牌库-搜索-供应商- 展会-招标-采购- 社区-知识-技术-资料库-方案-产品库- 视频

问答社区

如何使用Junit测试使用Spring框架的代码

辽宁林氏 2018-11-12 10:46:18 427  浏览
  •  

参与评论

全部评论(0条)

热门问答

如何使用Junit测试使用Spring框架的代码
 
2018-11-12 10:46:18 427 0
如何使用junit编写测试类
 
2017-04-02 20:40:22 355 1
如何使用junit编写测试类
 
2016-12-20 08:09:56 288 1
如何使用eclipse进行junit测试
 
2018-12-03 08:26:48 243 0
如何使用eclipse进行junit测试
 
2017-06-13 10:34:17 363 1
spring junit 集成测试怎么做
 
2018-11-16 05:18:20 311 0
myeclipse怎么使用junit测试接口
 
2018-11-18 13:21:38 249 0
Eclipse中怎么使用junit测试
 
2016-01-10 23:46:13 415 2
如何使用junit进行单元测试面试题
 
2017-02-06 12:14:55 566 1
用junit怎么自动生成测试代码
 
2016-06-27 08:48:04 515 1
idea怎么使用idea添加junit case测试类
 
2017-05-23 05:06:37 572 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 由于字符限制,给出的被测试类里很多方法和抛出异常都省略。可以出现问题的地方只可能在我写的方法remove(),equals()里面和JUNIT测试里。 请帮我看看那错了,测试的结果不管加多少@test都只显示测试了一个。并且出现错误: Tests failed = [initializationError(ArrayCollection): No runnable methods] 展开
2012-09-10 01:25:22 334 3
海天注塑机使用代码和使用密码
是弘讯电脑,HT360W3型... 是弘讯电脑,HT360W3型 展开
2011-01-06 09:25:48 2096 3
如何测试使用加速度计的应用程序
 
2017-01-11 03:05:04 325 1
如何使用cc2521测试接地电阻
 
2012-12-12 21:11:14 329 1
接口测试框架中,使用的log4j工具包,reportng工具包有什么用途
 
2017-01-09 07:11:41 464 1
中小型软件企业开发使用什么框架?
我们一般都用了SSH,但效果不太理想,因为速度太慢了!一般的软件公司都有什么框架的呢?
2013-08-02 05:27:28 309 4
如何使用拉力试验机测试材料的抗拉强度
 
2018-12-01 08:10:26 352 0
如何使用网络分析仪测试天线的阻抗
 
2017-07-30 20:22:01 305 1

1月突出贡献榜

推荐主页

最新话题