Create checkpoint from string
- 5 years ago
thebick wrote:
The data are already in a file format, and I do not have the permission to create a .json file. Can I just create an aqObject and assign the text as some property of the object? It may be possible, but I don't see anything in the documentation to indicate if it is, and if so, how to do it.aqObject doesn't work that way. That's kind of what BenoitB was indicating. You don't need to create a JSON file, necessarily, but you should be able to, for many code languages, create your own custom objects. JavaScript is pretty easy in that you can simply use the prototyping way of creating objects from functions or even create classes. You could potentially create a Dictionary object from the available Scripting resources in your Windows environment. There are number of ways of doing this... but basically, it's a matter of building some custom code to create your object and assigning the properties.
But then... you may be complicating things more than you need to.
You could simply do aqString.Compare (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/compare.html). Pass in the two strings (The one from your baseline and the one from the application) and test to see if the result of Compare is 0. If it's zero, they match and you can use Log.CheckPoint to log a "Passed" result. If it's not zero, they don't match, and you can use Log.Warning or Log.Error (your choice) to log the failure.
Something like this.function stringCheckpoint(baselineString, testString) { if aqString.Compare(baselineString, testString, true) = 0 { Log.CheckPoint(testString + " is correct") } else { Log.Warning("The two strings do not match", "Baseline: " + baselineString + " Test: " + testString) }