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.”

Execute parallel tests in batch builds

Focus mode
Execute parallel tests in batch builds - AWS CodeBuild

You can use AWS CodeBuild to execute parallel tests in batch builds. Parallel test execution is a testing approach where multiple test cases run simultaneously across different environments, machines, or browsers, rather than executing sequentially. This approach can significantly reduce overall test execution time and improve testing efficiency. In CodeBuild, you can split your tests across multiple environments and run them concurrently.

The key advantages of parallel test execution include:

  1. Reduced execution time - Tests that would take hours sequentially can complete in minutes.

  2. Better resource utilization - Makes efficient use of available computing resources.

  3. Earlier feedback - Faster test completion means quicker feedback to developers.

  4. Cost-effective - Saves both time and computing costs in the long run.

When implementing parallel test execution, two main approaches are commonly considered: separate environments and multithreading. While both methods aim to achieve concurrent test execution, they differ significantly in their implementation and effectiveness. Separate environments create isolated instances where each test suite runs independently, while multithreading executes multiple tests simultaneously within the same process space using different threads.

The key advantages of separate environments over multithreading include:

  1. Isolation - Each test runs in a completely isolated environment, preventing interference between tests.

  2. Resource conflicts - No competition for shared resources that often occurs in multithreading.

  3. Stability - Less prone to race conditions and synchronization issues.

  4. Easier debugging - When tests fail, it's simpler to identify the cause as each environment is independent.

  5. State management - Easily manage shared state issues that plague multithreaded tests.

  6. Better scalability - Can easily add more environments without complexity.

Support in AWS CodeBuild

AWS CodeBuild provides robust support for parallel test execution through its batch build feature, specifically designed to leverage separate environment execution. This implementation aligns perfectly with the benefits of isolated testing environments.

Batch build with test distribution

CodeBuild's batch build functionality enables the creation of multiple build environments that run simultaneously. Each environment operates as a completely isolated unit, with its own compute resources, runtime environment, and dependencies. Through the batch build configuration, you can specify how many parallel environments they need and how tests should be distributed across them.

Test sharding CLI

CodeBuild includes a built-in test distribution mechanism through its CLI tool, codebuild-tests-run, which automatically divides tests into different environments.

Report aggregation

One of the key strengths of CodeBuild's implementation is its ability to handle test result aggregation seamlessly. While tests execute in separate environments, CodeBuild automatically collects and combines the test reports from each environment into a unified test report at the batch build level. This consolidation provides a comprehensive view of test results while maintaining the efficiency benefits of parallel execution.

The following is the diagram explains the complete concept of parallel test execution in AWS CodeBuild.

Concept diagram of parallel test execution.

On this page

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