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

时间:2014-01-24 14:29:31

标签: java jenkins continuous-integration junit4 jenkins-plugins

我完全疲惫不堪。詹金斯不会成功完成:)

也许有些人可以帮助我吗? ant jenkins的工作包括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结构:

enter image description here

(简单)测试:

package tictactoe;

import junit.framework.TestCase;

import org.junit.Assert;
import org.junit.Test;

//@RunWith(Suite.class)
//@SuiteClasses({Tests.class})
public class FieldTest extends TestCase {
    @Test
    public void testSchlange() {
        String schlange = new String();
        Assert.assertTrue(schlange.isEmpty());
    }

    @Test
    public void testAdd() {
    Assert.assertFalse(false);
    }
}

和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>

1 个答案:

答案 0 :(得分:2)

通常它按以下方式工作:在您(或在您的情况下jenkins)启动ant脚本之后,您将有一些任务创建在属性中定义的文件夹,收集在classpathes中定义的一些java文件,编译这些类,运行测试在他们身上,最后建造一个罐子。

要知道哪个任务(目标)首先出现,一旦启动构建过程,ant通常会使用默认目标。这个目标有所谓的依赖关系(相关目标),必须在它开始之前先完成。

在你的情况下,你的目标似乎没有任何依赖你的junit目标(有些甚至看起来很冗余,像TicTacToe和FieldTest似乎是相同的)。似乎你的蚂蚁脚本不知何故得到了自动生成和修改。修改它们时,您似乎忘记将junit目标作为依赖项添加到目标中,所以我猜你也错过了ANT中的一些基础知识。

我建议阅读以下tutorial。它将帮助您开始构建自己的ant脚本,还有一章介绍如何在脚本中包含junit测试。 Jenkins似乎配置正常,因为它显然已经开始构建并尝试生成报告。它只是没有成功,因为你的测试从未开始为这些报告生成必要的xmls,这导致构建失败,尽管你的构建过程成功了。