gpt4 book ai didi

tycho - JUnit4Provider 不工作

转载 作者:行者123 更新时间:2023-12-04 18:01:30 27 4
gpt4 key购买 nike

我正在尝试让打包类型为 eclipse-test-plugin 的项目工作(我有一个雄心勃勃的目标,就是有一天让它执行测试,但现在只有两个类里面有空的测试方法)。

我假设问题只存在于我们使用目标配置文件,所以需要的插件(或其他)不会自动加载。在没有最新的文档或示例的情况下,我猜测这种用例的 pom.xml 应该看起来像这样:

<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>${see.below}</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>0.22.0</version>
<configuration>
<providerHint>junit4</providerHint>
</configuration>
</plugin>
</plugins>
</build>

(因为没有依赖项,我得到了一个 ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider,这就是类所在的位置。)

现在如果我使用 2.18.1 或以下版本的 surefire-junit4,我会收到以下错误:

An error has occurred. See the log file C:\workspaces\workspace\org.acme.project.rxp-build\org.acme.project.rxp.it\target\work\data\.metadata\.log.
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.22.0:test (default-test) on project org.acme.project.rxp.it: An unexpected error occured while launching the test runtime (return code 13). See log for details. -> [Help 1]

Aaand 有问题的日志文件包含:

org.apache.maven.surefire.util.SurefireReflectionException: java.lang.ClassNotFoundException: org.apache.maven.surefire.junit4.JUnit4Provider
at org.apache.maven.surefire.util.ReflectionUtils.loadClass(ReflectionUtils.java:251)
at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:128)
at org.apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.java:235)
at org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:113)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:78)
at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:91)
at org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.run(HeadlessTestApplication.java:21)

如果我使用 surefire-junit42.19 版本,我会收到以下消息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (test) on project org.acme.project.rxp.it: Execution test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: There was an error in the forked process
[ERROR] org.apache.maven.surefire.util.SurefireReflectionException: java.lang.NoSuchMethodError: org.apache.maven.surefire.providerapi.ProviderParameters.isInsideFork()Z
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:134)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.createProviderInCurrentClassloader(ForkedBooter.java:230)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:199)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
[ERROR] Caused by: java.lang.NoSuchMethodError: org.apache.maven.surefire.providerapi.ProviderParameters.isInsideFork()Z
[ERROR] at org.apache.maven.surefire.junit4.JUnit4Provider.<init>(JUnit4Provider.java:103)
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[ERROR] at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:130)

我有点怀疑 surefire-apisurefire-junit4 有相同的版本,所以我确保 Maven 为两者加载相同的版本,但是有行为没有变化。

这里有什么问题?如何获取要构建的测试插件?

最佳答案

好的,如果目标平台文件包含,它可以在没有愚蠢的 Maven 依赖项的情况下工作

<unit id="org.hamcrest.core" version="0.0.0"/>
<unit id="org.junit" version="0.0.0"/>
<unit id="org.eclipse.jdt.junit.runtime" version="0.0.0"/>
<unit id="org.eclipse.jdt.junit4.runtime" version="0.0.0"/>

Manifest.MF 包含

Require-Bundle: org.eclipse.jdt.junit4.runtime,
org.junit

关于tycho - JUnit4Provider 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34654579/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com