The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf ·...
Transcript of The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf ·...
![Page 1: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/1.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future ofCode Coverage for Eclipse
Marc R. HoffmannEclipse Summit 20102010-11-03, Ludwigsburg
![Page 2: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/2.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Outline
Code CoverageEclEmmaEMMA
JaCoCo
![Page 3: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/3.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Code Coverage
„Legacy Code is simply code without tests.“
Michael Feathers:Working Effectively with Legacy Code
![Page 4: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/4.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Example: JUnit with Code Coverage
![Page 5: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/5.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
EclEmma – Code Coverage for Eclipse
|
![Page 6: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/6.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Monthy EclEmma Downloads
2,000
4,000
6,000
8,000
10,000
2007 2008 2009 2010
EclEmma EMMA
1.4
1.0
1.1
1.21.3
1.5
![Page 7: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/7.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Current Status of EMMA
Great Tool! ☺Last Release
2.0.5312, 2005-06-13Project Activity
Latest Commit 2006-02-23
![Page 8: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/8.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Action Required!
Making EMMA alive?Using a different Library?Starting a new Project?
![Page 9: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/9.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Requirements for a Code Coverage Library
Be a Library!Open for Different Usage ScenariosDesigned for Integration
Regression TestsFramework IndependentScalable for Large ProjectsFast Enough for Agile Teams
![Page 10: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/10.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
The „JaCoCo“ Project
Java Code CoverageStarted Mid of 2009Beta Releases Sinces End of 2009EPLHosted within EclEmma (SourceForge)
www.eclemma.org/jacoco
Active TeamMarc R. Hoffmann (GER)Brock Janiczak (AUS)
![Page 11: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/11.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo Demo
![Page 12: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/12.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Coverage
Analysis
Coverage Analysis
*.exec
*.class
Actual
Target
![Page 13: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/13.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo Ant Tasks: Coverage
![Page 14: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/14.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo Ant Tasks: Report
![Page 15: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/15.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo Ant Tasks: Report
![Page 16: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/16.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Report Sorting
Project A
Project B
80%
35%
Sort Items by absolut amount of missed code.
![Page 17: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/17.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo in Eclipse
![Page 18: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/18.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo on JDT Test Suite
Credits: Olivier Thomann
![Page 19: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/19.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Implementation Details
![Page 20: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/20.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Implementation Strategies
J 010Compiler Class Loader
JVM
JVM Profiling
Source Offline On-the-Fly
Instrumentation
Byte Code
![Page 21: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/21.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Java Agent
java.lang.instrumentIn-MemoryNo class file preprocessing
byte[] transform(ClassLoader loader,String className,Class<?> classBeingRedefined,ProtectionDomain protectionDomain,byte[] classfileBuffer)throws IllegalClassFormatException
![Page 22: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/22.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Implementation and Packaging
Set of OSGi Bundles< 3,000 LOC< 400 KB
ASM
Ant
core
agent
report
ant
3rd Party Dependencies
![Page 23: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/23.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Keep the Good Ideas of EMMA
Byte Code InstrumentationJRE and Platform Independent
Basic Block CoverageGood Tradeoff between Datails and Overhead
Using boolean[] Arrays for Probe StorageConcurrency PossibleSharing the Instance
![Page 24: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/24.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Basic Block Coverage
ALOAD probearrayICONST probeidICONST_1BASTORE
ALOAD probearrayICONST probeidICONST_1BASTORE
![Page 25: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/25.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Class Identity
IssuesMultiple Versions of the Same Class in one VMModified Classes over Time
Use CRC64 HashFits into Java long
![Page 26: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/26.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Avoid Coverage Runtime Dependency
Object access = ... // Retrieve instance
Object[] args = new Object[3];args[0] = Long.valueOf(0x89f47a04b2881d38); // class idargs[1] = "com/example/MyClass"; // class nameargs[2] = Integer.valueOf(24); // probe count
access.equals(args);
boolean[] probes = (boolean[]) args[0];
Avoid Class Loading IssuesUse JRE APIs only!
![Page 27: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/27.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
How to Share an Object Instance?
The Challenge:
Share a given object instanceby using JDK APIs only.
Current Solutions:Object as System PropertyInstall Custom Handler with Java LoggingInstall Custom URL Protocol HandlerInstrumented JRE Class
![Page 28: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/28.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Runtime Isolation
Eating one‘s own dog food:Run JaCoCo on JaCoCo?
Java Agent becomes part of the application classpath Rename classes in jacocoagent.jarduring build ☺
![Page 29: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/29.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Runtime Isolation
![Page 30: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/30.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo Implementation Maxims
Test FirstKeep it simple and fastRelease Often and Consistent
Every Work Item released as Trunk Build
![Page 31: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/31.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
JaCoCo Status
Statement CoverageHTML, XML, CSV ReportsAnt TasksDocumentationAPIs not frozen yet!
3rd Party IntegrationsSonar Plug-in
![Page 32: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/32.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Future Plans
Branch CoverageFiltersEclipse PluginMaven Integration
![Page 33: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/33.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Get Involved
Download the Latest Build at http://www.eclemma.org/jacocoIntegrate it With Your
BuildWhatever Tool
Get in Touch forFeature RequestsBug ReportsContributions
![Page 34: The Future of Code Coverage for Eclipsedownload.eclipselab.org/...future-of-code-coverage.pdf · 11/3/2010 · The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann](https://reader033.fdocuments.in/reader033/viewer/2022052022/60379eb9ee734878e8020f6f/html5/thumbnails/34.jpg)
The Future of Code Coverage for Eclipse | © 2010 by Marc R. Hoffmann | made available under the EPL v1.0
The Future of Code Coverage for Eclipse
Questions?
Thank You!