【问题标题】:How to show ScalaTest tests nicely in TeamCity如何在 TeamCity 中很好地展示 ScalaTest 测试
【发布时间】:2017-01-23 02:49:40
【问题描述】:

我是 Scala 的新手,并将其集成到现有的 Java 项目中。

该项目是使用 Maven 构建的(已经成功配置 pom.xml 以编译 Java 和 Scala 代码并在单个项目中运行两个 lang 的测试)。

我们的 TeamCity 服务器有一个 Maven 构建步骤。

我在 ScalaTest 中创建了一个新的单元测试,但是当 TeamCity 运行构建时,它不会将此测试识别为测试,所以我只能在完整的构建日志中看到结果,而在“测试”中看不到标签。

搜索了 TeamCity 的 ScalaTest 插件,但没有找到。

有什么想法吗?谢谢。

【问题讨论】:

  • “在完整的构建日志中查看结果”是什么意思,你希望在哪里看到它?
  • 类似 JUnit 测试显示在“测试”选项卡中
  • 有一个 SBT 插件,但由于您使用的是 Maven,您可能需要使用 JUnit 测试运行器:scalatest.org/user_guide/using_junit_runner

标签: java scala maven teamcity scalatest


【解决方案1】:

我认为您需要将 XML Reporting Build 功能添加到您的构建配置中。如果构建功能中没有该功能,请尝试将测试结果文件保存为 %teamcity.build.checkoutDir%test_results.xml

Teamcity 我认为应该选择此文件并将其显示在“测试”选项卡中。您可能需要将此文件定义为人工制品之一。

【讨论】:

    【解决方案2】:

    我设法以一种非常简单的方式解决了这个问题。事实证明,scalatest的maven插件可以生成junit格式的报告。我将这些报告的输出文件夹更改为与 surefire 插件 (target/surefire-reports) 的报告文件夹相同的文件夹。

    实际上scalatest guide 的基本示例显示了正确的配置。

    <plugin>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest-maven-plugin</artifactId>
      <version>1.0</version>
      <configuration>
        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
        <junitxml>.</junitxml>
        <filereports>WDF TestSuite.txt</filereports>
      </configuration>
      <executions>
        <execution>
          <id>test</id>
          <goals>
            <goal>test</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 2023-03-21
      • 2011-11-05
      • 1970-01-01
      • 1970-01-01
      • 2012-07-15
      • 2013-08-20
      • 2021-03-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多