我正在使用cobertura maven插件来生成关于我的基于spring的应用程序的测试代码覆盖率的报告。我的单元测试配置为:在cobertura-maven-plugin测试中加载Spring ApplicationContext
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/testAppContext.xml")
public class TestCase extends TestBase
testAppContext.xml - 春天IOC配置位于/src/test/resources/testAppContext.xml
而且我的Cobertura的相关pom.xml的部分是:
<build>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
<build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
当我做“mvn干净安装”它工作正常,但当我使“mvn网站” - 基于弹簧的测试失败,因为“无法加载ApplicationContext”与基础“注入自动装配依赖失败”,所以我收到有关测试覆盖率的错误报告
我认为这可能是因为testAppContext.xml在“site”目标或其他目录中不在类路径中。任何建议如何解决这个问题?
谢谢你的帮助!
你能发布完整的堆栈跟踪吗?也请看看:http://stackoverflow.com/questions/8391944 –
@TomaszNurkiewicz它也适用于我的情况。我没有“名为'x'的Bean必须是[y]类型,但实际上是在stacktrace中键入[$ Proxy]”,所以我没有机会找到这个解决方案。感谢您的回答和此链接! –