Skip to content

Allow conditioning SwitcherTests based on a criteria (when) #309

@petruki

Description

@petruki

Is your feature request related to a problem? Please describe.
Switcher can also have Strategies that can give us more granular verification for feature flags.
When testing more complex cases using Strategies, we want to provide the condition in which the Switcher will return true or false.

Describe the solution you'd like
Include a CriteriaResponse map of criteria (when), that will be checked during Switcher evaluation.
This map will toggle the result assumed when evaluating the Switcher.

This feature can be used in both ways, with SwitcherExecutor or SwitcherTest annotations.

SwitcherExecutor

void shouldTestSomething() {
   SwitcherExecutor.assume(MY_SWITCHER, true)
	.when(StrategyValidator.VALUE, "Value1");
}

SwitcherTest

@SwitcherTest(key = MY_SWITCHER, when = {
   @SwitcherTestWhen(strategy = StrategyValidator.VALUE, input = "Value1")
})
void shouldTestSomething() {
...
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions