【问题标题】:ANT is not calling JUnitsANT 没有调用 JUnit
【发布时间】: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

【问题讨论】:

    标签: java ant junit


    【解决方案1】:

    你需要类似的东西

          <batchtest todir="reportDir">
            <fileset dir="tests" includes="**/*Test.java"/>
          </batchtest>
    

    【讨论】:

    • 非常感谢您发现错误!
    猜你喜欢
    • 1970-01-01
    • 2015-01-06
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多