Hi,I try to compare property in checkpoint, the property compare failed although it has same value
Solved! Go to Solution.
You can write a script routine using the script editor of TestComplete. You should have chosen a script language when you created your project.
Once your script code is written, you can use the "Run Script Routine" operation to execute the code within your keyword test.
Hi,
> The value is float
This is the key. Regular comparison logic does not work with floats due to their internal representation. Your approach with the threshold is valid and generally used one.
Or, convert floats to strings as it was suggested by Robert and do strings comparison.
Non-printing characters, spaces, etc., all are compared. If you're comparing string to string, it needs to be EXACT.
Double check to make sure that the actual property does not have spaces at the end. You could always change the test to "contains" instead of "equals".
Hi Trisyaanogre,
The values are exactly the same, no spaces or something like that, even when I updated the property to the actual value and ran the test again it fails.
Furthermore the value is recognized as a number and not as a string (I don't have the "contains" condition) .
My end game is to compare the value with a threshold - is there any way to do this?
I'm wondering if it may be a rounding problem... that the property value actually contains more significant digits than what is visible... or if it's a data type problem (double vs long).
What would happen if you had your "Expected Value" stored as a string? To see if it compares string to string?
The value is float, the main goal of this test is to compare array of floats.
I can not change the type of the property because it is an external component.
Is there a way to compare array of values and not only one?
I would write script code for that rather than using a property checkpoint.
How do I replace checkpoint with script code?
You can write a script routine using the script editor of TestComplete. You should have chosen a script language when you created your project.
Once your script code is written, you can use the "Run Script Routine" operation to execute the code within your keyword test.
Hi,
> The value is float
This is the key. Regular comparison logic does not work with floats due to their internal representation. Your approach with the threshold is valid and generally used one.
Or, convert floats to strings as it was suggested by Robert and do strings comparison.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |
Subject | Author | Latest Post |
---|---|---|