次の手順では、pytest テスト フレームワーク
この手順には、次の前提条件が必要です。
-
既存の CodeBuild プロジェクトがある。
-
そのプロジェクトは、pytest テストフレームワークを使用するようにセットアップされた Python プロジェクトである。
build
ファイルの post_build
または buildspec.yml
フェーズに、次のエントリを追加します。このコードは、自動的に現在のディレクトリ内でテストを検出し、<test report directory>
/<report filename>
で指定されたファイルにテストレポートをエクスポートします。レポートでは、JunitXml
形式が使用されます。
- python -m pytest --junitxml=<test report directory>
/<report filename>
buildspec.yml
ファイルで、次のセクションを追加/更新します。
version: 0.2
phases:
install:
runtime-versions:
python: 3.7
commands:
- pip3 install pytest
build:
commands:
- python -m pytest --junitxml=<test report directory>
/<report filename>
reports:
pytest_reports:
files:
- <report filename>
base-directory: <test report directory>
file-format: JUNITXML