Properties files fixture is a specialization of FileFixture which allows .properties file to be read.
Reading
In this sample we first create a .properties file, using FileFixture, and then read it.| script | file fixture | ||||
| set directory | http://files/test | ||||
| $props<-[sample.properties] | create | sample.properties | containing | wine = good | |
| append | #comment = ignored | to | $props->[sample.properties] | on new line | |
| append | beer:bad | to | $props->[sample.properties] | on new line | |
| show | content of | $props->[sample.properties] | wine = good #comment = ignored beer:bad | ||
| script | properties file fixture | |||||||
| load values from | $props->[sample.properties] | |||||||
| show | values |
| ||||||
| check | value | wine | good | |||||
| check | value | beer | bad | |||||
| check | number of values | 2 | ||||||
| We can use standard file fixture methods | ||||||||
| delete | $props->[sample.properties] | |||||||
Writing
We can also write properties in an easier way:| script | properties file fixture | |||
| set directory | http://files/test | |||
| set value | bad | for | wine | |
| set value | good | for | beer | |
| set value | better | for | cola | |
| $sample2<-[sample2.properties] | create | sample2.properties | containing values | |
| show | content of | $sample2->[sample2.properties] | wine=bad cola=better beer=good | |
| script | properties file fixture | |||||||||
| load values from | $sample2->[sample2.properties] | |||||||||
| show | values |
| ||||||||
| check | value | wine | bad | |||||||
| check | value | beer | good | |||||||
| check | value | cola | better | |||||||
| check | number of values | 3 | ||||||||
| delete | $sample2->[sample2.properties] | |||||||||