码迷,mamicode.com
首页 > 其他好文 > 详细

Maven学习13之覆盖率测试

时间:2016-05-12 15:51:43      阅读:330      评论:0      收藏:0      [点我收藏+]

标签:


1.build的时候的goals为:

cobertura:cobertura

2.运行之后在site下面可以看到html文件


3.运行记录:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenLearning 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> cobertura-maven-plugin:2.7:cobertura (default-cli) > [cobertura]test @ MavenLearning >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MavenLearning ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\all\eclipse432\MavenLearning\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MavenLearning ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- cobertura-maven-plugin:2.7:instrument (default-cli) @ MavenLearning ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 1 classes.
[INFO] Cobertura: Saved information on 1 classes.
[INFO] Cobertura: Saved information on 1 classes.

[INFO] Instrumentation was successful.
[INFO] NOT adding cobertura ser file to attached artifacts list.
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MavenLearning ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\all\eclipse432\MavenLearning\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MavenLearning ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to D:\all\eclipse432\MavenLearning\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MavenLearning ---
[INFO] Surefire report directory: D:\all\eclipse432\MavenLearning\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.xubo.maven.MavenLearning.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 sec
Running org.xubo.maven.MavenLearning.CopyOfHelloWorldTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.009 sec <<< FAILURE!
initializationError(org.xubo.maven.MavenLearning.CopyOfHelloWorldTest)  Time elapsed: 0.009 sec  <<< ERROR!
java.lang.Exception: Method testHello() should be public
	at org.junit.runners.model.FrameworkMethod.validatePublicVoid(FrameworkMethod.java:88)
	at org.junit.runners.model.FrameworkMethod.validatePublicVoidNoArg(FrameworkMethod.java:66)
	at org.junit.runners.ParentRunner.validatePublicVoidNoArgMethods(ParentRunner.java:122)
	at org.junit.runners.BlockJUnit4ClassRunner.validateTestMethods(BlockJUnit4ClassRunner.java:193)
	at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:168)
	at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:115)
	at org.junit.runners.ParentRunner.validate(ParentRunner.java:269)
	at org.junit.runners.ParentRunner.<init>(ParentRunner.java:66)
	at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:59)
	at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:250)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Running org.xubo.maven.MavenLearning.TestHelloWorld
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.021 sec <<< FAILURE!
initializationError(org.xubo.maven.MavenLearning.TestHelloWorld)  Time elapsed: 0.021 sec  <<< ERROR!
java.lang.Exception: Method testHello() should be public
	at org.junit.runners.model.FrameworkMethod.validatePublicVoid(FrameworkMethod.java:88)
	at org.junit.runners.model.FrameworkMethod.validatePublicVoidNoArg(FrameworkMethod.java:66)
	at org.junit.runners.ParentRunner.validatePublicVoidNoArgMethods(ParentRunner.java:122)
	at org.junit.runners.BlockJUnit4ClassRunner.validateTestMethods(BlockJUnit4ClassRunner.java:193)
	at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:168)
	at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:115)
	at org.junit.runners.ParentRunner.validate(ParentRunner.java:269)
	at org.junit.runners.ParentRunner.<init>(ParentRunner.java:66)
	at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:59)
	at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:250)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)


Results :

Tests in error: 
  initializationError(org.xubo.maven.MavenLearning.CopyOfHelloWorldTest): Method testHello() should be public
  initializationError(org.xubo.maven.MavenLearning.TestHelloWorld): Method testHello() should be public

Tests run: 3, Failures: 0, Errors: 2, Skipped: 0

[ERROR] There are test failures.

Please refer to D:\all\eclipse432\MavenLearning\target\surefire-reports for the individual test results.
[INFO] 
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test @ MavenLearning <<<
[INFO] 
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @ MavenLearning ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 1 classes.
Report time: 103ms

[INFO] Cobertura Report generation was successful.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.397 s
[INFO] Finished at: 2016-05-10T17:10:55+08:00
[INFO] Final Memory: 24M/166M
[INFO] ------------------------------------------------------------------------


4.pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>org.xubo.maven</groupId>
	<artifactId>MavenLearning</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>MavenLearning</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<junit.version>4.11</junit.version>
	</properties>


	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.8.1</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.17</version>
			<scope>compile</scope>
		</dependency>
	</dependencies>

	<!-- <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> 
		<artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> 
		</plugin> </plugins> </build> -->

</project>



Maven学习13之覆盖率测试

标签:

原文地址:http://blog.csdn.net/xubo245/article/details/51364846

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!