我对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();
}
}
<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版本上运行测试没有任何错误。有什么想法吗?
答案 0 :(得分:1)
我在jira.codehaus.org上打开了a bug,得到了这个问题在maven-surefire-plugin v.2.11中得到解决的答案。因为我使用2.10版本,所以发生了错误。最新的surefire插件版本是2.12,所以更改surefire配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>never</forkMode>
</configuration>
</plugin>
并且测试将成功运行。