0 0

使用cobertura-maven-plugin做单元测试覆盖率碰到的问题3

项目中一直使用的是cobertura-maven-plugin做单元测试覆盖率统计
Pom.xml中描述如下

<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>cobertura-maven-plugin</artifactId>
	<version>2.4</version>
	<configuration>
		<encoding>UTF-8</encoding>
		<formats>
			<format>html</format>
			<format>xml</format>
		</formats>
	</configuration>
</plugin>



输入命令mvn cobertura:cobertura 时,提示以下信息

Report time: 2937ms
[ERROR] net.sourceforge.cobertura.javancss.parser.ParseException: Encountered " <IDENTIFIER> "\u6d93\u5d85\u6093 "" at line 120, column 74.
Was expecting one of:
"instanceof" ...
")" ...
"," ...
">" ...
"<" ...
"?" ...
"==" ...
"<=" ...
">=" ...
"!=" ...
"||" ...
"&&" ...
"++" ...
"--" ...
"+" ...
"-" ...
"*" ...
"/" ...
"&" ...
"|" ...
"^" ...
"%" ...
">" ...

at net.sourceforge.cobertura.javancss.parser.JavaParser.generateParseException(JavaParser.java:10296)
at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_consume_token(JavaParser.java:10172)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Arguments(JavaParser.java:3610)
at net.sourceforge.cobertura.javancss.parser.JavaParser.PrimarySuffix(JavaParser.java:3515)
at net.sourceforge.cobertura.javancss.parser.JavaParser.PrimaryExpression(JavaParser.java:3396)
at net.sourceforge.cobertura.javancss.parser.JavaParser.StatementExpression(JavaParser.java:4083)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3808)
at net.sourceforge.cobertura.javancss.parser.JavaParser.BlockStatement(JavaParser.java:3997)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Block(JavaParser.java:3947)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3778)
at net.sourceforge.cobertura.javancss.parser.JavaParser.IfStatement(JavaParser.java:4253)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3816)
at net.sourceforge.cobertura.javancss.parser.JavaParser.BlockStatement(JavaParser.java:3997)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Block(JavaParser.java:3947)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3778)
at net.sourceforge.cobertura.javancss.parser.JavaParser.IfStatement(JavaParser.java:4258)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3816)
at net.sourceforge.cobertura.javancss.parser.JavaParser.BlockStatement(JavaParser.java:3997)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Block(JavaParser.java:3947)
at net.sourceforge.cobertura.javancss.parser.JavaParser.TryStatement(JavaParser.java:4618)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Statement(JavaParser.java:3847)
at net.sourceforge.cobertura.javancss.parser.JavaParser.BlockStatement(JavaParser.java:3997)
at net.sourceforge.cobertura.javancss.parser.JavaParser.Block(JavaParser.java:3947)
at net.sourceforge.cobertura.javancss.parser.JavaParser.MethodDeclaration(JavaParser.java:2039)
at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassBodyDeclaration(JavaParser.java:1082)
at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassBody(JavaParser.java:941)
at net.sourceforge.cobertura.javancss.parser.JavaParser.UnmodifiedClassDeclaration(JavaParser.java:854)
at net.sourceforge.cobertura.javancss.parser.JavaParser.ClassDeclaration(JavaParser.java:761)
at net.sourceforge.cobertura.javancss.parser.JavaParser.TypeDeclaration(JavaParser.java:608)
at net.sourceforge.cobertura.javancss.parser.JavaParser.CompilationUnit(JavaParser.java:353)
at net.sourceforge.cobertura.javancss.parser.JavaParser.parse(JavaParser.java:137)
at net.sourceforge.cobertura.javancss.Javancss._measureSource(Javancss.java:256)
at net.sourceforge.cobertura.javancss.Javancss._measureRoot(Javancss.java:339)
at net.sourceforge.cobertura.javancss.Javancss.<init>(Javancss.java:419)
at net.sourceforge.cobertura.reporting.ComplexityCalculator.getAccumlatedCCNForSource(ComplexityCalculator.java:102)
at net.sourceforge.cobertura.reporting.ComplexityCalculator.getAccumlatedCCNForSingleFile(ComplexityCalculator.java:139)
at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForSourceFileNameInternal(ComplexityCalculator.java:224)
at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForPackageInternal(ComplexityCalculator.java:194)
at net.sourceforge.cobertura.reporting.ComplexityCalculator.getCCNForProject(ComplexityCalculator.java:164)
at net.sourceforge.cobertura.reporting.xml.XMLReport.<init>(XMLReport.java:80)
at net.sourceforge.cobertura.reporting.Main.parseArguments(Main.java:107)
at net.sourceforge.cobertura.reporting.Main.main(Main.java:174)

 

项目中的代码是正常代码,

 报警告的这一行代码如下

notSameValueField.append("\"值类型\"不同,数据库值为\"");

 

在编绎、打包、测试时都是正常的,但就是在做覆盖率统计时报这样的信息,是少引了某个plugin吗? 请各路达人 指点迷津。。。

 

2011年3月22日 10:43

3个答案 按时间排序 按投票排序

0 0

升级插件版本,最新为2.7。

2015年3月18日 13:58
0 0

中文字符串前后加半角空格,可以暂时解决。

2014年5月21日 16:30
0 0

http://jira.codehaus.org/browse/MCOBERTURA-161  这好像是个bug,好像没解决

2012年11月22日 11:14

相关推荐

Global site tag (gtag.js) - Google Analytics