运行 junit 中的 maven 测试 window

Run maven test in junit window

我在 Eclipse 中有一个使用 maven 的 Java 项目。这个项目包括几个 Junit5 测试。

我已将 pom.xml 配置如下:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.0</version>
    <configuration>
        <properties>
            <configurationParameters>
                junit.jupiter.execution.parallel.enabled = true
                junit.jupiter.execution.parallel.mode.default = concurrent
            </configurationParameters>
        </properties>
    </configuration>
</plugin>

我包含了我的 junit 依赖如下:

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.5.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>5.5.1</version>
    <scope>test</scope>
</dependency>

当我右键单击我的项目时,我可以选择 Run As -> Junit Test。这将打开 Junit 视图,我可以在其中以一种很好的方式查看流程并在没有我的 maven 设置的情况下执行测试。

当我右击我的项目时,我也可以选择Run As -> Maven test。这将打开控制台视图,采用我的 Maven 设置并将 运行 测试。但是我不喜欢控制台视图的外观。

所以我的问题是:是否可以通过 Maven test 执行我的项目以使用我的 Maven 设置并让它 运行 在 Junit 视图中?

maven测试在target\surefire-reports\目录下输出测试结果

您可以将带有测试结果的 XML 拖放到测试视图中,一旦测试完成,该视图将加载并显示测试结果。

注意事项:

  • 您不会看到进度,您只能在测试完成后执行此操作
  • 一次只能看到一个测试(~一个测试class),不是完整的测试结果
  • 很不方便