Giriş
jacoco:check diye yeni bir goal tanımlanır. check aşamasında belirtilen kapsama yüzdeleri tutmuyorsa build fail eder. chck için rule tanımlanır. Açıklaması şöyle
The rule is given in the rule tag. You have the flexibility to specify more than one rule.Element tag: This tag specifies the element on which the rule has to be applied.Limit tag: Tags like counter, value, minimum, etc., are used to limit the code coverage percentage. A command like mvn clean verify can be used for ensuring whether the rule is followed or not.
Counter olarak şunlar kullanılabilir
CLASS
LINE
PACKAGE
INSTRUCTION
Örnek - LINE
Şöyle yaparız %90 Line Coverage ister
<execution> <id>jacoco-check</id> <goals> <goal>check</goal> </goals> <configuration> ... <rules> <rule> <element>PACKAGE</element> <limits> <limit> <counter>LINE</counter> <value>COVEREDRATIO</value> <minimum>0.9</minimum> </limit> </limits> </rule> </rules> </configuration> </execution>
Örnek - LINE
Şöyle yaparız. %50 Line Coverage ister
<plugin> ... <executions> ... <execution> <id>jacoco-check</id> <goals> <goal>check</goal> </goals> <configuration> <rules> <rule> <element>PACKAGE</element> <limits> <limit> <counter>LINE</counter> <value>COVEREDRATIO</value> <minimum>0.50</minimum> </limit> </limits> </rule> </rules> </configuration> </execution> </executions> </plugin>
Örnek - INSTRUCTION, CLASS, LINE, BRANCH, METHOD
Şöyle yaparız.
<execution><id>check</id><goals><goal>check</goal></goals><configuration><rules><rule><element>BUNDLE</element><limits><limit><counter>INSTRUCTION</counter><value>COVEREDRATIO</value><minimum>${coverage.instruction.threshold}</minimum></limit><limit><counter>CLASS</counter><value>COVEREDRATIO</value><minimum>${coverage.class.threshold}</minimum></limit><limit><counter>LINE</counter><value>COVEREDRATIO</value><minimum>${coverage.line.threshold}</minimum></limit><limit>...
Hiç yorum yok:
Yorum Gönder