【问题标题】:Run maven test in junit window在junit窗口中运行maven测试
【发布时间】:2019-12-17 19:00:44
【问题描述】:

我在 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 -&gt; Junit Test。这将打开 Junit 视图,我可以在其中很好地查看过程并在没有我的 maven 设置的情况下执行测试。

当我在我的项目上单击右键时,我还可以选择Run As -&gt; Maven test。这将打开控制台视图,获取我的 Maven 设置并运行测试。但我不喜欢控制台视图的外观。

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

【问题讨论】:

    标签: java eclipse maven junit5


    【解决方案1】:

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

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

    注意事项:

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

    【讨论】:

      猜你喜欢
      • 2013-08-23
      • 2021-12-16
      • 2010-09-30
      • 2020-12-31
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多