5控制台启动器一样

5控制台启动器一样

本文介绍了像JUnit 5控制台启动器一样,使用Surefire生成树输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随附的控制台启动器最后,JUnit Platform的JUnit平台(来自JUnit 5)产生了一个非常漂亮的摘要视图.但是,Maven Surefire插件的输出非常简单.

The Console Launcher that comes with JUnit Platform (from JUnit 5) produces a quite nice summary view at the end. The Maven Surefire plugin, however, has a very simple output.

是否可以使用Surefire创建类似于启动创建的输出?

Is it possible to create with Surefire output similar to what the launches creates?

推荐答案

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

My current workaround is to disable surefire and use exec-maven-plugin to manually run 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>

这篇关于像JUnit 5控制台启动器一样,使用Surefire生成树输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 19:35