【发布时间】:2014-06-04 17:00:12
【问题描述】:
我是 ANT 新手,我正在尝试使用 ant 调用 Junit 测试(我使用的示例非常简单,在这篇文章中提到了)。问题是我没有看到测试用例被调用,因为我在屏幕上没有看到相关的输出。 (在下面的消息中,Junit 之后没有日志,例如通过了多少次测试)
Buildfile: C:\AntTestCases\build.xml
junit:
main:
BUILD SUCCESSFUL
Total time: 271 milliseconds
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="testingAnt" basedir="." default="main">
<!-- classpaths -->
<path id="classpath">
<fileset dir="lib" includes="**/*.jar"/>
</path>
<target name="junit">
<junit printsummary="on" fork="true" haltonfailure="yes">
<classpath>
<path refid="classpath"/>
</classpath>
<batchtest todir="reportDir">
<fileset dir="tests" includes="*Test.java"/>
</batchtest>
<formatter type="xml"/>
<formatter type="plain" usefile="false" />
</junit>
</target>
<target name="main" depends="junit"/>
</project>
测试类
package suite;
import org.junit.Test;
import junit.framework.TestCase;
public class SampleTests extends TestCase{
@Test
public void test1() {
System.out.println("SampleTests.test1()");
assertTrue(true);
}
}
非常感谢您对我哪里出错的意见。我已经阅读了一些关于 junit 和 ant 的教程,但没有任何帮助 http://www.vogella.com/tutorials/ApacheAnt/article.html http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html
Junit 的版本是 4,ant - 1.8.1 和 java 1.7
【问题讨论】: