2.2. File handling
Goal
- Create a new test data file named
students.txt
which contains two names in separate lines. - Create a new keyword named
Read Names From File
which will log the names to console from thestudents.txt
. - Create a new test case named
Students
which will utilize the previously created keyword.
Solution
Hints
You can handle files and directories by using keywords from the OperatingSystem
library.
Click here to learn more about the OperatingSystem
library.
You will need to use Split To Lines
keyword from the String
library.
Solution: tests/02-classroom/test_data/students.txt
1 2 |
|
Solution: tests/02-classroom/resources/lists.resource
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Solution: tests/02-classroom/01-lists.robot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Results
Inside the tests
folder, execute the following command to execute 02-Classroom
suite.
1 |
|
You can check the generated log.html
file to see how your test cases worked.
Last update: June 22, 2020