Java Jenkins/Hudson没有任何测试报告包含任何结果

Java Jenkins/Hudson没有任何测试报告包含任何结果,java,jenkins,continuous-integration,junit4,jenkins-plugins,Java,Jenkins,Continuous Integration,Junit4,Jenkins Plugins,我完全筋疲力尽了。詹金斯不会成功完成:) 也许你们中的一些人可以帮我?AntJenkins的工作包括javadoc插件、发布html报告插件和junit测试结果插件。配置是完全默认的,例如,没有路径变量或其他 Started by an SCM change Started by user anonymous Building in workspace /var/lib/jenkins/jobs/TicTacToe/workspace Updating http://xxx.xxx.xxx.xx

我完全筋疲力尽了。詹金斯不会成功完成:)

也许你们中的一些人可以帮我?AntJenkins的工作包括javadoc插件、发布html报告插件和junit测试结果插件。配置是完全默认的,例如,没有路径变量或其他

Started by an SCM change
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/TicTacToe/workspace
Updating http://xxx.xxx.xxx.xxx/svn/repo/projekt at revision '2014-01-24T15:21:33.486 +0100'
U         build.xml
U         .classpath
At revision 20
[workspace] $ ant
Buildfile: /var/lib/jenkins/jobs/TicTacToe/workspace/build.xml

build-subprojects:

init:

build-project:
     [echo] TicTacToe: /var/lib/jenkins/jobs/TicTacToe/workspace/build.xml

build:

BUILD SUCCESSFUL
Total time: 0 seconds
Publishing Javadoc
[htmlpublisher] Archiving HTML reports...
Recording test results
None of the test reports contained any result
Build step 'Publish JUnit test result report' changed build result to FAILURE
Finished: FAILURE
以及eclipse结构:

(简单)测试:

以及build.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="build" name="TicTacToe">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <path id="TicTacToe.classpath">
        <pathelement location="bin"/>
        <pathelement location="jfxrt.jar"/>
        <pathelement location="hamcrest-core-1.3.jar"/>
        <pathelement location="junit-4.11.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="TicTacToe.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="TicTacToe">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="tictactoe.FieldTest" todir="${junit.output.dir}"/>
            <classpath refid="TicTacToe.classpath"/>
        </junit>
    </target>
    <target name="FieldTest">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="tictactoe.FieldTest" todir="${junit.output.dir}"/>
            <classpath refid="TicTacToe.classpath"/>
        </junit>
    </target>
    <target name="junitreport">
        <junitreport todir="${junit.output.dir}">
            <fileset dir="${junit.output.dir}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${junit.output.dir}"/>
        </junitreport>
    </target>
</project>

通常它的工作方式如下:在您(或您的jenkins)启动ant脚本之后,您将有一些任务创建属性中定义的文件夹,收集类路径中定义的一些java文件,编译这些类,对它们运行测试,最后构建一个jar

为了知道哪个任务(目标)首先出现,ant通常使用一个默认目标,该目标在您开始构建过程后立即开始。此目标具有所谓的依赖项(相关目标),在开始之前,必须先完成这些依赖项

在您的情况下,您的目标似乎对junit目标没有任何依赖性(有些甚至看起来是冗余的,比如TictaToe和FieldTest似乎是相同的)。您的ant脚本似乎也是以某种方式自动生成和修改的。在修改它们时,您似乎忘记了将junit目标作为依赖项添加到目标中,因此我猜您也错过了中的一些基础知识


我建议阅读以下内容。它将帮助您开始构建自己的ant脚本,还有一章介绍如何在脚本中包含junit测试。Jenkins似乎配置得很好,因为它显然启动了您的构建并试图生成报告。它只是没有成功,因为您的测试从未开始为这些报告生成必要的XML,这会导致构建失败,即使构建过程成功。

在第一次查看时,我觉得您没有在构建文件中调用junit测试目标,因此他无法收集测试结果,因为他们从未被处决过。您可能希望在收集数据之前验证您的测试是否已执行。我对该主题完全陌生。你能详细解释一下我的方法吗?e、 g.“您可能想验证,您的测试在收集数据之前是否已执行”听起来不错,但我不知道如何做到这一点;)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="build" name="TicTacToe">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <path id="TicTacToe.classpath">
        <pathelement location="bin"/>
        <pathelement location="jfxrt.jar"/>
        <pathelement location="hamcrest-core-1.3.jar"/>
        <pathelement location="junit-4.11.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="TicTacToe.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="TicTacToe">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="tictactoe.FieldTest" todir="${junit.output.dir}"/>
            <classpath refid="TicTacToe.classpath"/>
        </junit>
    </target>
    <target name="FieldTest">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="tictactoe.FieldTest" todir="${junit.output.dir}"/>
            <classpath refid="TicTacToe.classpath"/>
        </junit>
    </target>
    <target name="junitreport">
        <junitreport todir="${junit.output.dir}">
            <fileset dir="${junit.output.dir}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${junit.output.dir}"/>
        </junitreport>
    </target>
</project>