I am new to Robot, and trying to implement a data-driven test case, where I read data from a file. The data looks like this:
TC1,user1,password1
TC2,user2,password2
TC3,user3,password3
TC4,user4,password4
My test case and keywords are as below:
*** Test Cases ***
Login TestCase
${data}= Read Data From File ${testFile}
Process Test Data ${data}
*** Keywords ***
Process Test Data
[Arguments] ${data}
: FOR ${row} IN @{data}
\ ${status}= Run Keyword And Return Status Perform Login ${row}
Perform Login
[Arguments] ${row}
Login using ${row[1]} ${row[2]}
Now while running the 'Login Testcase', the report generated shows
'Total 1 Pass 1 Fail 0'.
My question is how can I get the report the generate Pass/Fail for each row, ie
'Total N Pass X Fail Y' , where N=number of rows in data file and X+Y=N
I tried putting the For loop inside 'Login Testcase', but still getting the same result. Any ideas/help is highly appreciated!
Update: So, I tried modifying the tests (without reading the data file) as below:
*** Settings ***
Test Template Perform Login
*** Test Cases ***
Login TestCase
TC1 user1 password1
TC2 user2 password2
TC3 user3 password3
TC4 user4 password4
*** Keywords ***
Perform Login
[Arguments] ${tc#} ${username} ${password}
Login using ${username} ${password}
While doing so, Perform Login is run 4 times, but the report output still shows
'Total 1 Pass 1 Fail 0'.
I am not sure if I am using the test template the correct way, and also how to read data from file and use that for each test case iteration.
Update2:
*** Settings ***
Test Template Perform Login
*** Test Cases ***
TC1 user1 password1
TC2 user2 password2
TC3 user3 password3
TC4 user4 password4
*** Keywords ***
Perform Login
[Arguments] ${username} ${password}
Login using ${username} ${password}
When I modify the testcases this way, I get
'Total 4 Pass 3 Fail 1', which is what I expect.
But in this case, I am not sure how to use the data read from file. Please help/share your ideas on how I could use data file to feed my testcases!!