New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve Pitest Issues - ImportOrderCheck (6) #7877
Comments
I am on it. |
I ran
to generate diff report, but I'm getting this error -
I checked my command again and it seems to be correct, any help would be appreciated. |
@bossever you can try to debug diff.groovy file to check what is wrong with arguments. |
@bossever remove the space from your config file's path. It is a good practice not to have spaces in filenames and file paths. |
Thanks, that made it work. |
Pitest Report:Surviving mutation on line 878:
Hardcoded mutation is here. Diff Report: https://bossever.github.io/issue7877/diff-report/index.htmlConfig used for diff report: https://gist.github.com/bossever/9af6e0f85a4fdabaedebf3863349fc9f |
I have mostly understood how pitest works and what it is meant for, but I am having some trouble understanding how diff regression works. From what I can gather, it runs checkstyle on various projects from two branches (the baseBranch and the patchBranch) and tries to find differences between the output of the two. |
You are correct |
I am somehwat confused about the usage of variable checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java Lines 877 to 879 in 9c53648
The Javadoc description for it is - checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java Lines 601 to 602 in 9c53648
This would imply that it is true whenever there were any imports at all. However, the variable name seems to mean something else - before First Import I tried to understand the variable by looking at its usage, but I couldn't get it, any help would be appreciated. After understanding it, I think I could come up with a test case where the mutation can be killed. |
Like the variable says, it defines whether we are at or before the first import. The variable is true when we begin any new AST tree and only becomes false after we complete our first visit and examine an import statement. |
Thanks, that made it clear! |
After a lot of thought, I believe that this particular mutation cannot be killed. I have explained why below. checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java Lines 877 to 879 in 9c53648
When return line - lastImportLine > 1; I could create a UT in two ways - Case 1:
import java.util.HashMap;
// Unnecessary separator
import java.util.LinkedList;
public class Test {} Expected violation: For this, I would need the method Case 2:
import java.util.HashMap;
import java.util.LinkedList;
public class Test {} Expected violation: This would require Conclusion:I think |
I do not see this import in your example. |
Ah, looks like I forgot to change the violation message appropriately, will change now. |
@bossever it looks like a lot of refactoring around this method happened at 9e24cf1 , and checking Edit: please generate a new diff report in your PR, and add one more config with both |
@nmancus1 If I remove |
No, this is what pitest is telling you; no existing test inputs are hitting this code such that mutating To convince yourself, run Edit: I misread your comment, ignore the following:
|
Is it so that removal of the condition is the only other option? If so, I will create the PR immediately. |
You have two options, as stated above:
In order to find test cases, we usually look to the regression report (which is clean in this case, so no help there) or think of some way to hit the code otherwise (with real input, not reflection, etc. in this case). It is good to think about it logically; is there ever a case where the result of this method does not solely depend on |
Hmm okay, I don't think I can come up with a test case that can kill the mutation, so I will remove this condition now. |
fix is merged |
Child issue of #7797 ,
checkstyle/.ci/pitest.sh
Line 91 in abf829f
The text was updated successfully, but these errors were encountered: