<span style="font-family:Microsoft YaHei;">package com.tgb.test;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
// 1. 继承 TestCase 类
public class CalculatorTest extends TestCase {
// 2. 测试方法必须以 test 开头
public void testAdd() {
int result = new Calculator().add(1, 2);
Assert.assertEquals(3, result);
}
// 3. 将 testcase 加入 testsuite,可以同时测试多个用例
public static Test suite() {
return new TestSuite(CalculatorTest.class);
}
}</span>原文地址:http://blog.csdn.net/happylee6688/article/details/38059833