# Sonar Lint Rule for Missing java Test class

**URL:** <https://community.sonarsource.com/t/sonar-lint-rule-for-missing-java-test-class/90635>\
**Category:** IntelliJ Platform\
**Tags:** java\
**Created:** [May 10, 2023, 8:51am UTC](https://community.sonarsource.com/t/sonar-lint-rule-for-missing-java-test-class/90635 "2023-05-10T08:51:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avinash\_Ch](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/avinash_ch/32/45014_2.png) [@Avinash\_Ch](https://community.sonarsource.com/u/Avinash_Ch)\
**Post date:** [May 10, 2023, 8:51am UTC](https://community.sonarsource.com/t/sonar-lint-rule-for-missing-java-test-class/90635/1 "2023-05-10T08:51:25Z")

</div>

Please provide

- Operating system: Windows 11
- SonarLint plugin version: 8.2.0.68615
- Programming language you’re coding in: Java
- Is connected mode used: No
  - Connected to SonarCloud or SonarQube (and which version):

And a thorough description of the problem / question:

We want to enable or enforce the developers to follow Test First Approach or Test Driven Development.

For this I am thinking of writing a Sonar custom rule which highlights the violation when a new Java class is written first and the corresponding Test.java is not yet present.

Could you please guide if there is already a Rule defined for this requirement. Or need to Write our own.

Thanks,  
Avinash

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [May 11, 2023, 7:32pm UTC](https://community.sonarsource.com/t/sonar-lint-rule-for-missing-java-test-class/90635/2 "2023-05-11T19:32:08Z")

</div>

Hi,

Welcome to the community!

You would need to write your own rule for this (feel free to post specific programming questions in the [Writing rules](https://community.sonarsource.com/c/sq/customrules/18) category). Further, you would need to use SonarQube to run the rule since we restrict what runs in SonarLint to the rules we offer - we’ve learned the hard way that it’s the only way we can ensure a good developer experience.

&nbsp;  
HTH,  
Ann
