【问题标题】:ERROR: Step ‘Publish JUnit test result report’ failed: Test reports were found but none of them are new. Did tests run?错误:步骤“发布 JUnit 测试结果报告”失败:找到了测试报告,但没有一个是新的。测试运行了吗?
【发布时间】:2017-06-15 06:00:54
【问题描述】:
<project basedir="." default="build" name="Calculator">
    <property environment="env"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.8"/>
    <property name="source" value="1.8"/>
    <path id="JUnit 4.libraryclasspath">
        <pathelement location="../../../.p2/pool/plugins/org.junit_4.12.0.v201504281640/junit.jar"/>
        <pathelement location="../../../.p2/pool/plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
    </path>
    <path id="Calculator.classpath">
        <pathelement location="bin"/>
        <path refid="JUnit 4.libraryclasspath"/>
    </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="Calculator.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="AllTests">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.AllTests" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="AdditionTest">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.AdditionTest" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="Divide">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.Divide" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="Multiply">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.Multiply" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="SubtractTest">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.SubtractTest" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="AllTestss">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.AllTestss" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.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 中运行我的项目及其 Junit 测试时出现错误。 我也收到错误 “错误:步骤‘发布 JUnit 测试结果报告’失败:没有任何测试报告包含任何结果”。 并且在测试中也存在依赖性问题。 尝试了一些解决方案,但没有奏效 有什么解决办法吗?

【问题讨论】:

  • 什么依赖问题?您尝试了哪些解决方案?
  • 我在某处读到可能存在依赖性问题,我不知道它到底是什么意思。但我尝试的解决方案是重建 build.xml,更改 xml 中测试的顺序,

标签: eclipse unit-testing jenkins junit ant


【解决方案1】:

请务必在开始之前清理您的目标文件夹,这样您会更容易理解。看起来你只有旧的测试结果。

谢谢

【讨论】:

  • 我做到了,现在得到了这个。错误:“发布 JUnit 测试结果报告”步骤失败:没有任何测试报告包含任何结果
  • 所以,看起来测试没有运行,您的日志中是否有任何错误?你确定你运行测试吗?
  • 是否有任何插件可以在 Jenkins 中运行测试?
  • Jenkins 中有很多插件。你现在如何运行测试?它看起来像一个 ant 脚本,如果是你可以运行 n-wiki.jenkins-ci.org/display/JENKINS/Ant+Plugin 如果不是 ANT,请告诉我它是什么...
  • 是的,我正在运行一个 Ant 脚本
猜你喜欢
  • 2019-07-05
  • 1970-01-01
  • 1970-01-01
  • 2012-12-02
  • 1970-01-01
  • 2023-03-05
  • 2013-06-25
  • 1970-01-01
  • 2015-06-24
相关资源
最近更新 更多