run-acceptance-tests

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
An acceptance test is a Go test function with the prefix
TestAcc
.
To run a focussed acceptance test named
TestAccFeatureHappyPath
:
  1. Run
    go test -run=TestAccFeatureHappyPath
    with the following environment variables:
    • TF_ACC=1
    Default to non-verbose test output.
  2. The acceptance tests may require additional environment variables for specific providers. If the test output indicates missing environment variables, then suggest how to set up these environment variables securely.
To diagnose a failing acceptance test, use these options, in order. These options are cumulative: each option includes all the options above it.
  1. Run the test again. Use the
    -count=1
    option to ensure that
    go test
    does not use a cached result.
  2. Offer verbose
    go test
    output. Use the
    -v
    option.
  3. Offer debug-level logging. Enable debug-level logging with the environment variable
    TF_LOG=debug
    .
  4. Offer to persist the acceptance test's Terraform workspace. Enable persistance with the environment variable
    TF_ACC_WORKING_DIR_PERSIST=1
    .
A passing acceptance test may be a false negative. To "flip" a passing acceptance test named
TestAccFeatureHappyPath
:
  1. Edit the value of one of the TestCheckFuncs in one of the TestSteps in the TestCase.
  2. Run the acceptance test. Expect the test to fail.
  3. If the test fails, then undo the edit and report a successful flip. Else, keep the edit and report an unsuccessful flip.
验收测试是前缀为
TestAcc
的Go测试函数。
要运行名为
TestAccFeatureHappyPath
的指定验收测试:
  1. 运行
    go test -run=TestAccFeatureHappyPath
    ,并设置以下环境变量:
    • TF_ACC=1
    默认使用非详细测试输出。
  2. 验收测试可能需要针对特定Provider的额外环境变量。如果测试输出显示缺少环境变量,请建议如何安全地设置这些环境变量。
要诊断失败的验收测试,请按以下顺序使用这些选项。这些选项是累积的:每个选项都包含其上方所有选项的功能。
  1. 重新运行测试。使用
    -count=1
    选项确保
    go test
    不使用缓存结果。
  2. 启用
    go test
    的详细输出。使用
    -v
    选项。
  3. 启用调试级日志。通过环境变量
    TF_LOG=debug
    开启调试级日志。
  4. 保留验收测试的Terraform工作区。通过环境变量
    TF_ACC_WORKING_DIR_PERSIST=1
    启用保留功能。
通过的验收测试可能存在假阴性情况。要“翻转”一个名为
TestAccFeatureHappyPath
的通过验收测试:
  1. 编辑TestCase中某个TestStep内的TestCheckFuncs之一的值。
  2. 运行验收测试。预期测试会失败。
  3. 如果测试失败,则撤销编辑并报告翻转成功。否则,保留编辑并报告翻转失败。