marc r. hoffmann eclipsecon 2010...
TRANSCRIPT
![Page 1: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/html5/thumbnails/1.jpg)
© 2010 by Marc R. Hoffmann | made available under the EPL v1.0 | 2010-03-25
The Future of Code Coverage for Eclipse
Marc R. HoffmannEclipseCon 20102010-03-25
![Page 2: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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 CoverageEclEmmaEMMAJaCoCo
Sorry,no robots
![Page 3: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
EclEmma – Code Coverage for Eclipse
|
![Page 5: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Monthly EclEmma Downloads
2007 2008 2009 2010
2,000
4,000
6,000
8,000
10,000
1.0
1.1
1.21.3
1.4
EclEmma EMMA
![Page 6: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Current Status of EMMA
Great Tool! ☺Last Release
2.0.5312, 2005-06-13Project Activity
Latest Commit 2006-02-23
![Page 7: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Action Required!
Making EMMA alive?Using a different Library?Starting a new Project?
![Page 8: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
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 9: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
The „JaCoCo“ Project
Java Code CoverageStarted Mid of 2009Beta Releases Sinces End of 2009EPLHosted within EclEmma (SourceForge)
www.eclemma.org/jacoco
TeamMarc R. Hoffmann (GER)Brock Janiczak (AUS)Christoph Beck (GER)Radek Liba (GER)
![Page 10: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
JaCoCo Demo
![Page 11: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Coverage
Analysis
Coverage Analysis
*.exec
*.class
Actual
Target
![Page 12: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
JaCoCo Ant Tasks: Coverage
![Page 13: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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: Report
![Page 14: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Report Sorting
Project A
Project B
80%
35%
Sort Items by absolut amount of missed code.
![Page 16: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
JaCoCo in Eclipse
![Page 17: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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 on JDT Test Suite
Credits: Olivier Thomann
![Page 18: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Implementation Details
![Page 19: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Architecture Overview
Set of OSGi Bundles
core
report
agent
ASMant
Ant
![Page 20: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Java Agent
java.lang.instrumentIn-MemoryNo class file preprocessing
byte[] transform(ClassLoader loader,String className,Class<?> classBeingRedefined,ProtectionDomain protectionDomain,byte[] classfileBuffer)throws IllegalClassFormatException
![Page 21: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
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 22: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Basic Block Coverage
ALOAD probearrayICONST probeidICONST_1BASTORE
ALOAD probearrayICONST probeidICONST_1BASTORE
![Page 23: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Class Identity
IssuesMultiple Versions of the Same Class in one VMModified Classes over Time
Use CRC64 HashFits into Java long
![Page 24: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
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 25: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
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 LoggingInstrumented JRE Class
![Page 26: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
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 27: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Runtime Isolation
![Page 28: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
JaCoCo Implementation Maxims
Test FirstKeep it simple and fastRelease Often and Consistent
Every Work Item released as Trunk Build
![Page 29: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
JaCoCo Status
Statement CoverageHTML, XML, CSV ReportsAnt TasksDocumentationAPIs not frozen yet!
![Page 30: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Future Plans
Branch CoverageFiltersEclipse PluginMaven Integration
![Page 31: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Get Involved
Download the Latest Build at http://www.eclemma.org/jacocoIntegrate it With Your
BuildWhatever Tool
Get in Touch forFeature RequestsBug ReportsContributions
![Page 32: Marc R. Hoffmann EclipseCon 2010 2010-03-25download.eclipselab.org/jacoco/docs/20100325-the-future-of-code... · © 2010 by Marc R. Hoffmann | made available under the EPL v1.0 |](https://reader036.vdocuments.net/reader036/viewer/2022070815/5f0ec5727e708231d440dbae/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
Short-Term Plans
San Francisco Area until SaturdayGet in Touch
Questions?Thank You!