Junit学习一:private method的测试
来源:互联网 发布:Green VPN网络加速器 编辑:程序博客网 时间:2024/06/11 06:36
测试包:jmockit-1.6
被测试类:
package edu.com;public class T { private int privateMethod(int x, int y){ return x + y; }}测试类:
package edu.com;import static org.junit.Assert.*;import mockit.Deencapsulation;import org.junit.After;import org.junit.Before;import org.junit.Test;public class TTest { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void testPrivateMethod() { // 新建一个对象,如果直接用T.class来invoke会报错 /** * int actual = Deencapsulation.invoke(T.class, "privateMethod", 3, 5); * java.lang.IllegalArgumentException: Attempted to invoke non-static method without an instance to invoke it on */ T t = new T(); int expected = 8; int actual = Deencapsulation.invoke(t, "privateMethod", 3, 5); assertEquals(expected, actual); }}
0 0
- Junit学习一:private method的测试
- [JAVA]在Junit中测试私有函数的方法(junit, private, method)
- Use junit test private method
- Junit测试private方法
- [java]junit测试private方法
- junit学习笔记(一):JUnit的安装和测试原则
- Junit学习二:private field
- Junit的学习笔记一
- Junit 笔记 一.对方法的测试
- Junit学习笔记之一:junit的安装和测试原则
- ant+junit 测试一
- JUnit测试笔记(一)
- junit源码学习--运行测试的过程
- Maven整合Junit unitils测试框架 cannot retrieve JUnit method
- 根据反射机制测试private方法(junit测试)
- private method
- junit 测试学习笔记
- junit学习笔记一
- MyEclipse中如何去掉Struts2-Hibernate-Spring框架
- java中通过反射强力获取私有变量的值
- Android 获取组件高度;
- 6572_Telephony
- 窗体继承思想
- Junit学习一:private method的测试
- 九度OJ 1448 拓扑排序问题
- JDK的安装于配置
- PHP中如何过滤掉非汉字字符?
- JAVA小程序开发之模拟电梯APP(代码优化)
- 简单生活
- nyoj-528-找球号(三)
- 微信公众平台订阅号运营11个秘决
- nginx源码分析--数据结构ngx_array_t