6

我下载了一个使用 ant 构建的大型项目,每次编译后它都会运行大量的 junit 测试。有没有办法在不更改每个单独的构建文件的情况下通过所有这些测试?

4

1 回答 1

6

Any decent ANT build file should have well defined execution targets that can be called individually and declare dependencies to other targets if needed, basically something like this:

<project default="unitTests">

    <target name="clean">
        <echo message="Cleaning..." />
    </target>

    <target name="compile" depends="clean">
        <echo message="Compiling..." />
    </target>

    <target name="unitTests" depends="compile">
        <echo message="Testing..." />
    </target>

</project>

The default target (specified in the <project> tag) is usually the most comprehensive task that compiles the project and ensures integrity of the application by also running unit tests.

If your project's build file is constructed like that, then it's a matter of running ANT with the compile target and that will skip the tests. If it isn't built like that then there is no other way than to change the build file and separate the unit tests into it's own target that is not the default.

于 2013-05-25T18:05:02.360 回答