如何在 TeamCity 中很好地显示 ScalaTest 测试

How to show ScalaTest tests nicely in TeamCity

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

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

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

我在 ScalaTest 中创建了一个新的单元测试,但是当 TeamCity 运行s 构建时,它没有将这个测试识别为测试,所以我只能在完整的构建日志中看到结果,但不在 "Tests" 选项卡中。

已搜索 TeamCity 的 ScalaTest 插件,但未找到。

有什么想法吗?谢谢。

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

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

我设法以一种非常简单的方式解决了这个问题。原来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>