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 Kotlin

Focus mode
Configure parallel tests with Kotlin - AWS CodeBuild

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

version: 0.2 batch: fast-fail: false build-fanout: parallelism: 2 ignore-failure: false phases: install: runtime-versions: java: corretto11 commands: - echo 'Installing dependencies' - KOTLIN_VERSION="1.8.20" # Replace with your desired version - curl -o kotlin-compiler.zip -L "https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip" - unzip kotlin-compiler.zip -d /usr/local - export PATH=$PATH:/usr/local/kotlinc/bin - kotlin -version - curl -O https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.8.2/junit-platform-console-standalone-1.8.2.jar pre_build: commands: - echo 'prebuild' build: commands: - echo 'Running Kotlin Tests' - | codebuild-tests-run \ --test-command 'kotlinc src/main/kotlin/*.kt $(echo "$CODEBUILD_CURRENT_SHARD_FILES" | tr "\n" " ") -d classes -cp junit-platform-console-standalone-1.8.2.jar' \ --files-search "codebuild-glob-search 'src/test/kotlin/*.kt'" - | codebuild-tests-run \ --test-command ' java -jar junit-platform-console-standalone-1.8.2.jar --class-path classes \ $(for file in $CODEBUILD_CURRENT_SHARD_FILES; do class_name=$(basename "$file" .kt) echo "--select-class $class_name" done) ' \ --files-search "codebuild-glob-search 'src/test/kotlin/*.kt'" post_build: commands: - echo "Test execution completed"

In the above example, the codebuild-tests-run CLI is used twice. During the first run, kotlinc compiles the files. The CODEBUILD_CURRENT_SHARD_FILES variable retrieves the test files assigned to the current shard, which are then converted into a space-separated list. In the second run, JUnit executes the tests. Again, CODEBUILD_CURRENT_SHARD_FILES fetches the test files assigned to the current shard, but this time they are converted into class names.

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