30. novembre 2021
Tester des fichiers Excel
The procedure call creates a property variable which contains the different values of the Excel file. Hereby, the name of the property group is passed via the resultGroupName parameter. so, in the above example ${resultGroup:A1} will expand to the value located in the cell A1, ${resultGroup:A2} will expand to the value located in the cell A2 and so on.
Afterwards, it's possible to check the different values of the excel file, for example with the help of the different procedures in the check-Package (e.g. checkValueToBeEqual). However, especially if you do have a large Excel file, creating so many procedure calls can be cumbersome. In this case it makes sense to create a reference Excel file. Then QF-Test can read both the Excel file and the reference Excel file into different property groups. The following Jython server script can then be used to compare the property groups with one another:
p1 = rc.lookup("groupName1")
p2 = rc.lookup("groupName2")
props1 = rc.getProperties(p1)
props2 = rc.getProperties(p2)
errors = []
for p in props1.keys():
if props2.containsKey(p):
v1 = props1.get(p)
v2 = props2.get(p)
if v1 != v2:
errors.append("%s has value %s in %s but %s in %s" % (p, v1, p1, v2, p2))
else:
errors.append("%s in %s but not in %s" % (p, p1, p2))
for p in props2.keys():
if not props1.containsKey(p):
errors.append("%s in %s but not in %s" % (p, p2, p1))
if errors:
rc.logError("\n".join(errors))
Excel files can be read into QF-Test using a simple procedure call where the procedure qfs.utils.files.readExcelFile must be called: