企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Testing with feature flags > 原文:[https://docs.gitlab.com/ee/development/testing_guide/end_to_end/feature_flags.html](https://docs.gitlab.com/ee/development/testing_guide/end_to_end/feature_flags.html) * [Running a scenario with a feature flag enabled](#running-a-scenario-with-a-feature-flag-enabled) # Testing with feature flags[](#testing-with-feature-flags "Permalink") 要在启用了功能标志的情况下运行特定的测试,可以使用`QA::Runtime::Feature`类来启用和禁用功能标志( [通过 API](../../../api/features.html) ). 请注意,更改功能标志需要管理员授权. 只要您通过`GITLAB_QA_ADMIN_ACCESS_TOKEN` (推荐)提供适当的访问令牌,或者提供`GITLAB_ADMIN_USERNAME`和`GITLAB_ADMIN_PASSWORD` , `QA::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[](#running-a-scenario-with-a-feature-flag-enabled "Permalink") 也可以在启用功能标记的情况下运行整个方案,而无需编辑现有测试或编写新测试. 有关详细信息,请参见[质量检查自述文件](https://gitlab.com/gitlab-org/gitlab/tree/master/qa#running-tests-with-a-feature-flag-enabled) .