代码之家  ›  专栏  ›  技术社区  ›  Michael Piefel

像JUnit5控制台启动器一样使用Surefire生成树输出

  •  4
  • Michael Piefel  · 技术社区  · 7 年前

    Console Launcher JUnit平台(来自junit5)提供的这一点在最后产生了一个非常好的摘要视图。然而,Maven Surefire插件有一个非常简单的输出。

    有没有可能用Surefire输出创建类似于Launchs创建的内容?

    3 回复  |  直到 7 年前
        1
  •  4
  •   rampion    6 年前

    我目前的解决方法是禁用surefire并使用 exec-maven-plugin 手动运行 ConsoleLauncher :

    <!-- disable surefire -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version><!-- ... --></version>
      <executions>
        <execution>
          <id>default-test</id>
          <phase>none</phase>
        </execution>
      </executions>
    </plugin>
    <!-- enable ConsoleLauncher -->
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version><!-- ... --></version>
      <executions>
        <execution>
          <phase>test</phase>
          <goals><goal>java</goal></goals>
          <configuration>
            <mainClass>org.junit.platform.console.ConsoleLauncher</mainClass>
            <arguments>
              <argument>--scan-class-path</argument>
              <argument>${project.build.directory}/test-classes</argument>
            </arguments>
            <classpathScope>test</classpathScope>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <!-- ... -->
    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-console-standalone</artifactId>
      <version><!-- ... --></version>
      <scope>test</scope>
    </dependency>
    
        2
  •  1
  •   tibor17    6 年前

    目前Surefire正在开发中 1 用于嵌入式Surefire功能,以及支持JUnit5 DisplayName的独立扩展。 其中一个扩展是测试集信息的控制台记录器。与中的控制台输出非常相似 2 可能也会支持。

    扩展是一组Java抽象,Surefire/Failsafe插件将包含这些抽象的默认实现。其他渐进式扩展实现,其输出类似于 2 ,将善意地要求用户支持Surefire项目,以便在他们自己的GitHub存储库(而不是ASF)中实现扩展。欢迎Surefire在ASF Maven Surefire网页上列出这些扩展的所有第三方实现。

        3
  •  0
  •   Sormuras    7 年前

    当然。

    随时可以打开一个特性请求来扩展当前的摘要输出 https://issues.apache.org/jira/projects/SUREFIRE/issue 也许是一个针对 https://github.com/apache/maven-surefire ;-)