Skip to content
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

Introduce JUnitNullaryParameterizedTestDeclaration check #817

Merged
merged 3 commits into from
Oct 23, 2023

Conversation

Venorcis
Copy link
Contributor

@Venorcis Venorcis commented Oct 6, 2023

Flag uses of @ParameterizedTest on methods that don't have any parameters.

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Looks good. All 4 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.JUnitParameterizedMethodDeclaration 0 4

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@github-actions
Copy link

github-actions bot commented Oct 6, 2023

Looks good. All 4 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.JUnitParameterizedMethodDeclaration 0 4

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and added a commit; the check now also suggests a fix. Nice idea for a check @Venorcis!

Suggested commit message:

Introduce `JUnitNullaryParameterizedTestDeclaration` check (#817)

While there, slightly simplify the `AutowiredConstructor` check.

@Stephan202 Stephan202 added this to the 0.15.0 milestone Oct 10, 2023
@github-actions
Copy link

Looks good. All 14 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.AutowiredConstructor 0 2
🎉tech.picnic.errorprone.bugpatterns.JUnitNullaryParameterizedTestDeclaration 0 12

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Venorcis
Copy link
Contributor Author

Rebased and added a commit; the check now also suggests a fix. Nice idea for a check @Venorcis!

Thanks @Stephan202, all LGTM! 🎉

Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes LGTM! Nice idea for a check 🚀 !

*/
@AutoService(BugChecker.class)
@BugPattern(
summary = "Nullary JUnit test methods need not be parameterized",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a personal thingy, but I do not really like "need not be" phrase. Maybe we can change to "should not".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's you ;)

But will add a commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 haha nice. Will merge once 🟢 !

private static final long serialVersionUID = 1L;
private static final MultiMatcher<MethodTree, AnnotationTree> IS_PARAMETERIZED_TEST =
annotations(AT_LEAST_ONE, isType("org.junit.jupiter.params.ParameterizedTest"));
private static final Matcher<AnnotationTree> IS_ARGUMENT_SOURCE =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes me think of the MoreJUnitMatchers#HAS_METHOD_SOURCE (link) but this usage is slightly different is fine as-is and we don't need to consider any changes right now. Anyway, wanted to highlight it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, fine to move such things only when a second use case comes up 👍

Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and added a commit. @rickie feel free to merge once built.

private static final long serialVersionUID = 1L;
private static final MultiMatcher<MethodTree, AnnotationTree> IS_PARAMETERIZED_TEST =
annotations(AT_LEAST_ONE, isType("org.junit.jupiter.params.ParameterizedTest"));
private static final Matcher<AnnotationTree> IS_ARGUMENT_SOURCE =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, fine to move such things only when a second use case comes up 👍

*/
@AutoService(BugChecker.class)
@BugPattern(
summary = "Nullary JUnit test methods need not be parameterized",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's you ;)

But will add a commit.

@github-actions
Copy link

Looks good. All 14 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.AutowiredConstructor 0 2
🎉tech.picnic.errorprone.bugpatterns.JUnitNullaryParameterizedTestDeclaration 0 12

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie force-pushed the vkoeman/junit-parameterized branch from 71bd150 to 29d70a7 Compare October 23, 2023 07:09
@sonarcloud
Copy link

sonarcloud bot commented Oct 23, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@github-actions
Copy link

Looks good. All 14 mutations in this change were killed.

class surviving killed
🎉tech.picnic.errorprone.bugpatterns.AutowiredConstructor 0 2
🎉tech.picnic.errorprone.bugpatterns.JUnitNullaryParameterizedTestDeclaration 0 12

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie merged commit c3b950f into master Oct 23, 2023
17 checks passed
@rickie rickie deleted the vkoeman/junit-parameterized branch October 23, 2023 07:22
@Stephan202 Stephan202 changed the title Introduce JUnitParameterizedMethodDeclaration bug checker Introduce JUnitNullaryParameterizedTestDeclaration check Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants