Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Last active February 22, 2017 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffbrl/eecaaa0d10820d9b13e097522ad561cd to your computer and use it in GitHub Desktop.
Save jeffbrl/eecaaa0d10820d9b13e097522ad561cd to your computer and use it in GitHub Desktop.
Simple test of a calculator function with the robot framework - v1
*** Settings ***
Documentation Check arithmetic operations
Library ${EXECDIR}/lib/easy_math.py WITH NAME math
# The setup and teardown functions currently only print messages to output.xml
Suite Setup math.setup
Suite Teardown math.teardown
*** Variables ***
*** Test Cases ***
T1: Adding two integers
${result}= math.Calculate ${20} ${15} +
Should Be Equal As Integers ${result} ${35}
T2: Subtracting two integers
${result}= math.Calculate ${20} ${15} -
Should Be Equal As Integers ${result} ${5}
T3: Multiplying two integers
${result}= math.Calculate ${6} ${7} *
Should Be Equal As Integers ${result} ${42}
T4: Dividing two integers
${result}= math.Calculate ${42} ${7} /
Should Be Equal As Integers ${result} ${6}
import operator as op
def setup():
print "setting stuff up"
def calculate(number1, number2, operation):
arithmetic_function = { '+': op.add, '-': op.sub, '*': op.mul, '/': op.div }
return arithmetic_function[operation](number1, number2)
def teardown():
print "tearing stuff down"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment