我正在使用 Maven 3.0.3、JUnit 4.8.1 和 Spring 3.1.1.RELEASE。我以这种方式配置了我的 Surefire 插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<reuseForks>false</reuseForks>
<argLine>-Xmx2048m -XX:MaxPermSize=512M</argLine>
</configuration>
</plugin>
我注意到当我的单元测试由于 IllegalStateExceptions 而失败时,Maven 永远不会打印出在执行结束时失败的测试名称。相反,我会看到
mvn clean install
...
Tests in error:
? IllegalState Failed to load ApplicationContext
? IllegalState Failed to load ApplicationContext
? IllegalState Failed to load ApplicationContext
? IllegalState Failed to load ApplicationContext
如何让 Mavne 打印出有关测试失败的更具体信息?现在,我必须深入研究 surefire-reports 目录以找出失败的原因。我的大多数 JUnit 测试如下所示:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:test-context.xml" })
public class CleverTeacherServiceTest extends AbstractImportServiceTest
{