Skip to content

New CheckstyleTestMakeupCheck #610

@rnveach

Description

@rnveach

Identified at checkstyle/regression-tool#85 (comment) ,

We need a new check to bring uniformity to our UTs in Checkstyle.
There are so many ways to write a test that some conflict with our custom check in regression to read these checks easily.

  1. Some properties are defined with variables:
    https://github.com/checkstyle/checkstyle/blob/master/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java#L66
  2. Some check configurations are defined as a class field and some are defined as local variables:
    https://github.com/checkstyle/checkstyle/blob/master/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java#L43

I am currently naming the check CheckstyleTestMakeupCheck and started a preview of the check at https://github.com/rnveach/checkstyle/commits/regression_util.

We should make a check that only examines methods defined with @Test and have a verify method call.
The method must have a local variable defining a DefaultConfiguration and assigning it with either createModuleConfig(...) or one of our other standard configuration creation methods.
If it calls addAttribute on the DefaultConfiguration the property name must be a string, and the property value must either be: a String, a concatentation of 2 or more strings, a enumeration toString in the form XXX.YYY.toString(), getPath(String), or the literal null (which is technically not supported in the configuration file).

@romani Please review and approve.
Let me know if you can think of anything else to verify.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions