【问题标题】:TFS Can't Find Unit Test Results from Ant/JUnit buildTFS 无法从 Ant/JUnit 构建中找到单元测试结果
【发布时间】:2011-12-22 14:14:14
【问题描述】:

我有一个刚刚导入 TFS 的 java 项目,我一直在尝试让 TFS 输出单元测试的结果。

在 TFSBuild.proj 文件的末尾,我有以下内容:

<ItemGroup>
  <!--  Ant Call Configuration.
        The build file called should be included in the workspace of the build definition.
  -->

  <AntBuildFile Include="$/PROJECT_NAME/Main/tfsbuild.xml">
    <Targets>build,test</Targets>
    <Properties>BinariesRoot=$(BinariesRoot);BuildDefinitionName=$(BuildDefinitionName);BuildDefinitionUri=$(BuildDefinitionUri);BuildDirectory=$(BuildDirectory);BuildNumber=$(BuildNumber);DropLocation=$(DropLocation);LogLocation=$(LogLocation);SourceGetVersion=$(SourceGetVersion);TestResultsRoot=$(TestResultsRoot);TeamProject=$(TeamProject);WorkspaceName=$(WorkspaceName);WorkspaceOwner=$(WorkspaceOwner)</Properties>
    <Lib></Lib>
  </AntBuildFile>

  <!-- JUnit XML Results files should be created using the XML formatter
       and be located in the following path
  -->
  <JUnitLogFiles Include="$(BinariesRoot)\**\TEST-*.xml" />
</ItemGroup>

这会启动构建并告诉 TFS 在哪里可以找到 junit 测试结果。 问题是,即使我可以通过日志看到测试已运行,TFS 也没有找到单元测试结果。

【问题讨论】:

    标签: java ant tfs junit continuous-integration


    【解决方案1】:

    我几乎放弃了这一点,并更改了我的 ant 文件以生成 junit 报告并将其与构建工件一起存储。我将我的 ant 任务更改为:

        <target name="test" depends="compile-tests">
        <echo>Running unit tests, output should be in ${junit.output}</echo>
        <junit printsummary="yes">
            <classpath>
                <pathelement path="${compile.classpath}" />
                <pathelement path="${lib.dir}/junit-4.0.jar" />
                <pathelement path="${build}" />
                <pathelement path="${dist-classes}" />
            </classpath>
    
            <formatter type="xml" />
    
            <batchtest fork="yes" todir="${junit.output}">
                <fileset dir="${src.test}">
                    <include name="**/*Test.java" />
                </fileset>
            </batchtest>
        </junit>
    
        <mkdir dir="${DropLocation}/${BuildNumber}/test_results" />
        <junitreport todir="${junit.output}">
            <fileset dir="${junit.output}">
                <include name="TEST-*.xml" />
            </fileset>
            <report todir="${DropLocation}/${BuildNumber}/test_results" />
        </junitreport>
    </target>
    

    但是在检查下一次构建的输出后,我意识到 JUnit 输出保存为 TESTS-TestSuites.xml,不是 TEST-*.xml。我相应地更改了我的 TFSBuild.proj 文件,现在构建结果出现在 TFS 中。

    尽管 junitreport 任务仍然会获取输出。

    【讨论】:

      猜你喜欢
      • 2011-11-22
      • 2013-04-12
      • 2018-03-03
      • 2010-10-06
      • 2014-03-12
      • 2018-07-22
      • 1970-01-01
      • 1970-01-01
      • 2017-05-23
      相关资源
      最近更新 更多