0

I have introduced a feature flag in my spring application application.yml and I'd like to test both scenarios in which this feature flag is true/false. I have my existing tests implemented with cucumber, and I've created a separate package where I'd like to put all my tests scenarios where the feature flag is enabled.

Only for the scenario's background step, I need the feature disabled, so I would like to have the possibility to enable/disable this flag value (flags.myfeatureflag-enabled) through a cucumber step, in order to enable/disable it in tests scenarios. How is it possible to do so?

Akinn
  • 1,896
  • 4
  • 23
  • 36

1 Answers1

1

You have not implemented a feature toggle, you have implemented a configuration toggle.

You can not change a configuration toggle without refreshing the application context and as such you can not "toggle" it while using Cucumber Spring, nor could you do this with Springs JUnit integration.

You can still test it but you will have to start and refresh the application context manually.

Alternatively reconsider the design of your feature toggle such that it doesn't depend on configuration. For example by having it in the database, external service or passed along with the request.

M.P. Korstanje
  • 10,426
  • 3
  • 36
  • 58