呵呵,初次接触自动测试,记录一下...
首先,使用junit编写测试类,就不详细写了..帖出代码:
package
src.test;
import
junit.framework.TestCase;
import
org.junit.
*
;
import
src.baseline.Hello;

import
static
junit.framework.Assert.
*
;
import
static
junit.runner.BaseTestRunner.
*
;
public
class
TestHello
extends
TestCase
...
{
private int x = 1;
private int y = 1;
@Test 
public void testSayHello()...{
Hello h = new Hello();
assertEquals(" hello, Junit 4",h.sayHello());
}
@Before 
public void startTest()...{
System.out.println(" test start");
}
@After 
public void endTest2()...{
System.out.println("test end");
}
}
<
project
name
="autotest.project"
default
="runtest"
basedir
="."
>
<
property
name
="src.dir"
value
="src/baseline"
/>
<
property
name
="test.dir"
value
="src/test"
/>
<
property
name
="build.dir"
value
="build/app"

这篇博客介绍了作者初次尝试自动测试的经历,主要讲解了如何利用JUnit编写测试类,并通过Ant的runtest任务来执行测试。文章提到了在使用JUnit4时遇到的问题,即@标记的测试方法无法被TestRunner识别,目前还在寻求解决方案。

1721

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



