Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何让Maven打印出失败的测试名称?_Spring_Maven_Junit_Maven Surefire Plugin - Fatal编程技术网

Spring 如何让Maven打印出失败的测试名称?

Spring 如何让Maven打印出失败的测试名称?,spring,maven,junit,maven-surefire-plugin,Spring,Maven,Junit,Maven Surefire Plugin,我使用的是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>

我使用的是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>
我怎样才能让Mavne打印出更多关于测试失败的具体信息?现在我必须在surefire reports目录中查找失败的原因。我的大多数JUnit测试如下所示:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:test-context.xml" })
public class CleverTeacherServiceTest extends AbstractImportServiceTest
{

我认为您的Spring测试配置在测试运行之前失败了。您通常会看到控制台中列出的失败测试,如:


T T S T S 运行测试套件 ..
测试运行:234,失败:1,错误:0,跳过:0,经过的时间:7.019秒我尝试了“-Dsurefire.useFile=false”标志,但结果仍打印为“?IllegalState未能加载ApplicationContext”。如果我的问题不清楚,我正试图找出如何用实际的测试名称替换测试结果中的“?”。我很惊讶没有堆栈跟踪或其他列出错误测试的信息。我创建了一个缺少上下文的伪测试,在控制台中得到了一个非常明显的错误,就像我在上面发布的一样。有一个堆栈跟踪,但是有几百个测试,向上滚动所有控制台输出并找到具体的故障是很麻烦的。我希望有一个简单的方法来打印摘要,就像Maven有时会做的那样,但显然不是在这里。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:test-context.xml" })
public class CleverTeacherServiceTest extends AbstractImportServiceTest
{