【问题标题】:Intellij/Maven Unit Test running issuesIntellij/Maven 单元测试运行问题
【发布时间】:2011-05-08 13:00:15
【问题描述】:

所以我在使用 Intellij 运行 Maven 项目中的所有测试时遇到问题。原因是少数模块依赖于加载的 dll 中的本机方法。由于这个 dll 不能多次加载,我不得不在我的 maven pom 文件中添加一个子句,这些测试将以分叉模式运行。

但是,在 Intellij 中,我无法弄清楚如何使这些相同的测试以分叉模式运行。我想将 Intellij 漂亮的 UI 用于带有绿色条的单元测试和漂亮的 UT 接口,但是由于这个问题,我无法在我的项目中运行所有测试。

有没有人遇到过 Maven、Intellij 和单元测试的问题以及如何让它们很好地协同工作的任何提示?

这是我的 pom.xml 文件的 sn-p:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <id>allTests</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                        <excludes>
                            <exclude>**/pkgA/**/*Test.java</exclude>
                        </excludes>
                    </configuration>
                </execution>
                <execution>
                    <id>forkedTests</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                        <forkMode>pertest</forkMode>
                        <includes>
                            <include>**/pkgA/**/*Test.java</include>
                        </includes>
                        <excludes>
                            <exclude>**/SpecificTest.java</exclude>
                            <exclude>**/*PerformanceTest.java</exclude>
                        </excludes>
                    </configuration>
                </execution>
            </executions>
        </plugin>

【问题讨论】:

    标签: unit-testing intellij-idea maven pom.xml


    【解决方案1】:

    请在 IntelliJ IDEA 问题跟踪器中为功能请求投票:Allow unit tests to be run seperate JVMs

    【讨论】:

      【解决方案2】:

      但是,在 Intellij 中,我无法弄清楚如何使这些相同的测试以分叉模式运行。

      我认为 IntelliJ 不允许调整其 test runner 的行为。

      有没有人遇到过 Maven、Intellij 和单元测试的问题以及如何让它们很好地协同工作的任何提示?

      一些想法/建议:

      • 使用 Maven 运行所有测试,甚至在 IntelliJ 下~or~
      • 使用执行 DLL 初始化并引用所有 TestCases 的 TestSuite,这当然不再加载 DLL。

      【讨论】:

        【解决方案3】:

        在 IntelliJ 14 中,您在 运行配置 对话框中有 Fork 模式 选项。 当您在一个类/套件中运行所有测试时,您可以启用应该等同于您的 maven 的 pertest 的 forkMode=method。

        【讨论】:

          猜你喜欢
          • 2016-04-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-09-27
          • 1970-01-01
          • 1970-01-01
          • 2013-07-11
          • 1970-01-01
          相关资源
          最近更新 更多