EMMA Code coverage Matcher

Article ID:360033193891
1 minute readKnowledge base

For this matcher, a Custom Step property called "component" was created so that the matcher will save the coverage information into a nested property sheet based on which project the step was running on - the procedure ran numerous code coverage steps for different code projects.

push (@::gMatchers,
  {
        id =>               "emmaMatcher",
        pattern =>     q{^\s*(\d+)%\s+(?:[()\/\d.]+)(?:!?)\s+}.
                       q{\s*(\d+)%\s+(?:[()\/\d.]+)(?:!?)\s+}.
                       q{\s*(\d+)%\s+(?:[()\/\d.]+)(?:!?)\s+}.
                       q{\s*(\d+)%\s+(?:[()\/\d.]+)(?:!?)\s+}.
                       q{all\s+classes\s*$},
        action =>           q{
                              diagnostic("", "info",-1,1);
                              #my $component = getProperty("/myJobStep/component");
                              my $component = "$[/myStep/component]";
                              setProperty("summary",
                                "class: $1%\n".
                                "method: $2%\n".
                                "block: $3%\n".
                                "line: $4%\n"
                              );
                              setProperty("/myJob/$component/class_coverage",$1);
                              setProperty("/myJob/$component/method_coverage",$2);
                              setProperty("/myJob/$component/block_coverage",$3);
                              setProperty("/myJob/$component/line_coverage",$4);
                             },
  },
);

Sample EMMA Output

[EMMA v2.0.4015 (stable) report, generated Sat May 15 12:02:28 CDT 2004]
-------------------------------------------------------------------------------
OVERALL COVERAGE SUMMARY:

[class, %]	[method, %]	[block, %]	[line, %]	[name]
85%  (157/185)!	65%  (1345/2061)!	60%  (44997/74846)!	64%  (8346.3/13135)!	all classes

OVERALL STATS SUMMARY:

total packages:	8
total classes:	185
total methods:	2061
total executable files:	62
total executable lines:	13135

COVERAGE BREAKDOWN BY PACKAGE:

[class, %]	[method, %]	[block, %]	[line, %]	[name]
25%  (1/4)!	25%  (3/12)!	40%  (3012/7446)!	25%  (3/12)!	com.sun.tools.javac.v8.resources
94%  (16/17)!	49%  (41/83)!	48%  (1111/2292)!	45%  (201.1/450)!	com.sun.tools.javac.v8
88%  (45/51)!	61%  (242/397)!	54%  (3070/5729)!	52%  (809.6/1563)!	com.sun.tools.javac.v8.tree
83%  (19/23)!	60%  (134/224)!	54%  (2746/5063)!	56%  (580.1/1041)!	com.sun.tools.javac.v8.util
100% (1/1)	40%  (2/5)!	58%  (25/43)!	49%  (5.9/12)!	com.sun.tools.javac
77%  (33/43)!	59%  (310/529)!	60%  (10584/17674)!	61%  (2077.2/3396)!	com.sun.tools.javac.v8.code
91%  (39/43)!	75%  (521/698)	66%  (19701/29863)!	70%  (3606.9/5138)!	com.sun.tools.javac.v8.comp
100% (3/3)	81%  (92/113)	70%  (4748/6736)!	70%  (1062.4/1523)!	com.sun.tools.javac.v8.parser
-------------------------------------------------------------------------------

The matcher above captures the following line only:

85%  (157/185)!	65%  (1345/2061)!	60%  (44997/74846)!	64%  (8346.3/13135)!	all classes