参考原文:http://hi.baidu.com/nboy/blog/item/3b61b3de71dc0b5cccbf1aa8.html
在Eclipse中右键-->new-->other...-->Java/JUnit,选择JUnit Test Case创建一个JUnit Test类:CalculationTest.java
import
static
org.junit.Assert.
*
;
import
org.junit.After;
import
org.junit.Before;
import
org.junit.Test;

public
class
CalculationTest
...
{

private Calculation calc = null;// 定义一个Calculation对象
@Before
public void setUp() throws Exception ...{
// @Before 关键字用于测试前初始化工作,如:数据库连接,创建工厂类对象,初始化变量等.
calc = new Cal

本文介绍了如何在Eclipse环境中创建并运行JUnit Test Case,通过右键新建JUnit Test Class,然后选择要测试的Java类运行单元测试,可以在JUnit窗口查看测试结果。此外,还提到了import static 语句在简化静态变量引用中的作用。
3万+

被折叠的 条评论
为什么被折叠?



