Reputation: 59
I am starting to learn how to use robotframework for testing I have created following test case to be executed on the local linux host.
*** Settings ***
Library Process
Suite Teardown Terminate All Processes kill=True
*** Test Cases ***
${result} = Run Process ping 1.1.1.1 -c 1 shell=True stdout=/home/user/stdout.txt
Log all output: ${result.stdout}
Should Contain ${result.stdout} 64 bytes from 1.1.1.1*
When i execute this test case I get following out in the terminal:
➜ ~ robot firstlinux.robot
==============================================================================
Firstlinux
==============================================================================
${result} = | PASS |
------------------------------------------------------------------------------
Log | FAIL |
No keyword with name 'all output: ${result.stdout}' found.
------------------------------------------------------------------------------
Should Contain | FAIL |
No keyword with name '64 bytes from 1.1.1.1*' found.
------------------------------------------------------------------------------
Firstlinux | FAIL |
3 critical tests, 1 passed, 2 failed
3 tests total, 1 passed, 2 failed
==============================================================================
Output: /home/user/output.xml
Log: /home/user/log.html
Report: /home/user/report.html
How do I get this test to pass, I am checking the stdout and make sure it has the string output from the ping command but looks like robot is not picking this up. I cam see that a stdout.txt file is created which has the results from the stdtout as:
➜ ~ ping 1.1.1.1 -c 1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=55 time=30.5 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 30.565/30.565/30.565/0.000 ms
How do I get the stdout to be displyed in the report that is generated, at the moment I cannot see the output in the report.
Thanks
Upvotes: 0
Views: 6315
Reputation: 386352
Your problem is that you haven't properly indented the keywords in your test case. Robot thinks that anything at the left margin is the name of a test case.
You posted this code:
*** Test Cases ***
${result} = Run Process ping 1.1.1.1 -c 1 shell=True stdout=/home/user/stdout.txt
Log all output: ${result.stdout}
Should Contain ${result.stdout} 64 bytes from 1.1.1.1*
In the above, robot thinks that the first test case is named ${result}
. It thinks Log
is the name of a second test case, and Should Contain
is the name of a third test case.
The words immediate after those names are assumed to be keywords. That is why it's complaining that all output: ${result.stdout}
, because that's the first keyword of the "test case" you've named Log
.
Instead, you need to give your test case a name, and then indent all of those statements. For example, if you want to call this test "Ping test", you would do it like this:
*** Test Cases ***
Ping test
${result} = Run Process ping 1.1.1.1 -c 1 shell=True stdout=/home/user/stdout.txt
Log all output: ${result.stdout}
Should Contain ${result.stdout} 64 bytes from 1.1.1.1*
Note: you also need two or more spaces after Run Process
.
Upvotes: 3