1# Context 2 3`AdServicesLoggingUsageRule` has been introduced in `AdServicesExtendedMockitoTestCase` to make 4critical logging verification simpler (and required) with the first use case 5targeting `ErrorLogUtil`. 6 7For `AdServicesLoggingUsageRule` to scan `ErrorLogUtil` usage across all test subclasses, 8`ErrorLogUtil` is automatically spied and mocked appropriately to store actual invocation calls. The 9test author would only need to use annotations like `@ExpectErrorLogUtilCall` and/or 10`@ExpectErrorLogUtilWithExceptionCall` over test methods to verify logging and satisfy the rule. 11 12# Problem 13 14Test author may unknowingly silence the `AdServicesLoggingUsageRule` by mocking / 15spying `ErrorLogUtil` and overriding its behavior. 16 17We will need a linter that flags if `ErrorLogUtil` is getting mocked explicitly in tests. 18 19# Linter Strategy 20 21The linter detects and flags the following: 22 231. Usage of `@SpyStatic(ErrorLogUtil.class)` and `@MockStatic(ErrorLogUtil.class)` over classes and 24 methods. These annotations are most commonly used for static mocking / spying 25 in `AdServicesExtendedMockitoTestCase` subclasses. 262. Usage of `doNothingOnErrorLogUtilError()` in `AdServicesExtendedMockitoTestCase` subclasses. 273. Usage of `when(..)` with `ErrorLogUtil` as part of its parameter 28 in `AdServicesExtendedMockitoTestCase` subclasses. 29