Share
Embed
Transcript
20 slides
-
本日話す内容 話すこと • Circle CIで失敗したテストを再実行する方法 (前提として僕がAndroidエンジニアなのでJUnitでのテストをベースに話します。) 話さないこと • 他のCI/CDサービスとの比較 •
Flakyなテストを改善していく系の話 Circle CIで失敗したテストのみ再実行できるようになりました -
Circle CIでテストを実行している例 (AndroidのUnitTestの実行例) CircleCIのテストの実行例 - run: name: Run UnitTest command:
| ./gradlew testDebugUnitTest -
設定①: テスト結果のアップロード store_artifactsを使用する方法 - run: name: Save test results command:
| mkdir -p ~/test-results/junit/ find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; when: always - store_artifacts: path: ~/test-results destination: circleci-docs -
設定①: テスト結果のアップロード store_artifactsを使用する方法 - run: name: Save test results command:
| mkdir -p ~/test-results/junit/ find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; when: always - store_artifacts: path: ~/test-results destination: circleci-docs JUnitのテスト結果はそれぞれの モジュール内にxmlファイルが作られるのでま とめて ~/test-resultsにコピーする -
設定①: テスト結果のアップロード store_artifactsを使用する方法 - run: name: Save test results command:
| mkdir -p ~/test-results/junit/ find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; when: always - store_artifacts: path: ~/test-results destination: circleci-docs -
設定①: テスト結果のアップロード store_test_resultsを使用する方法 - run: name: Save test results command:
| mkdir -p ~/test-results/junit/ find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \; when: always - store_test_results: path: ~/test-results -
設定②: circleci tests runを使ってテスト実行 次にcircleci tests runを使ってテストを実行する必要があります。 - run: name:
Run unit test command: | set -e TEST_FILES=$(circleci tests glob " **/src/test/java/*.kt") echo "$TEST_FILES" | circleci tests run \ --command="./gradlew testDebugUnitTest" \ --verbose --split-by=timings --timings-type=classname -
設定②: circleci tests runを使ってテスト実行 次にcircleci tests runを使ってテストを実行する必要があります。 - run: name:
Run unit test command: | set -e TEST_FILES=$(circleci tests glob " **/src/test/java/*.kt") echo "$TEST_FILES" | circleci tests run \ --command="./gradlew testDebugUnitTest" \ --verbose --split-by=timings --timings-type=classname circleci tests コマンドでテストファイルのグロ ブします -
設定②: circleci tests runを使ってテスト実行 次にcircleci tests runを使ってテストを実行する必要があります。 - run: name:
Run unit test command: | set -e TEST_FILES=$(circleci tests glob " **/src/test/java/*.kt") echo "$TEST_FILES" | circleci tests run \ --command="./gradlew testDebugUnitTest" \ --verbose circleci tests run のcommandオプションに テストの実行コマンドを指定します。 verboseオプションでデバッグメッセージが出 るようにします。