【发布时间】:2014-08-24 21:41:55
【问题描述】:
我第一次从事 Eclipse RCP + Maven 项目,我想用 JUnit 对我的包运行一些单元测试。似乎最推荐的方法是创建一个包片段并使用 Tycho 插件之类的东西来解决依赖关系。但是,当我在我的主 pom 中运行 mvn clean verify 时,它应该运行测试并部署我的应用程序,但我得到了以下错误:
[ERROR] Cannot resolve project dependencies:
[ERROR] You requested to install 'myproject.app.feature.feature.group 1.0.0' but it could not be found
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test (default-test) on project myproject.app.viewmanager-test: Execution default-test of goal org.eclipse.tycho:tycho-surefire-plugin:0.21.0:test failed: No solution found because the problem is unsatisfiable.: [Unable to satisfy dependency from tycho-extra-1408913392535 0.0.0.1408913392535 to myproject.app.feature.feature.group 1.0.0.; Unable to satisfy dependency from tycho-1408913392552 0.0.0.1408913392552 to myproject.app.feature.feature.group 1.0.0.; No solution found because the problem is unsatisfiable.] -> [Help 1]
我了解 Maven 无法找到“myproject.app.feature.feature.group 1.0.0”,但我不知道它是从哪里得到的,因为它的名称似乎是错误的。
值得一提的是,当我在 Eclipse(而不是 Maven)中运行单元测试时,它可以工作。
这是我的测试片段中的第谷配置:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<dependencies>
<dependency>
<type>eclipse-feature</type>
<artifactId>myproject.app.feature</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
正如here 所建议的那样,我将该功能添加为依赖项,因为我的测试片段除了它的主机之外还需要一些其他捆绑包,所以我期待它能够工作。
有什么建议吗?我发现的最相似的问题是this one,但两种解决方案都不适用于我。
【问题讨论】:
-
我知道 Maven 找不到 'myproject.app.feature.feature.group 1.0.0' 但我不知道它是从哪里得到的,因为似乎名称是错误的。 - 实际上名称是正确的,但这很难看到。此错误消息直接来自 p2 解析器,因此它们处于非常低的抽象级别。例如,
.feature.group后缀是 p2 区分特征和包的方式。我写了一个wiki page 来帮助理解来自 p2 的错误消息。
标签: maven junit eclipse-rcp tycho tycho-surefire-plugin