1 Test coverage implementation technology
- Instrumentation: Code injection, inserting statistical code at key positions in the product code to obtain test coverage data
- Class Instrumentation: Insert statistical code into the compiled .class file
- Source Instrumentation: Insert the statistical code into the source code and compile it into a new .class file
- Custom JVM: Insert statistical code into .class in the JVM. Test coverage analysis can be done during the execution of the test code by the JVM
2 Introduction to EclEmma
- An excellent open source software testing tool
- A plugin for eclipse
- Ability to perform coverage tests on programs written in the Java language
- Ability to launch in workbench
- Directly analyze code coverage
- Coverage results are immediately aggregated and highlighted in the Java source editor
- Detailed coverage test reports can also be generated from the results of program execution
- Can be used in combination with JUnit and TestNG
- How it works: Class Instrumentation
3 EclEmma test coverage metrics
- Line coverage: Partial line coverage: a>b?a:b
- Basic Statement Block Coverage: Basic Statement Block: Code area without if-else branches
- Class Coverage: Loaded and initialized by the JVM
- Method coverage: The first basic block of statements is executed
4 EclEmma installation
- Start eclipse -> click the Help menu -> Install New Software, in the pop-up dialog box, click Add
- Enter a Name, such as EclEmma. Enter Location: http://update.eclemma.org/
- Restart eclipse after installation, if the installation is successful, a new button will appear on the toolbar, as shown in Figure 1
Figure 1 EclEmma button