2.3. Evaluate
Goal
- Create a new test data file named
exam_results.json
which contains two names as keys, the values should be dictionaries which contain exam results like:{'math': '90%', 'physics': '85%'}
. - Create a new suite named
02-Exams
in02-Classroom
suite. - Create a new test case named
Get Exam Results
in02-Exams
suite which will read theexam_results.json
and log the results to the console in the following format:Jane Doe: {'math': '90%', 'physics': '85%'}
.
Solution
Hints
JSON (JavaScript Object Notation)
is a lightweight data-interchange format.
Click here to learn more about the JSON
format. Click here to see examples for JSON
.
You can decode JSON
strings by using Python module named json
.
Click here to learn more about json
module.
You can use Evaluate
keyword to evaluate expressions in Python.
Click here to learn more about Evaluate
keyword.
Robot Framework supports native &{dict}
iteration with FOR
loops from version 3.2.0`. Make sure you have at least that version of Robot Framework installed!
Solution: tests/02-classroom/test_data/exam_results.json
1 2 3 4 5 6 7 8 9 10 |
|
Solution: tests/02-classroom/02-exams.robot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Results
Inside the tests
folder, execute the following command to execute 02-Exams
suite.
1 |
|
You can check the generated log.html
file to see how your test cases worked.
Last update: June 22, 2020