Wednesday, October 29, 2014

Default properties


Hello guys,

This is a quick post to present one new useful too I developed as part of the Mobile Automation Framework that I am building. 

I found that I had different properties files, one for each strong entity of the business model like the device, the application or a test user. Those files had some properties repeated among different files of the same entity. 

A simple and powerful solution is to have the first line of a file to point to another properties file which will be loaded first as the default properties. So for example, if the first line (just for convention, actually it can be any line) has a property with key "ref.defaults.fileName" and a value "default.properties" then this files is loaded first. The point here is that these default files can be chained / stacked if these files has at the same time a key pointing to another default file.

This way we can organise configuration in a hierarchical stack which goes from generic properties to specific ones. The properties of the default files are overwritten by the properties of the file to be loaded. 

You can check some test to see how this actually works and reuse the code as you wish from here

I hope it is useful, please leave me any comments if you have any idea or new requirements. 

Posted by Marc Andreu.

No comments: