报告内容如下:

  分析后台日志
  我们再看看这时后台日志打印的内容
  qyfmac$mvncleancobertura:cobertura
  [INFO]Scanningforprojects...
  [INFO]
  [INFO]------------------------------------------------------------------------
  [INFO]Buildinglearn-maven1.0-SNAPSHOT
  [INFO]------------------------------------------------------------------------
  [INFO]
  [INFO]---maven-clean-plugin:2.5:clean(default-clean)@learn-maven---
  [INFO]Deleting/Users/qyfmac/git/learn-maven/target
  [INFO]
  [INFO]>>>cobertura-maven-plugin:2.7:cobertura(default-cli)>[cobertura]test@learn-maven>>>
  [INFO]
  [INFO]---maven-resources-plugin:2.6:resources(default-resources)@learn-maven---
  [WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
  [INFO]skipnonexistingresourceDirectory/Users/qyfmac/git/learn-maven/src/main/resources
  [INFO]
  [INFO]---maven-compiler-plugin:3.1:compile(default-compile)@learn-maven---
  [INFO]Changesdetected-recompilingthemodule!
  [WARNING]Fileencodinghasnotbeenset,usingplatformencodingUTF-8,i.e.buildisplatformdependent!
  [INFO]Compiling1sourcefileto/Users/qyfmac/git/learn-maven/target/classes
  [INFO]
  [INFO]---cobertura-maven-plugin:2.7:instrument(default-cli)@learn-maven---
  [INFO]Cobertura2.1.1-GNUGPLLicense(NOWARRANTY)-SeeCOPYRIGHTfile
  [INFO]Cobertura:Savedinformationon1classes.
  [INFO]Cobertura:Savedinformationon1classes.
  [INFO]Instrumentationwassuccessful.
  [INFO]NOTaddingcoberturaserfiletoattachedartifactslist.
  [INFO]
  [INFO]---maven-resources-plugin:2.6:testResources(default-testResources)@learn-maven---
  [WARNING]Usingplatformencoding(UTF-8actually)tocopyfilteredresources,i.e.buildisplatformdependent!
  [INFO]skipnonexistingresourceDirectory/Users/qyfmac/git/learn-maven/src/test/resources
  [INFO]
  [INFO]---maven-compiler-plugin:3.1:testCompile(default-testCompile)@learn-maven---
  [INFO]Changesdetected-recompilingthemodule!
  [WARNING]Fileencodinghasnotbeenset,usingplatformencodingUTF-8,i.e.buildisplatformdependent!
  [INFO]Compiling1sourcefileto/Users/qyfmac/git/learn-maven/target/test-classes
  [INFO]
  [INFO]---maven-surefire-plugin:2.12.4:test(default-test)@learn-maven---
  [INFO]Surefirereportdirectory:/Users/qyfmac/git/learn-maven/target/surefire-reports
  -------------------------------------------------------
  TESTS
  -------------------------------------------------------
  Runningcom.qyf404.learn.maven.AppTest
  Testsrun:2,Failures:0,Errors:0,Skipped:0,Timeelapsed:0.335sec
  [INFO]Cobertura:Loadedinformationon1classes.
  [INFO]Cobertura:Savedinformationon1classes.
  Results:
  Testsrun:2,Failures:0,Errors:0,Skipped:0
  [INFO]
  [INFO]<<<cobertura-maven-plugin:2.7:cobertura(default-cli)<[cobertura]test@learn-maven<<<
  [INFO]
  [INFO]---cobertura-maven-plugin:2.7:cobertura(default-cli)@learn-maven---
  [INFO]Cobertura2.1.1-GNUGPLLicense(NOWARRANTY)-SeeCOPYRIGHTfile
  [INFO]Cobertura:Loadedinformationon1classes.
  Reporttime:159ms
  [INFO]CoberturaReportgenerationwassuccessful.
  [INFO]------------------------------------------------------------------------
  [INFO]BUILDSUCCESS
  [INFO]------------------------------------------------------------------------
  [INFO]Totaltime:6.624s
  [INFO]Finishedat:2015-12-08T16:42:47+08:00
  [INFO]FinalMemory:22M/227M
  [INFO]------------------------------------------------------------------------
  这行日志[INFO]>>>cobertura-maven-plugin:2.7:cobertura(default-cli)>[cobertura]test@learn-maven>>>告诉我们cobertura-maven-plugin绑定到了maven生命周期test上.
  这行日志[INFO]---cobertura-maven-plugin:2.7:instrument(default-cli)@learn-maven---告诉我们在完成项目源码编译后,执行了cobertura:instrument,对项目源码做了标记.
  这两行日志
  [INFO]Cobertura:Loadedinformationon1classes.
  [INFO]Cobertura:Savedinformationon1classes.
  在执行测试用例时打出的,很明显cobertura-maven-plugin在执行测试用例时做了些事情(这只是个猜测,具体干了啥是要看源码的).
  这行日志[INFO]CoberturaReportgenerationwassuccessful.告诉我们生成覆盖率报告成功.而之前执行了测试用例,而且生成报告用了之前生成的class文件.
  通过分析日志,我们基本能猜测到:
  cobertura-maven-plugin绑定到了maven生命周期test上.
  源码编译完成后,cobertura-maven-plugin生成了自己的一套class文件来标记源码,存放在/target/generated-classes/cobertura/目录里.
  测试用例执行时,cobertura-maven-plugin修改了自己生成的那套标记源码的class文件,并根据这套class文件生成了终的覆盖率报告.