Fixed Order Dependent Flakiness in testValidFlowNamespaceWithAllValidCharsTypes #1464
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.
Fixes #1463
Motivation
SlangBuilderTest.testValidFlowNamespaceWithAllValidCharsTypesfails when executed on it's own because it is an Order-Dependent test that requiresSlangBuilderTest.testValidFlowNamespaceCaseInsensitiveto mock and set the behavior of metadataExtractor.extractMetadataModellingResult() to return EMPTY_METADATA beforehand. As a result, the test can fail due to external factors not setting up it's state correctly, despite the test and the code that it is testing remaining unchanged. Order dependent flaky tests can lead to unreliable results from CI and can erode developer trust in the test suite.Modifications
A few lines were introduced at the beginning of
SlangBuilderTest.testValidFlowNamespaceWithAllValidCharsTypesto mock and set the required behavior ofmetadataExtractor.extractMetadataModellingResult()to returnEMPTY_METADATA. Previously, the test would only pass if another test had configured this mock beforehand. The mock configuration persists between tests because the tests use Autowired Spring beans which are shared across tests, and the Before method does not reset the metadataExtractor mock.As a result,
testValidFlowNamespaceWithAllValidCharsTypesis now self-contained and no longer depends on execution order, as it properly initializes its own required mock state.Affected Tests
This change affects the existing tests:
Tools Used
iDFlakies was utilized to identify the order dependent polluter(s), victim(s), and cleaner(s) in the test suite(s). The tool functions by repeatedly running a project's JUnit tests under many different deterministic test orders to detect flaky tests which pass and fail inconsistently, and then re-executes the failing orders to classify each flaky test as either order-dependent or non-order-dependent. iFixFlakies was executed on the output to further diagnose the source of the problems and additionally generate test helper patches from existing cleaners that were found. With the combination of these tools, I was able to more easily diagnose the source(s) of the problem(s) and create effective solution(s) for them.