ASSERT-KTH / ASSERT-KTH/flacoco

Include `while (true)` lines in coverage

Open
#67 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
38
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Right now, `flacoco` does not consider `while` loop conditions that have a constant value `true` in the coverage computation.

Example:
```java
package fr.spoonlabs.FLtest1;

public class Calculator {

public Calculator() {
}

public int calculate(String op, int op1, int op2) {

while(true) {
if (op.equals("+")) {
return op1 + op2;
} else if (op.equals("-")) {
return op1 - op2;
} else if (op.equals("*")) {
return op1 / op2;//buggy
} else if (op.equals("/")) {
return op1 / op2;
} else if (op.equals("%")) {
return op1 % op2;
}
throw new UnsupportedOperationException(op);
}

}
}
```

Output:

```
fr/spoonlabs/FLtest1/Calculator@-@16,1.0
fr/spoonlabs/FLtest1/Calculator@-@15,0.7071067811865475
fr/spoonlabs/FLtest1/Calculator@-@13,0.5773502691896258
fr/spoonlabs/FLtest1/Calculator@-@11,0.5
fr/spoonlabs/FLtest1/Calculator@-@12,0.0
fr/spoonlabs/FLtest1/Calculator@-@14,0.0
fr/spoonlabs/FLtest1/Calculator@-@17,0.0
fr/spoonlabs/FLtest1/Calculator@-@18,0.0
```

`while(true) {` is on line 10.

Another example where this happens is https://github.com/SpoonLabs/astor/tree/master/examples/quixbugscompiled/detect_cycle

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing flacoco's coverage-computation path for Java while conditions and reproduce the example with the while(true) statement on line 10. Compare the reported coverage with the expected inclusion of that line, then add a regression test for the constant-true loop and verify the coverage output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.