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
Issue #12326: Resolve Pitest suppression for AccessModifierOption #12340
Conversation
Github, generate report |
We do not allow pure Junit test methods anymore. |
ok @romani |
@shubh220922 please hardcode mutation first and try to understand why this mutation survives our tests. |
@nrmancuso okay going through this. |
@shubh220922 also, please keep hack like 4f9c2a4 in mind to kill mutation (using config input to kill mutation) |
@nrmancuso Should I write input files for the tests previously present in the file as well or only for mine. |
@shubh220922 please do not modify existing test inputs, also make sure to read through #12341 |
I'll work on this pr within the next 3 days. My exams are going on. |
@nrmancuso I've been trying to understand the meaning of |
@shubh220922 please read pitest documentation for this mutation operator; share specific points you need clarification on https://pitest.org/quickstart/mutators/#EXPERIMENTAL_NAKED_RECEIVER Edit: I see you edited your comment, see our wiki at https://github.com/checkstyle/checkstyle/wiki/How-to-Generate-and-Analyze-Pitest-Reports#experimental-naked-receiver for code example |
5d1fea9
to
973fc77
Compare
I have hardcoded the mutation in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item:
@@ -63,7 +63,7 @@ private String getName() { | |||
* @return the AccessModifier associated with given access modifier name. | |||
*/ | |||
public static AccessModifierOption getInstance(String modifierName) { | |||
return valueOf(AccessModifierOption.class, modifierName.trim().toUpperCase(Locale.ENGLISH)); | |||
return valueOf(AccessModifierOption.class, modifierName.toUpperCase(Locale.ENGLISH)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
973fc77
to
4b685bb
Compare
Now in order to find what violation I will get at respective lines, I will have to check through running the config but the following is being displayed:
It is giving me this error @nrmancuso. |
@shubh220922 you must use a check that uses AccessModifierOption Example: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMethod |
4b685bb
to
856dca1
Compare
@nrmancuso i have made some changes.. Thanks to your link given at #12340 (comment). But I am getting this error when I am running the test that I have made: EDIT1: It is not able to find the messages bundle for some reason. What have I missed @nrmancuso. |
@shubh220922 please only create a new test and input in JavadocMethodCheckTest, with tab character added to access modifier property value. You only need a very simple input, the idea is that we need check to read the property in only. Make sure that |
c7b0c4c
to
9ebf025
Compare
Mutation didn't get killed. What am I missing @nrmancuso. Could you review my changes please @nrmancuso . |
@nrmancuso this is really quite suspicious. The current test case must resolve the mutation according to the config but it is not. I have created a test case in one of this check from naming package and mutation were killed. i am also curious to know why this is happening :), because according to the concept of mutation testing if we don't have strong enough test case for the code which we write so it will be mutated and in this currently updated pr this test is enough to kill this mutation bcs of trim func |
@shubh220922 this means that the string is getting trimmed before we reach this method ( |
@nrmancuso the following is what I got from debugging: I have started debugging from I specially tagged this The value of But in the Image2 Following the stack of execution the value of After crossing this line, the value of I am thinking where exactly is the problem coming from?! |
@shubh220922 ok, we have missed a nuance here.
|
We do all possible to avoid API package. |
@romani let's create issue to move AccessModifierOption, we can discuss final location in issue. It doesn't make sense to keep AccessModifierOption in naming if we use it elsewhere. |
9ebf025
to
af40a7a
Compare
@nrmancuso mvn passed successfully. Mutation killed. |
Q.1) Q.2) How did you figure this out in #12340 (comment) as I wasn't able to reach any conclusion through debugging. |
@shubh220922 test was right, but mutation was not killed. This means that we did not use this test to cover the mutation we are working on. We cannot put all tests on all packages, as pitest would take a very long time to run. I initially missed this since mutation class was suppressed in |
Please see if my interpretation of this is correct or not: Statement 1Due to certain config of pitest present in pom.xml that we have set, it only allows for killing those mutations for which the tests and inputs are written within the same package as the main java file containing mutation It is thereby not possible to write tests and inputs in a different package than the package that contains the file containing the mutation due to the config of pit in pom.xml Question 1.1Did we set this config of PIT in pom.xml? Or it is given by default by PIT? Question 2
Question 2.1Where is the suppression exactly? Question 2.2Which mutation class is being suppressed here? Question 2.3The suppression of the mentioned mutation class is suppressing what function here? |
@nrmancuso should i create issue to move |
See for yourself in the pom file.
This is what you have removed in this PR, read the suppression you've removed for all details. To be clear: most pitest mutation suppression files are named by package, like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Items:
src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java
Outdated
Show resolved
Hide resolved
...wl/tools/checkstyle/checks/naming/parametername/InputParameterNameAccessModifierChecker.java
Outdated
Show resolved
Hide resolved
af40a7a
to
cb0778e
Compare
Travis CI failing! Fixing it. |
Disregard this failure, this is in Travis side |
ParameterName | ||
format = ^h$ | ||
ignoreOverridden = (default)false | ||
accessModifiers = \tpublic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config like this: public\t,\t,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other PR, we had public, \t
, case taken from this PR is with tab character "on" the access modifier. The first trim in both methods took care of the single \t
, the second trim takes care of the \t
"on" the access modifier.
Referencing from #12326
also related to #12341