We welcome and encourage contributions to the LogDispatch project! To maintain the quality and reliability of the SDK, we strictly adhere to automation testing best practices.
If you are adding new features, fixing bugs, or refactoring code, please ensure your tests comply with the following guidelines.
Before opening a Pull Request, always verify that your changes haven't broken existing functionality. You can execute the entire test suite locally using the Maven Wrapper:
./mvnw testDo not create or add to large, monolithic test classes. Each test file should focus on testing a specific responsibility (Single Responsibility Principle). If you are adding a completely new behavior, create a new, appropriately named test file.
When writing tests related to the LogDispatchFilter, extend the abstract LogDispatchFilterBaseTest.java class.
This base class contains:
- Shared constants (API keys, URLs).
- Pre-configured mocks (e.g.,
RestTemplate). - Helper methods for creating dummy
HttpServletRequestandFilterChainobjects. - Utility methods for capturing and verifying the dispatched JSON payload.
Reusing these utilities keeps the test suite DRY (Don't Repeat Yourself).
- Classes: Test classes must end in
*Test.java(e.g.,LogDispatchFilterHeaderMaskingTest.java). Themaven-surefire-pluginis configured to automatically detect and execute these classes. - Methods: Test methods should be descriptively named (e.g.,
shouldMaskConfiguredHeaderInApmPayload). - Display Names: Always decorate your test classes and methods with the JUnit 5
@DisplayNameannotation to provide clean, human-readable output in the test logs.
Any tests verifying the AOP interception logic (which intercepts @RestController exceptions and reads @LogDispatch annotations) should be placed inside LogDispatchAspectTest.java or in similarly named isolated files.
Thank you for helping us keep LogDispatch robust!