This functionality is supported only for global configuration file in YAML-format (application.yml)!
If you need to change any property from the YAML global configuration file during testing, you should use tag <configuration> in scenario.xml. Write an appropriate comment and specify as many properties as you need inside the tag. To change property, you need to specify its full path from the highest level and the desired value. The value should have the same type as the property has in global configuration file.
Let's take a look at the following configuration file:
accountManagement: registration: emailRegistrationEnabled: true phoneRegistrationEnabled: true
To change values of emailRegistrationEnabled and phoneRegistrationEnabled properties, you need to specify their full path using dot separation, in our case accountManagement.registration.emailRegistrationEnabled and accountManagement.registration.phoneRegistrationEnabled. So in test scenario it should be the following:
... <configuration comment="Disabling registration via phone, enabling registration via email"> <property path="accountManagement.registration.phoneRegistrationEnabled" value="false"/> <property path="accountManagement.registration.emailRegistrationEnabled" value="false"/> </configuration> ...
So, the next step in the scenario, the system will behave as the properties above have the value false. Such behavior will last until the end of the scenario or until properties' values will be changed again.
You can specify as many properties as you need. Also you can use the tag <configuration> itself as many times as you need.
Also it's required to have stated paths of properties in GlobalConfigurationPathResolver.
How to add required path to GlobalConfigurationPathResolver
To add path which you need to GlobalConfigurationResolver, you should use command for invoking generator which adds appropriate paths to GlobalConfigurationPathResolver:
cmd/run generate cfg-with-resolver
The command above generates GlobalConfigurationPathResolver with ALL properties from global configuration file if it has YAML-format.
If you don't need all properties to be included in GlobalConfigurationPathResolver, you can list only required the highest level properties to include. For this separate them with comma (no spaces, just comma!).
For example, if you has the following configuration file
googleAuth: companyName: "Knubisoft.com" geoLite2: enabled: false name: "GEOLITE2" delaysTracking: api-duration: 5000ms dao-duration: 5000ms service-duration: 5000ms
and you need to generate paths only for properties companyName and api-duration to change their values via tag <configuration>, you should run the following command from the project root directory:
cmd/run generate cfg-with-resolver googleAuth,delaysTracking
You can also specify values to exclude from generation considering that all properties's paths will be generated. For that use the flag '-e' or '--exclude' and list required separated with comma the highest level properties to exclude. E.g.
cmd/run generate cfg-with-resolver -e geoLite2
cmd/run generate cfg-with-resolver --exclude geoLite2
NOTE: After test completion all changed properties' values are reverted to their values before changing via tag <configuration> (values which were stated in configuration file).
If you have any questions/suggestions feel free to contact Diakonov Serhii (email: s.dyakonov@knubisoft.com)