Feature Toggle Integration Testing with Spring Boot

This blog explains tries to explain the following concepts:


  1. What is a feature toggle?
  2. Use case of feature toggle in real life
  3. Importance of integration testing with feature on and off

What is a feature toggle?

The mechanism of controlling the application's behaviour or feature during runtime using an external configuration or property is called feature toggle.

Use case of feature toggle in real life

Imagine you are a developer working for a telecom provider. Every time a new product or phone is launched by manufacturers, the products should not be displayed in the telecom provider's website, until it is officially launched by the manufacturers like Apple or Google.

However as a telecom provider, your organisation should be able to sell or receive orders for the newly launched phones, immediately after the launch of the new phones.

Hence, feature toggle becomes quite handy, where the application can be developed with new features targeting the sales of un-launched phones, however the new features can be switched off in production until the official launch.

Once the phone is launched, the technical team can enable the new feature by simply editing the value of an environment variable or configuration file to enable the feature in production, without having to redeploy the application.

Importance of integration testing with feature on and off

An application using feature toggle should not only be tested at unit level testing, but also be tested at developer's integration testing or functional testing.

Feature toggle testing at functional level allow us to test the application's behaviour and user experience, when the feature is on and off. Also it increases the robustness of the application, so that application can be deployed confidently with feature on or off.

Sample application on Github with feature toggle integration tests

I have created a sample Github repository with Spring Boot application along with Integration tests, which tests a web page and web apis with feature on and off.

https://github.com/harishkannarao/FeatureToggleTestingWithSpringBoot

The integration tests uses programmatic way to start/restart a spring boot application to control the feature on or off, which allows the application running inside a server to pick up the changes made to the feature controlled by the integration test.

Comments

Popular posts from this blog

JSON with curl and jq

Import self signed in Linux for Chrome / Chromium headless testing

Colima - Drop In replacement for Docker Desktop for Mac and Linux