There is no such example. Cyclomatic complexity coverage is derived from branch 
coverage.

Cyclomatic complexity coverage is something I invented for JaCoCo. I don’t 
think there is a official definition for it. Here are the definitions for 
JaCoCo:

https://www.jacoco.org/jacoco/trunk/doc/counters.html 
<https://www.jacoco.org/jacoco/trunk/doc/counters.html>

Regards,
-marc


> On 4. Oct 2019, at 12:29, [email protected] wrote:
> 
> Hi Marc,
> 
> Thank you for your quick answer and for helping me to understand it. Do you 
> have a small example when the branch coverage would pass but the cyclomatic 
> complexity would fail?
> 
> Thank you,
> Csaba
> 
> On Friday, 4 October 2019 07:25:13 UTC+1, Marc R. Hoffmann wrote:
> Hi,
> 
> cyclomatic complexity is calculated based on branches. In your case the 
> cyclomativ complexity is 3 and your two test cases cover all branches.
> 
> Path coverage is a different metric which is not supported by JaCoCo.
> 
> Best regards,
> -marc
> 
> 
>> On 3. Oct 2019, at 18:52, [email protected] <javascript:> wrote:
>> 
>> * "So I had the assumption that the coverage report should fail, as I didn't 
>> test (call) the method with a number which is 1 < n < 10, but to my surprise 
>> the coverage passed."
>> 
>> On Thursday, 3 October 2019 17:49:58 UTC+1, [email protected] 
>> <http://gmail.com/> wrote:
>> Hi,
>> 
>> I have a question connected to Cyclomatic Complexity. According the 
>> documentation the "Cyclomatic Complexity is the minimum number of paths that 
>> can, in (linear) combination, generate all possible paths through a method". 
>> There is also a calculation for it v(G) = B - D + 1, but was not sure in my 
>> case.
>> 
>> I have simple method what I want to test:
>> 
>> public int increase(int i) {
>>     if (i > 1) {
>>         i = i+ 1;
>>     }
>>     if (i > 10) {
>>         i = i+ 1;
>>     }
>>     return i;
>> }
>> 
>> And my test is very simple, I don't do any assertions, just call it with two 
>> different numbers:
>> 
>> @Test
>> void test() {
>>     increase(100);
>>     increase(-10);
>> }
>> 
>> I used the following coverage limit:
>> <limit>
>>     <counter>COMPLEXITY</counter>
>>     <value>COVEREDRATIO</value>
>>     <minimum>1.00</minimum>
>> </limit>
>> 
>> So I had the assumption that the coverage report should fail, as I didn't 
>> test (call) the method with a number which is 1 < n < 10, but to my surprise 
>> the coverage failed.
>> 
>> Do you know why it is passed in my case?
>> 
>> My simplified pom.xml file just in case:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <project xmlns="http://maven.apache.org/POM/4.0.0 
>> <http://maven.apache.org/POM/4.0.0>"
>>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance 
>> <http://www.w3.org/2001/XMLSchema-instance>"
>>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
>> <http://maven.apache.org/POM/4.0.0> 
>> http://maven.apache.org/xsd/maven-4.0.0.xsd 
>> <http://maven.apache.org/xsd/maven-4.0.0.xsd>">
>>     <modelVersion>4.0.0</modelVersion>
>> 
>>     <groupId>com.kanbagoly</groupId>
>>     <artifactId>something</artifactId>
>>     <version>1.0-SNAPSHOT</version>
>> 
>>     <properties>
>>         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>         <maven.compiler.source>1.8</maven.compiler.source>
>>         <maven.compiler.target>1.8</maven.compiler.target>
>>         <junit.jupiter.version>5.5.2</junit.jupiter.version>
>>     </properties>
>> 
>>     <dependencies>
>>         <dependency>
>>             <groupId>org.junit.jupiter</groupId>
>>             <artifactId>junit-jupiter</artifactId>
>>             <version>${junit.jupiter.version}</version>
>>             <scope>test</scope>
>>         </dependency>
>>     </dependencies>
>> 
>>     <build>
>>         <plugins>
>>             <plugin>
>>                 <artifactId>maven-compiler-plugin</artifactId>
>>                 <version>3.7.0</version>
>>             </plugin>
>>             <plugin>
>>                 <artifactId>maven-surefire-plugin</artifactId>
>>                 <version>2.22.2</version>
>>             </plugin>
>>             <plugin>
>>                 <groupId>org.jacoco</groupId>
>>                 <artifactId>jacoco-maven-plugin</artifactId>
>>                 <version>0.8.4</version>
>>                 <executions>
>>                     <execution>
>>                         <id>prepare-agent</id>
>>                         <goals>
>>                             <goal>prepare-agent</goal>
>>                         </goals>
>>                     </execution>
>>                     <execution>
>>                         <id>report</id>
>>                         <phase>prepare-package</phase>
>>                         <goals>
>>                             <goal>report</goal>
>>                         </goals>
>>                     </execution>
>>                     <execution>
>>                         <id>check</id>
>>                         <goals>
>>                             <goal>check</goal>
>>                         </goals>
>>                         <configuration>
>>                             <rules>
>>                                 <rule>
>>                                     <element>BUNDLE</element>
>>                                     <limits>
>>                                         <limit>
>>                                             <counter>COMPLEXITY</counter>
>>                                             <value>COVEREDRATIO</value>
>>                                             <minimum>1.00</minimum>
>>                                         </limit>
>>                                     </limits>
>>                                 </rule>
>>                             </rules>
>>                         </configuration>
>>                     </execution>
>>                 </executions>
>>             </plugin>
>> 
>>         </plugins>
>>     </build>
>> 
>> </project>
>> 
>> 
>> 
>> 
>> Thank you for your answer in advance,
>> Csaba Kerti
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/853c87a6-4dcb-469c-8a93-3fa153cd9c7b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/853c87a6-4dcb-469c-8a93-3fa153cd9c7b%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/39d3be91-cec1-4b46-8f42-d043779201bc%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/39d3be91-cec1-4b46-8f42-d043779201bc%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/C9D5933A-8EA0-4FF9-AD21-13DAFA9E2D9A%40mountainminds.com.

Reply via email to