Skip to content

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.

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