RobotDemo¶
Robot Framework Demo
The demo contains three different test case files illustrating three different approaches for creating test cases with Robot Framework.
Visit https://github.com/robotframework/RobotDemo for more information.
1 failed, 11 passed, 0 skiped, 12 total
Executed in 58 ms on March 17, 2024 at 11:35:01
Source /home/chme/git/python-robot-markdown/examples/RobotDemo
Statistics
| Pass / Fail / Skip | Total / Elapsed | |
|---|---|---|
FAIL RobotDemo | 11 / 1 / 0 | 12 / 58 ms |
FAIL RobotDemo.Data Driven | 5 / 1 / 0 | 6 / 22 ms |
PASS RobotDemo.Gherkin | 1 / 0 / 0 | 1 / 5 ms |
PASS RobotDemo.Keyword Driven | 5 / 0 / 0 | 5 / 11 ms |
Data Driven FAIL¶
Example test cases using the data-driven testing approach.
The data-driven style works well when you need to repeat the same workflow multiple times.
Tests use Calculate keyword created in this file, that in turn uses keywords in CalculatorLibrary.py. An exception is the last test that has a custom template keyword.
Notice that one of these tests fails on purpose to show how failures look like.
1 fail, 5 pass, 0 skip, 6 total
Executed in 22 ms
Addition PASS¶
Executed in 3 ms
Calculate 12 + 2 + 2 16
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 1 ms
Calculate 2 + -3 -1
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Subtraction PASS¶
Executed in 2 ms
Calculate 12 - 2 - 2 8
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Calculate 2 - -3 5
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 1 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Multiplication PASS¶
Executed in 3 ms
Calculate 12 * 2 * 2 48
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 1 ms
Calculate 2 * -3 -6
None.Calculate
Executed in 0 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Division PASS¶
Executed in 2 ms
Calculate 12 / 2 / 2 3
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Calculate 2 / -3 -1
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 1 ms
Failing FAIL¶
Executed in 2 ms
2 != 3
Calculate 1 + 1 3
None.Calculate
Executed in 1 ms
Push Buttons C${expression}=
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be ${expected}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Calculation error PASS¶
Executed in 4 ms
Calculation should fail kekkonen Invalid button 'k'.
None.Calculation should fail
Executed in 1 ms
${error} = Should Cause Error C${expression}=
Verifies that calculating the given expression causes an error.
CalculatorLibrary.Should Cause Error
Executed in 1 ms
Should Be Equal ${expected} ${error}
Fails if the given objects are unequal.
BuiltIn.Should Be Equal
Executed in 0 ms
Calculation should fail ${EMPTY} Invalid expression.
None.Calculation should fail
Executed in 1 ms
${error} = Should Cause Error C${expression}=
Verifies that calculating the given expression causes an error.
CalculatorLibrary.Should Cause Error
Executed in 0 ms
Should Be Equal ${expected} ${error}
Fails if the given objects are unequal.
BuiltIn.Should Be Equal
Executed in 0 ms
Calculation should fail 1 / 0 Division by zero.
None.Calculation should fail
Executed in 1 ms
${error} = Should Cause Error C${expression}=
Verifies that calculating the given expression causes an error.
CalculatorLibrary.Should Cause Error
Executed in 0 ms
Should Be Equal ${expected} ${error}
Fails if the given objects are unequal.
BuiltIn.Should Be Equal
Executed in 1 ms
Gherkin PASS¶
Example test case using the gherkin syntax.
This test has a workflow similar to the keyword-driven examples. The difference is that the keywords use higher abstraction level and their arguments are embedded into the keyword names.
This kind of gherkin syntax has been made popular by [http://cukes.info|Cucumber]. It works well especially when tests act as examples that need to be easily understood also by the business people.
0 fail, 1 pass, 0 skip, 1 total
Executed in 5 ms
Addition PASS¶
Executed in 3 ms
Given calculator has been cleared
None.Given calculator has been cleared
Executed in 1 ms
Push Button C
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
When user types "1 + 1"
None.When user types "1 + 1"
Executed in 0 ms
Push Buttons ${expression}
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
and user pushes equals
None.and user pushes equals
Executed in 0 ms
Push Button =
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
Then result is "2"
None.Then result is "2"
Executed in 1 ms
Result Should Be ${result}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Keyword Driven PASS¶
Example test cases using the keyword-driven testing approach.
All tests contain a workflow constructed from keywords in CalculatorLibrary.py. Creating new tests or editing existing is easy even for people without programming skills.
The keyword-driven appoach works well for normal test automation, but the gherkin style might be even better if also business people need to understand tests. If the same workflow needs to repeated multiple times, it is best to use to the data-driven approach.
0 fail, 5 pass, 0 skip, 5 total
Executed in 11 ms
Push button PASS¶
Executed in 1 ms
Push Button 1
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 1 ms
Result Should Be 1
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Push multiple buttons PASS¶
Executed in 1 ms
Push Button 1
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
Push Button 2
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
Result Should Be 12
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Simple calculation PASS¶
Executed in 2 ms
Push Button 1
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
Push Button +
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 1 ms
Push Button 2
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
Push Button =
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
Result Should Be 3
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Longer calculation PASS¶
Executed in 1 ms
Push Buttons 5 + 4 - 3 * 2 / 1 =
Pushes the specified buttons.
CalculatorLibrary.Push Buttons
Executed in 0 ms
Result Should Be 3
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms
Clear PASS¶
Executed in 1 ms
Push Button 1
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 0 ms
Push Button C
Pushes the specified button.
CalculatorLibrary.Push Button
Executed in 1 ms
Result Should Be ${EMPTY}
Verifies that the current result is expected.
CalculatorLibrary.Result Should Be
Executed in 0 ms