Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix flaky tests under DubboAppenderTest #14900

Merged
merged 4 commits into from
Nov 20, 2024
Merged

Conversation

ljmcr
Copy link
Contributor

@ljmcr ljmcr commented Nov 17, 2024

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

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

@wcy666103
Copy link
Contributor

use mvn spotless:apply to format the code.

@AlbumenJ AlbumenJ merged commit 36b69f1 into apache:3.3 Nov 20, 2024
12 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants