如何使用 Maven 运行 JUnit5 测试,它作为插件安装到 eclipse 应用程序中

How to run JUnit5 Tests, which are installed as plug-in into an eclipse application, with Maven

首先:是的,我已经搜索并基本上尝试了我可以在这里和其他博客文章中找到的所有内容。 我是一名实习生,在我升级所有依赖项和 eclipse 本身之后,我试图再次获得一个项目 运行ning。特别是项目升级到 64 位和 Junit5。所以一般所需的项目结构等之前工作,但现在我必须将 Junit4 迁移到 Junit5。

项目结构: 我有一个多包设置,其中包含我们的产品(一个 eclipse 应用程序)、一个包含所有测试的 "tests plugin" 包 类 和一个附加的 "test.suite" 包,其中包含一个测试套件从以前的插件执行测试(以避免循环依赖)。测试套件包的pom包含了所有的构建逻辑,即:

  1. 安装产品
  2. 安装测试插件
  3. tycho 应该触发测试。

所以作为视觉辅助项目是这样的:

问题: 由于 Junit5,"test suite package" 中的 "test suite class" 无法执行其他包中的测试,因为未找到 Junit TestEngine(也无法修复)。将 "test suite class" 复制到 "tests plugin package" 中工作正常,并且在 Eclipse 中作为插件测试执行时所有测试 运行 正确。 使用 maven 构建时,我通过命令行参数将 maven 指向 "test suite"。这适用于旧版本,但现在我尝试在 "test plugin package" 上使用该套件,因为它在 eclipse 中工作,但显然在这种情况下测试不会 运行。 没有错误,只有 0 运行s,0 次跳过 0 次失败 0 次错误,构建成功。

由于 building/installing/ 等的 pom 在 "test suite" 包中,我怀疑将测试套件移动到 "tests plugin" 包需要额外的步骤才能工作。 我尝试从 pom 指向新套件位置的各种路径(source/test-work.directory/testclassesdirectory...),但没有成功。

我已经尝试了所有我能找到的代码片段,但我无法让 maven 执行这些测试。 最大的"success"是这个:https://mukis.de/pages/simple-junit-tests-with-tycho-and-surefire/ 将片段添加到我的 pom 时,我发现错误 "duplicated classes" 用于测试 类... 只要被剪断的 "compiler-plugin" 在我的 pom 中,我就有重复项,删除它完全给了我 none。 尝试通过 "compilerarguments" 在 Maven 编译器上禁用重复项也没有用。

我知道我的问题很模糊,我的解释和技巧也很薄弱,但我很感激任何 hints/discussions 或关于如何做的例子。 考虑到给定的项目结构,通常如何配置 tycho(运行ning 集成测试作为插件安装到我的应用程序中)?

编辑: 这是测试套件 pom 中的最新尝试:

<plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-surefire-plugin</artifactId>
            <version>${tycho-version}</version>
            <configuration>     
                <testClassesDirectory>../xxx.tests\src\[some dirs]\tests</testClassesDirectory>     
                <includes>
                    <include>**/*Test.xtend</include>
                </includes>        
                <failIfNoTests>false</failIfNoTests>
                <useUIHarness>true</useUIHarness>
                <useUIThread>false</useUIThread>
                <argLine>${tycho.testArgLine} ${memoryArgs}</argLine>
                <work>${test-work-directory}</work>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                    <configuration>
                        <testClassesDirectory>../xxx.tests\src\[some dirs]\tests</testClassesDirectory>
                            <includes>
                                <include>**/*Test.xtend</include>
                            </includes> 
                    </configuration>
                </execution>
            </executions>
        </plugin>

我试过没有路径,也让它们指向已编译和未编译的目录。

此致

我在这上面花了一个多月的时间,在发布一天后我偶然找到了解决方案...但我不想抱怨

解决方案:

  • 在那个插件的两个文件 (*plugin.java, .project) 中是一个拼写错误,编译器没有找到它,只能通过手动搜索找到。它来自旧的重命名周期,但是 Maven 或 Eclipse 没有抛出错误...

  • 正如我所说,我们使用命令行参数将 maven 指向测试套件。显然不再需要了。我不知道它是否是 junit5 的东西,但是在 "osgi" 环境中的测试 类 (它们被打包并作为插件安装)当我没有提供任何测试类 link 到 maven.