我有一个针对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 及以前的版本中,测试都可以正常运行而没有任何错误。有什么想法吗?