Skip to content

[Issue-3396] Support runOrder=balanced with forkCount>1#3397

Open
joshiste wants to merge 1 commit into
apache:masterfrom
joshiste:feature/3396-balanced-forkcount
Open

[Issue-3396] Support runOrder=balanced with forkCount>1#3397
joshiste wants to merge 1 commit into
apache:masterfrom
joshiste:feature/3396-balanced-forkcount

Conversation

@joshiste

@joshiste joshiste commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #3396

What

runOrder=balanced used only threadCount to sort the test classes. With forkCount>1 and no parallel=classes, threadCount is 1. So balanced only put the slowest classes first and did not use the number of forks.

This change makes balanced use forkCount × threadCount as the number of parallel test runners. Now balanced also helps when you use forkCount>1 without parallel=classes.

How

  • New forkcount provider property (ProviderParameterNames.FORKCOUNT_PROP). The mojo sends it to the provider, the same way as the existing threadcount.
  • BaseProviderFactory.getRunOrderCalculator() now uses threadCount × forkCount. getForkCount() uses the same default and clamp as getThreadCount().
  • Renamed the field threadCount to distributedParallelism in DefaultRunOrderCalculator, because it now means threads and forks together.
  • Updated the docs in SurefireMojo and IntegrationTestMojo. Removed the old note that said "only relevant with parallel=classes".

Tests

  • Unit test BaseProviderFactoryTest: checks the width is threadCount × forkCount, plus the default and the clamp cases.
  • IT RunOrderIT (and RunOrderParallelForksIT): run balanced with forkCount>1 (both reuse modes) and with forkCount=0.

  • Each commit has a clear subject line and body.
  • The description explains what the change does, how, and why.
  • Ran mvn clean install on the changed modules. Basic checks pass.
  • Ran the related integration tests (RunOrderIT, RunOrderParallelForksIT) with -Prun-its. They pass.
  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004.

Balanced run order sized its class distribution only by the parallel
threadCount, so with forkCount>1 and no parallel=classes it degraded to a
plain slowest-first list and ignored the number of forks consuming tests.

Size the distribution by the real concurrency, forkCount * threadCount, by
propagating forkCount to the provider via a new forkcount provider property
(mirroring threadcount) and using the product as the bin-packing width. The
calculator field is renamed to distributedParallelism to reflect the wider
meaning. This makes balanced effective with forkCount>1 even without
parallel=classes.
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.

Support runOrder=balanced with forkCount>1 (without parallel=classes)

1 participant