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\"/>
<property name=\"build.test.dir\" value=\"build/test\"/>
<target name=\"JUNIT\">
<available property=\"junit.present\" classname=\"junit.framework.TestCase\" />
</target>
<target name=\"compile\" depends=\"JUNIT\">
<mkdir dir=\"${build.dir}\"/>
<javac srcdir=\"${src.dir}\"
destdir=\"${build.dir}\"
classpath=\"lib/*.jar\"
debug=\"on\"
/>
</target>
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/