most efficient way to code file comparison checkpoints in large quantities
I'm looking for Suggestions/Tips/Tricks for an upcoming project. I am attempting to do some very simple file comparisons, but I am attempting to do so for a very large number of files so I would like to find the most efficient method possible. Efficiency is key given the number of files for the purposes of adding new test cases and for future maintenance. I will be generating new files on a regular basis that will be compared to previously generated File Checkpoint baselines that will be maintained in the SmartBear store. The generation of the new files will be handled by a separate automated process I've already configured, so all I need to do is automated the file comparisons in an efficient and easily maintainable way.
In other words, one newly generated file in a local directory will be compared against a SmartBear file Store file, and script will produce a warning if the comparison is above the AllowedDifference threshold, or will produce a Test Pass log entry if all is good.
I would like to maintain some sort of list... this list will contain categories like these to identify the files that I'm referencing:
1. file directory
2. file name
3. Hash % of "AllowedDifference" between the new/old files
5. Category of file
6. sub-Category of the file
4. name/location of the baseline file checkpoint in the SmartBear file Store that the newly generated file above file will be compared against.
I will iterate over the various test cases in the above list based on the Category/SubCategory supplied.
Any suggestions on how I may do this using SmartBear Scripts, keyword tests, File Checkpoints, etc. I'm wondering if I can use some sort of variable list or a Database to store all the values and maintain them in this list, and some variation of the "Check" method with "AllowedDifference" parameter to verify if the file content of the new files is sufficient for a Test Pass.
Any help would be greatly appreciated.
Thanks,
K
What kind of files are you going to make ? do you need to compare context in files or just compare byte codes.?
Test Complete will do comparison byte by byte. In some file types eg - PDF if not similar TC will let you know how many byte differs from original only. But TC can show difference between two text files.
To iterate over sort of list you can use DDT drivers. link
Thanks NisHera. Various text file formats, so yes I'll be attempting to use File Vericiation Checkpoints so I can see what has changed. I'll be attempting to use hash to allow files to pass if there is an acceptable % of difference in certain cases.
Anyway, I think the DDT drivers may be the answer I need. I need multiple different rows of values in the Excel or CSV driver though, so I may need to load to an Array in the script/keyword test in order to access the various columns/rows of data to get the values I'm after.
A little concerned about the performance if I have thousands of rows/columns in the spreadsheet... have you used this with a large spreadsheet or CSV before, and if so any latency/issues with scripts running to completion. In other words, is the loading of the DDT Driver content fast?
I don't know Python well so forgive me if my syntax is incorrect.
If I understand correctly, Baseline, as it comes from the DDT driver, is a text string that represents the name of the file in the Files store of TestComplete. So, you want to compare that file to what is being created as OBFile, right?
If that's the case, then your comparison should look like this:
# Creates a driver Driver = DDT.ExcelDriver("C:\\SmartBear-DDTDrivers\\BulkCustody.xlsx", "Sheet1") OBFile = aqString.Concat(DDT.CurrentDriver.Value[0], DDT.CurrentDriver.Value[1]) Baseline = DDT.CurrentDriver.Value[2] AllowableDiff = StrToInt(DDT.CurrentDriver.Value[3]) # Perform file comparison for each entry in the Excel file if (Files.Items(Baseline).Check(OBFile, AllowableDiff) == False): Log.Warning("For BaselineFileName" + ": " + aqConvert.VarToStr(DDT.CurrentDriver.Value[2]) + "the file HashCompare is beyond acceptable threshold - Please review OB file and compare against baseline file in SmartBear Repository.", pmHighest)# highest priority else: Log.Message(aqConvert.VarToStr(DDT.CurrentDriver.Value[2]) + "file was verified and is either identical or within acceptable threshold - No further actoin is needed.")
The Files.Items method returns the File object with the indicated name. You can then call the "Check" method of that item as you are doing.