How to skip a specific testcase in Robot framework?

Siya picture Siya · Oct 14, 2014 · Viewed 17.7k times · Source

In my robot script total 10 testcase are preset under TEST Cases section. Test1 is independent and does not need to run all the time; one time execution is enough.

Please suggest if there is a keyword that would skip only testcase1.

However if user is interested to run the script including testcase1, then user has to specify in command like something like pybot <scriptname> "add testcase1".

testcase1
....
....

testcase2
....
....

testcase3
....
....

testcase10
....
....

Answer

Bryan Oakley picture Bryan Oakley · Oct 14, 2014

There is no keyword for skipping a test. If you need to determine at run time whether to run a test or not, your only choice is to immediately fail it or cause it to pass without doing any other work. Robot simply doesn't support skipping tests once the tests start running

However, there is a command line option to let you skip tests by tag. This is a very powerful feature of robot. For more information see Selecting test cases in the robot framework users guide.

For example, consider the following test suite:

*** Test Cases ***
| Test case 1
| | [Tags] | run-once
| | log | this is test case 1

| Test case 2
| | log | this is test case 2

To run all the tests you would do this:

$ pybot example.robot

If you wanted to skip the first test you can use the --exclude option:

$ pybot --exclude run-once example.robot

If you wanted to run only the first test you could explicitly include it, which will run only the tests that have this tag:

$ pybot --include run-once