Search code examples
robotframeworkbuilt-in

Robot FW: Builtin library : Should Not Be Equal 0b1011 11 : Passes but its should fail, why?


Consider the following usage of "Should Not Be Equal" keyword:

*** Test Cases ***
Use "Should Not Be Equal"
     Should Not Be Equal 0b1011    11   # Should fail, but passes. Why?
     Should Not Be Equal     0b1011    0xB   # Should fail, but passes. Why?

The goal is to provide a negative failing test case by providing 0b1011 (i.e. 11 in base 10) and 11 (in base 10). Since 11 == 11 is True (in base 10), this test case should fail.

The actual result is that the test case passes, why?


Solution

  • Because by default, all arguments to keywords are passed as strings. So this call:

    Should Not Be Equal    0b1011    11
    

    , is similar to python's

    "0b1011" != "11"
    

    , which evaluates to True.

    If you want to check the integers/numerical values, this is the way:

    Should Not Be Equal    ${0b1011}    ${11}   # will fail, they are equal.