I am using Robot Framework to test a system that returns an int which represents the number of errors the system encountered while under test. However, if the system becomes unresponsive the return will be a NoneType and I receive this error:
'None' cannot be converted to an integer: TypeError: int() argument must be a string or a number, not 'NoneType'
I'm not able to use the Should Be True keyword because a passing response will be 0.
Is there any way to test the variable's type in Robot? My goal is to do something like this:
Should Not Be NoneType ${error_count} msg=System is not responding after test.
Should Be Equal As Integers ${error_count} ${0} msg=System generated ${error_count} errors during test.
To check that ${error_count} is not None, you can do the following:
Should Be True ${error_count} is not ${None} msg=Returned None
So long as the previous statement passes, your test can move forward with printing your result like so:
Log to Console System generated ${error_count} errors during test
Alternatively, you can merge everything onto one line using the Run Keyword Unless keyword:
Run Keyword Unless ${error_count} is ${None} Log to Console System generated ${error_count} errors during test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With