Search code examples
junitpmd

PMD rules needs to be applied Junit files also?


very curious to know whether PMD rules(other than PMD JUnit ruleset) needs to be applied for the Junit Java Test files also. Since these test files never going to be executed in production, how much it is necessary to have PMD rules complaint for Junit files.

Please share your thoughts.


Solution

  • This question is more a definition of what the software architect / technical lead wants.

    We have a common rule, what the quality of the tests have to be in the same quality as the code for production. But why?

    Since the test code is ensuring the quality of the production code, it has to have the same maintainability as the production code. Means if you do not focus to have some common rules on the tests, the tests will get worse and worse over the time.

    We separate between:

    • User acceptance tests (automated)
    • integration tests (automated)
    • and unit tests (automated)

    from top to down we are releasing the rules chains to the developers. UA-Tests are crucial, so identical to any production code. Unit tests are nice and needed, but we will survive if we loose some of them.