Skip to content

Conversation

mihirgune
Copy link
Contributor

Description

This Pull Request addresses test flakiness in the following test:

org.apache.maven.plugins.dependency.fromDependencies.TestCopyDependenciesMojo#testGetDependencies

Problem

The test performs a String equality check on the content of dependencies stored in mojo.resolvedDependencies against dependencies resolved through mojo.getDependencySets(true).getResolvedDependencies().

Since these dependencies are stored in java.util.Set collections, their ordering is non-deterministic, which occasionally causes test failures when executed with the Nondex plugin.

Solution

To address this, I modified the test to verify that the sets contain the same elements, regardless of order.

I've changed the assertion from:

assertEquals(
    mojo.getResolvedDependencies(true).toString(),
    mojo.getDependencySets(true).getResolvedDependencies().toString()
);

to

assertTrue(
    mojo.getResolvedDependencies(true).containsAll(
        mojo.getDependencySets(true).getResolvedDependencies()
    )
);

This ensures the test passes as long as both sets contain the same dependencies, regardless of order.

I'd appreciate any feedback on this approach and am open to making further adjustments if necessary.

@elharo elharo merged commit 74a956b into apache:master Nov 10, 2024
20 checks passed
@slawekjaranowski slawekjaranowski added this to the 3.9.0 milestone Sep 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants