【发布时间】:2012-03-03 04:57:27
【问题描述】:
我有一个简单的maven插件测试:
public class SimpleMavenTest extends AbstractMojoTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
// code
}
public void testCase() throws Exception {
// test case
}
@Override
protected void tearDown() throws Exception {
// code
super.tearDown();
}
}
用这样的maven-surefire-plugin配置:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>never</forkMode>
</configuration>
</plugin>
</plugins>
</build>
在 maven 3.0.4 发布之前,我的 SimpleMavenTest 运行成功。但是当我使用 maven 3.0.4 运行测试时,出现了下一个错误:
java.lang.IllegalStateException: The internal default plexus-bootstrap.xml is missing. This is highly irregular, your plexus JAR is most likely corrupt.
at org.codehaus.plexus.DefaultPlexusContainer.initializeConfiguration(DefaultPlexusContainer.java:1052)
at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:627)
at org.codehaus.plexus.PlexusTestCase.setUp(PlexusTestCase.java:119)
at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:69)
at org.maven.test.MyMojoTest.setUp(MyMojoTest.java:12)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
我看了这里:http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html 并尝试以这种方式更改 maven-surefire-plugin 配置:
<configuration>
<forkMode>once</forkMode>
</configuration>
一切正常。但如果我做:
<forkMode>never</forkMode>
出现上述错误。这很奇怪,因为在 maven 3.0.3 和以前的 maven 版本上,测试运行时没有任何错误。有什么想法吗?
【问题讨论】:
-
我有类似的设置,但我的surefire配置中有版本信息,如下所示
${surefire.version} 。不确定它是否有帮助。你可以试试吗? -
你的 pom 中有这个组 id 的条目吗?
org.apache.maven.wagon -
我尝试添加
${surefire.version} ,但又出现错误。我有这个条目:org.apache.maven.plugins 。我用您的尝试替换它:org.apache.maven.wagon 并成功试运行。谢谢你的帮助!但我需要它与org.apache.maven.plugins 一起使用,正如我在上面所写的,这很有趣:为什么它适用于 maven 3.0.3 而不适用于 maven 3.0.4。跨度> -
我上周遇到了这个问题,但发现它很不寻常。我会尝试暴力破解它,看看会发生什么。如果你愿意,我可以把它列为这篇文章的答案。
-
如果您找到解决方案,请在此处发布。我也会在这个麻烦中继续搜索。
标签: java unit-testing maven maven-plugin