We use robot framework at work to do some automated testing, and I need to add a few tests. This format is already in the repo, I cannot change anything drastically.
I am using a keywords file that looks like this:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from robot.api.deco import keyword
class testkeywords(object):
"""
"""
def __init__(self):
pass
@keyword('I compare ${first_number} with ${second_number}')
def compare(self, first_number, second_number):
if (int(first_number) != int(second_number)):
raise ValueError('Numbers are not the same.')
The .robot file has two tests, one that passes and one that fails:
*** Settings ***
Library testkeywords.py
*** Variables ***
${num_a} 5
${num_b} 6
*** Test Cases ***
Compare same numbers
I compare ${num_a} with ${num_a}
Compare different numbers
I compare ${num_a} with ${num_b}
The Compare different numbers test fails as expected, but it's still a FAIL. How can I set it to expect a failure and hence pass the keyword?