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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/34e27aaf-3886-4936-b5be-34392176088a%40googlegroups.com.