eclipse中如何写一个测试私有方法的junit?
来源:互联网 发布:在线手机小号软件 编辑:程序博客网 时间:2024/04/30 05:35
eclipse中如何写一个测试私有方法的junit?
假设类Summer定义如下:
public class Summer{
private int methodone(String argsone){
//method code
.......
return 4;
}
}
测试如下:
public class SummerTest extends TestCase {
public void testMethodone(){
Object rightResult = xxxxx;
Summer example = new Summer.newInstance();
Method m = example .getClass().getDeclaredMethod("methodone",new Class[]{String.class});
m.setAccessible(true);
Object result = m.invoke(example ,new Object[] {new String(xxxx)});
m.setAccessible(false);
if (result.equals(rightResult)){
//your code
......
}
}
}
假设类Summer定义如下:
public class Summer{
private int methodone(String argsone){
//method code
.......
return 4;
}
}
测试如下:
public class SummerTest extends TestCase {
public void testMethodone(){
Object rightResult = xxxxx;
Summer example = new Summer.newInstance();
Method m = example .getClass().getDeclaredMethod("methodone",new Class[]{String.class});
m.setAccessible(true);
Object result = m.invoke(example ,new Object[] {new String(xxxx)});
m.setAccessible(false);
if (result.equals(rightResult)){
//your code
......
}
}
}
- eclipse中如何写一个测试私有方法的junit?
- Junit中对私有方法测试
- junit私有方法测试
- [JAVA]在Junit中测试私有函数的方法(junit, private, method)
- 使用Junit 测试私有方法
- junit 测试私有方法或私有变量
- 在单元测试中如何测试私有的方法
- JUnit 中是以测试方法为一个独立的生命周期
- 使用JUnit测试Java类的私有方法
- junit测试延伸--私有方法测试
- 在单元测试中如何测试私有方法
- JUnit 3.8 通过反射测试私有方法
- JUnit 3.8 通过反射测试私有方法
- Junit 测试私有方法和私有变量方法
- Eclipse中建立自己的JUnit测试
- 如何使用JUnit写测试?
- 如何使用JUnit写测试?
- 类中私有方法的测试
- history of Ming dynasty
- 玩玩Spring之struts+hibernate+spring添删改查示例
- 多级树行控件加载
- 一个验证身份证号码的javascript函数
- 使用AJAX异步获取数据
- eclipse中如何写一个测试私有方法的junit?
- PHP安全(一)
- 应用XMLHTTP的SVG小例子
- 3D开端 RayCasting
- snmp协议
- 虚拟路径映射到另一个应用程序,这是不允许的。
- eclipse的源代码搜索插件
- 060803
- ISBN从10位升为13位,执行日期为2007年1月1日