Config files facilitates the execution of code in any environment without changing the code. In this post I am sharing about what kind of information we can add in config files and some common practices to keep in mind while creating config files.

    Why config files?

- Environment dependent parameters (Ex. Local, dev, stage, production)
- Test code dependent parameters (Ex. Timeouts, Reporting format, Logger)
- Test execution dependent parameters (Ex. Cloud browser/device services)
- Confidential parameters (Ex. Application, DB credentials, DB connection strings)
What format ?
There are no constraints on the format of the configuration file as long as the code could read and parse them. Configuration file should meet at least these 3 basic criteria to solve the purpose:
- Easy to read and edit
- Allow comments
- Easy to deploy
Best practices for managing config files:
- Breakdown and group the config files as per intent so that we manage the changes easily.
- Follow meaningful naming convention.
- Do not store confidential information directly.
- Do not add config properties which can be managed well within code itself.
- In case of overriding the value of any config property, keep in mind the below sequence:
Command line properties -> System properties -> Environment variables -> Code config properties