debian-mirror-gitlab/doc/development/testing_guide/end_to_end/feature_flags.md

30 lines
1.2 KiB
Markdown
Raw Normal View History

2019-12-26 22:10:19 +05:30
# Testing with feature flags
2020-04-22 19:07:51 +05:30
To run a specific test with a feature flag enabled you can use the `QA::Runtime::Feature` class to enable and disable feature flags ([via the API](../../../api/features.md)).
2019-12-26 22:10:19 +05:30
Note that administrator authorization is required to change feature flags. `QA::Runtime::Feature` will automatically authenticate as an administrator as long as you provide an appropriate access token via `GITLAB_QA_ADMIN_ACCESS_TOKEN` (recommended), or provide `GITLAB_ADMIN_USERNAME` and `GITLAB_ADMIN_PASSWORD`.
2020-04-22 19:07:51 +05:30
Please be sure to include the tag `:requires_admin` so that the test can be skipped in environments where admin access is not available.
2019-12-26 22:10:19 +05:30
```ruby
2020-07-28 23:09:34 +05:30
RSpec.describe "with feature flag enabled", :requires_admin do
2019-12-26 22:10:19 +05:30
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
It's also possible to run an entire scenario with a feature flag enabled, without having to edit existing tests or write new ones.
2020-06-23 00:09:42 +05:30
Please see the [QA README](https://gitlab.com/gitlab-org/gitlab/tree/master/qa#running-tests-with-a-feature-flag-enabled) for details.