Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Configure parallel tests with Java (Maven)

Focus mode
Configure parallel tests with Java (Maven) - AWS CodeBuild

The following is sample of a buildspec.yml that shows parallel test execution with Java on an Linux platform:

version: 0.2 batch: fast-fail: false build-fanout: parallelism: 5 ignore-failure: false phases: pre_build: commands: - echo 'prebuild' build: commands: - echo "Running mvn test" - | codebuild-tests-run \ --test-command 'mvn test -Dtest=$(echo "$CODEBUILD_CURRENT_SHARD_FILES" | sed "s|src/test/java/||g; s/\.java//g; s|/|.|g; s/ /,/g" | tr "\n" "," | sed "s/,$//")' \ --files-search "codebuild-glob-search '**/test/**/*.java'" post_build: commands: - echo "Running post-build steps..." - echo "Test execution completed"

In the given example, the environment variable CODEBUILD_CURRENT_SHARD_FILES contains test files in the current shard, separated by newlines. These files are converted into a comma-separated list of class names in the format accepted by the -Dtest parameter for Maven.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.