junit(四)
来源:互联网 发布:数据存储的基本单位 编辑:程序博客网 时间:2024/04/30 01:18
package com.ygl;
public class Calculator {
private int add(int a,int b){
return a+b;
}
}
//**************************************
package com.ygl;
import java.lang.reflect.Method;
import junit.framework.Assert;
import junit.framework.TestCase;
public class CalculatorTest extends TestCase {
public void testAdd(){
try{
Calculator cal=new Calculator();
Class<Calculator> clazz=Calculator.class;
Method method=clazz.getDeclaredMethod("add", new Class[]{int.class,int.class});//Integer.Type返回的是int的class对象
method.setAccessible(true);
Object result= method.invoke(cal, new Object[]{2,3});
Assert.assertEquals(5, result);
}catch(Exception e){
}
}
}
- junit(四)
- Junit学习笔记(四)
- (四)Junit单元测试
- Junit 测试 《四》
- Junit原理详解四
- 【Junit】Junit使用教程(四)
- Android测试(四) Junit实例
- Junit使用教程(四)
- Junit使用教程(四) .
- Junit使用教程(四)
- Junit使用教程(四)
- Junit使用教程(四)
- Junit使用教程(四)
- Junit使用教程(四)
- Junit使用教程(四)
- Junit使用教程(四)
- Junit使用教程(四)
- Junit使用之四---使用Junit测试WEB项目
- java中获取路径中的空格处理(%20)问题
- python第一步:安装ipython
- 启程之路
- java多线程实现方式
- Eclipse 安装Hibernate插件
- junit(四)
- hdu4857 逃生 (优先级队列 + 拓扑排序)
- 循环语句
- JZOJ 1769 Islands and Bridges
- 基于Windows的Apache+Git服务器搭建
- leetcode刷题,总结,记录,备忘 119
- C#动态内存分配《不安全代码》
- web 前端 2015 年最热门的 10 篇技术文章
- c++模板函数声明定义分离编译错误详解