Java: Renamed query java/mocking-all-non-private-methods-means-unit-test-is-too-big to java/excessive-public-method-mocking and changed wording from non-private to public

This commit is contained in:
Napalys Klicius
2025-08-26 08:20:56 +00:00
parent ff648fcb27
commit b271f1fcd0
12 changed files with 9 additions and 8 deletions

View File

@@ -36,8 +36,8 @@ ql/java/ql/src/Likely Bugs/Concurrency/NonSynchronizedOverride.ql
ql/java/ql/src/Likely Bugs/Concurrency/ScheduledThreadPoolExecutorZeroThread.ql
ql/java/ql/src/Likely Bugs/Concurrency/SynchOnBoxedType.ql
ql/java/ql/src/Likely Bugs/Concurrency/SynchSetUnsynchGet.ql
ql/java/ql/src/Likely Bugs/Frameworks/JUnit/ExcessivePublicMethodMocking.ql
ql/java/ql/src/Likely Bugs/Frameworks/JUnit/JUnit5MissingNestedAnnotation.ql
ql/java/ql/src/Likely Bugs/Frameworks/JUnit/MockingAllNonPrivateMethodsMeansUnitTestIsTooBig.ql
ql/java/ql/src/Likely Bugs/Inheritance/NoNonFinalInConstructor.ql
ql/java/ql/src/Likely Bugs/Likely Typos/ContainerSizeCmpZero.ql
ql/java/ql/src/Likely Bugs/Likely Typos/ContradictoryTypeChecks.ql

View File

@@ -34,8 +34,8 @@ ql/java/ql/src/Likely Bugs/Concurrency/NonSynchronizedOverride.ql
ql/java/ql/src/Likely Bugs/Concurrency/ScheduledThreadPoolExecutorZeroThread.ql
ql/java/ql/src/Likely Bugs/Concurrency/SynchOnBoxedType.ql
ql/java/ql/src/Likely Bugs/Concurrency/SynchSetUnsynchGet.ql
ql/java/ql/src/Likely Bugs/Frameworks/JUnit/ExcessivePublicMethodMocking.ql
ql/java/ql/src/Likely Bugs/Frameworks/JUnit/JUnit5MissingNestedAnnotation.ql
ql/java/ql/src/Likely Bugs/Frameworks/JUnit/MockingAllNonPrivateMethodsMeansUnitTestIsTooBig.ql
ql/java/ql/src/Likely Bugs/Inheritance/NoNonFinalInConstructor.ql
ql/java/ql/src/Likely Bugs/Likely Typos/ContainerSizeCmpZero.ql
ql/java/ql/src/Likely Bugs/Likely Typos/ContradictoryTypeChecks.ql

View File

@@ -1,6 +1,6 @@
## Overview
Mocking methods of a class is necessary for unit tests to run without overhead caused by expensive I/O operations. However, when a unit test ends up mocking all non-private methods of a class, it may indicate that the test is too complicated, possibly because it is trying to test multiple things at once. Such extensive mocking is likely a signal that the scope of the unit test is reaching beyond a single unit of functionality.
Mocking methods of a class is necessary for unit tests to run without overhead caused by expensive I/O operations. However, when a unit test ends up mocking all public methods of a class, it may indicate that the test is too complicated, possibly because it is trying to test multiple things at once. Such extensive mocking is likely a signal that the scope of the unit test is reaching beyond a single unit of functionality.
## Recommendation

View File

@@ -1,7 +1,8 @@
/**
* @id java/mocking-all-non-private-methods-means-unit-test-is-too-big
* @name Mocking all non-private methods of a class may indicate the unit test is testing too much
* @description Mocking all non-private methods provided by a class might indicate the unit test
* @id java/excessive-public-method-mocking
* @previous-id java/mocking-all-non-private-methods-means-unit-test-is-too-big
* @name Mocking all public methods of a class may indicate the unit test is testing too much
* @description Mocking all public methods provided by a class might indicate the unit test
* aims to test too many things.
* @kind problem
* @precision high

View File

@@ -0,0 +1,2 @@
query: Likely Bugs/Frameworks/JUnit/ExcessivePublicMethodMocking.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql

View File

@@ -1,2 +0,0 @@
query: Likely Bugs/Frameworks/JUnit/MockingAllNonPrivateMethodsMeansUnitTestIsTooBig.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql