junit测试 问题

[复制链接]
查看11 | 回复2 | 2011-8-5 22:37:49 | 显示全部楼层 |阅读模式
普通类
package cn.zt.a1;
public class T {
        public int add(int x, int y) {
                return x + y;
        }
       
        public static void main(String[] args) {
                int z = new T().add(3, 5);
                System.out.println(z);
        }
}
测试类
package c.zt.test;
import static org.junit.Assert.*;
import org.junit.Test;
import cn.zt.a1.T;
public class TTest {
        @Test
        public void testAdd() {
                int z = new T().add(5, 3);
                assertEquals(8,z);
        }
}
测试的时候,junit测试窗口有反映!


回复

使用道具 举报

千问 | 2011-8-5 22:37:49 | 显示全部楼层
右击类文run as junit test,你可以debug一下,看有没有执行这个方法,还有你可以试试继承testcase...
回复

使用道具 举报

千问 | 2011-8-5 22:37:49 | 显示全部楼层
把错误发出来看下...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行