2.4. Class based libraries
Goal
- Create a new class based library named
JSONLibrary
with a keyword namedParse JSON File
. This keyword should open and parse the content of the given JSON file and return the parsed data. - Make sure that the
JSONLibrary
available to every test case. - Modify the test case named
Get Exam Results
to useJSONLibrary
andParse JSON File
keyword.
Solution
Hints
Test libraries can be implemented as Python modules and Python or Java classes.
Solution: tests/libraries/JSONLibrary.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Solution: tests/02-classroom/02-exams.robot
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Results
To be able to import JSONLibrary
without defining the whole path to the file, you need to set its location with --pythonpath
parameter.
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