fix flaky tests under DubboAppenderTest #14900
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change?
Two tests under module dubbo-common are detected as Order-Dependent flaky tests:
org.apache.dubbo.common.utils.DubboAppenderTest.testAvailable
org.apache.dubbo.common.utils.DubboAppenderTest.testAppend
In this PR, I modified the test setup to ensure that each unit test starts with an independent state by resetting the DubboAppender in the @beforeeach method. Currently, all tests rely on the tearDown() method annotated with @AfterEach to clear the state. However, in unit testing, it is essential for each test to be independent and not depend on the state left by previous tests. If a test fails in a way that prevents tearDown() from running (e.g., due to an unexpected exception or forced termination), it can result in residual state in logList, causing dependencies between tests and breaking test isolation.
Additionally, I replaced assumeTrue() and assumeFalse() with assertThat() to ensure that tests fail with clear feedback when conditions are not met, rather than being skipped. Using assertions is better to report failures directly, rather than directly skipping a test when a condition is not met.
Checklist