单元测试通过Maven,但未通过Cobertura:“期望分支目标65处的堆栈图帧” [英] Unit tests passing through Maven, but failing through Cobertura: "Expecting a stackmap frame at branch target 65"

查看:135
本文介绍了单元测试通过Maven,但未通过Cobertura:“期望分支目标65处的堆栈图帧”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在我的Java / Spring-MVC项目中添加了Cobertura插件。奇怪的是,我的所有单元测试都在通过,当Maven进行初始测试运行时它们仍然通过,但是当Cobertura尝试运行测试时,它们都会失败,并显示相同的错误消息:

I recently added the Cobertura plugin to my Java/Spring-MVC project. The strange thing is that all my unit tests were passing, and they still pass when Maven does its initial test run, but then when Cobertura tries to run the tests, they all fail with the same error message:

Expecting a stackmap frame at branch target 65 in method xxx.xxxx.xxxx.xxxx;)V at offset 40

我不知道为什么会发生这种情况,甚至不知道如何修复它。我搜索过互联网,但没有发现任何类似的问题。我使用JUnit和spring-test-mvc进行测试。

I have no idea why this is happening and don't even know how to go about fixing it. I've searched the internet but haven't found any similar problems. I use JUnit and spring-test-mvc for testing.

有没有人见过这个?

推荐答案

当然我在问这个问题之后就找到了答案,即使我之前搜索了很长时间......

Of course I find the answer right after asking the question, even though I searched for quite awhile before...

问题在于Cobertura在使用Java 1.7时遇到了麻烦。您必须将以下行添加到您的pom.xml:

The problem is that Cobertura has trouble working with Java 1.7. You must add the following line to your pom.xml:

<argLine>-XX:-UseSplitVerifier</argLine>

这是配置元素。以下是整个Cobertura部分:

That goes in the configuration element. Here is the entire Cobertura section:

     <plugin>
        <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <argLine>-XX:-UseSplitVerifier</argLine>
                <formats>
                    <format>xml</format>
                </formats>
            </configuration>
            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>cobertura</goal>
                    </goals>
                </execution>
            </executions>
       </plugin>

现在一切都按预期工作。

Now everything works as expected.

这篇关于单元测试通过Maven,但未通过Cobertura:“期望分支目标65处的堆栈图帧”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆