Draft: Clarify testing guide for the code path with enabled FF
What does this MR do and why?
When a feature flag is introduced, it is recommended to test all the code affected by a feature flag, both when enabled and disabled to ensure the feature works properly.
The most common ways are:
- With an explicit context block with/without explicit FF enabling:
context 'when the feature flag is enabled' do
before do
stub_feature_flags(some_feature_flag: true)
end
it 'tests the behavior with the enabled feature flag' do
end
end
context 'when the feature flag is disabled' do
before do
stub_feature_flags(some_feature_flag: false)
end
it 'tests the behavior with the disabled feature flag' do
end
end
Pros: this explicit approach is more readable for someone who is unaware that feature flags are enabled by default in tests.
- With a context block only for the disabled FF scenario:
it 'tests the behavior with the enabled feature flag' do
end
context 'when the feature flag is disabled' do
before do
stub_feature_flags(some_feature_flag: false)
end
it 'tests the behavior with the disabled feature flag' do
end
end
Pros:Cleaner diffs and blames because only the relevant code is touched when the feature flag is removed. Less noise for someone who is aware that feature flags are enabled by default in tests.
Edited by Igor Drozdov