Last active
February 22, 2017 16:55
-
-
Save jeffbrl/eecaaa0d10820d9b13e097522ad561cd to your computer and use it in GitHub Desktop.
Simple test of a calculator function with the robot framework - v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** 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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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