Closed h1alexbel closed 2 months ago
@volodya-lombrozo updated, take a look, please
@volodya-lombrozo I also researched the subject of detecting mockery and other similar patterns and found a few papers where researchers studied mock practices in the unit tests:
At the moment I didn't found any practical tool that checks or alerts excessive mocking/stubbing.
@rultor merge
@volodya-lombrozo I also researched the subject of detecting mockery and other similar patterns and found a few papers where researchers studied mock practices in the unit tests:
- MockSniffer: Characterizing and Recommending Mocking Decisions for Unit Tests
- To Mock or Not to Mock? An Empirical Study on Mocking Practices
- An empirical study on the usage of mocking frameworks in Apache software foundation
At the moment I didn't found any practical tool that checks or alerts excessive mocking/stubbing.
Good! Then we will be the first one.
In this pull request I've introduced new rule
RuleTestCaseContainsMockery
for mockery detection with Mockito mocking framework.@volodya-lombrozo take a look, please closes #393
PR-Codex overview
This PR introduces a new rule to limit the number of mocks in test cases. It also adds support for JavaParser and updates dependencies.
Detailed summary
maxNumberOfMocks
parameter inRuleCorrectTestCase
andCop
classesJavaParserTestCase
to includestatements()
methodmaxNumberOfMocks
field inRuleCorrectTestCases
classValidateMojo
to supportmaxNumberOfMocks
Cop
class to acceptmaxNumberOfMocks
MockeryTest
andMockery.java
for testing mocks