Testing with feature flags

原文:https://docs.gitlab.com/ee/development/testing_guide/end_to_end/feature_flags.html

Testing with feature flags

要在启用了功能标志的情况下运行特定的测试,可以使用QA::Runtime::Feature类来启用和禁用功能标志( 通过 API ).

请注意,更改功能标志需要管理员授权. 只要您通过GITLAB_QA_ADMIN_ACCESS_TOKEN (推荐)提供适当的访问令牌,或者提供GITLAB_ADMIN_USERNAMEGITLAB_ADMIN_PASSWORDQA::Runtime::Feature将自动以管理员身份进行身份验证.

请确保包含标签:requires_admin以便在没有管理员权限的环境中可以跳过测试.

RSpec.describe "with feature flag enabled", :requires_admin do
  before do
    Runtime::Feature.enable('feature_flag_name')
  end

  it "feature flag test" do
    # Execute a test with a feature flag enabled
  end

  after do
    Runtime::Feature.disable('feature_flag_name')
  end
end 

Running a scenario with a feature flag enabled

也可以在启用功能标记的情况下运行整个方案,而无需编辑现有测试或编写新测试.

有关详细信息,请参见质量检查自述文件 .

Copyright © 温玉 2021 | 浙ICP备2020032454号 all right reserved,powered by Gitbook该文件修订时间: 2021-03-27 13:48:25

results matching ""

    No results matching ""