Skip to content

Introduce Checkstyle rules to prevent improper use of JUnit APIs in production code #22962

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

Closed
5 tasks done
sbrannen opened this issue May 13, 2019 · 1 comment
Closed
5 tasks done
Assignees
Labels
in: test Issues in the test module type: task A general task
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented May 13, 2019

Overview

This issue is a follow up to #22932.

The challenge is to define Checkstyle rules that prevent the use of types such as org.junit.Assert and org.junit.Assume in src/main/java while simultaneously allowing their use in src/test/java.

In addition, the rules cannot be too restrictive since spring-test actually depends on various JUnit APIs.

If we implement such rules, the implementation may require the introduction of a special checkstyle.xml file that is only applied to src/main. Furthermore, we likely should only apply these special rules to spring-test.

In addition, we may want to ensure that we do not accidentally use improper APIs from JUnit Jupiter and TestNG -- for example, their assertion libraries -- in src/main for spring-test.

Deliverables

Introduce Checkstyle rules to prevent improper use of testing/assertion APIs (except where needed in spring-test).

  • JUnit 3: junit.framework.* (src/main and src/test)
  • JUnit 4: org.junit.* (src/main and src/test)
  • JUnit Jupiter:org.junit.jupiter.api.Assertions and org.junit.jupiter.api.Assumptions (src/main and src/test)
  • TestNG: org.testng.* (src/main and src/test)
  • Hamcrest: org.hamcrest.* (src/main and src/test)
@sbrannen sbrannen added in: test Issues in the test module type: task A general task labels May 13, 2019
@sbrannen sbrannen added this to the 5.2 M3 milestone May 13, 2019
@jhoeller jhoeller modified the milestones: 5.2 M3, 5.2 RC1 Jun 11, 2019
@snicoll snicoll modified the milestones: 5.2 RC1, 5.2 RC2 Aug 2, 2019
@snicoll snicoll modified the milestones: 5.2 RC2, 5.2 GA Sep 5, 2019
@sbrannen
Copy link
Member Author

sbrannen commented Sep 5, 2019

It appears that a lot of this work has already been achieved by piecemeal inclusion of various Checkstyle rules over the course of the past month or so.

@philwebb In light of that, I'll assign this to myself to investigate further.

@sbrannen sbrannen assigned sbrannen and unassigned philwebb Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: task A general task
Projects
None yet
Development

No branches or pull requests

4 participants