Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run specific test cases from a test suite using Robot Framework

I am new to Robot and am learning to write logic and test cases.

I have a test suite, "mytestsuite.robot", which has a lot of test cases. I have a couple of errors in one of my test cases.

How do I run just that specific test case since I don't want to run the whole test suite again?

File mytestsuite.robot

testcase1 .... .... testcase2 .... .... testcase3 .... .... testcase4 .... .... 

Say test case 3 failed, and I want to just rerun test case 3.

I tried to use:

pybot mytestsuite.robot -t testcase3 

But I get an error.

like image 802
Mysterio Man Avatar asked Jul 28 '14 22:07

Mysterio Man


People also ask

How do you run a single test case multiple times in Robot Framework?

For example, if you are running tests on the current folder, you can pass "." as many times as you want the test to run. Ex: robot -t "*My test*" . . . This command will run all tests that match the expression 3 times, and the report will contain all 3 executions and results.


2 Answers

You want to use the option -t or --test, but the option goes before the name of the file rather than after. This should work:

robot -t testcase1 mytestsuite.robot 

The order of the command line arguments is covered in the user guide under a section titled Starting test execution, and is also available at the command line with the --help option (e.g. pybot --help)

Be aware that the specific file name is optional. You could use only: robot -t testcase1 .

Where "." means look for all files that contains the specified test. Robot will do the hard work of finding the specific test.

You can use also willcard as * in the begining or finish of the test name, to match easily a test or to run multiple tests.

robot -t "testcase1*" .

Will match all tests that begin with "testcase1" in current folder.

The user guide has a section titled Selecting test cases which covers this subject.

like image 120
Bryan Oakley Avatar answered Sep 22 '22 02:09

Bryan Oakley


If you want to run single test case in Robot Framework, use the below example.

Syntax: robot -t "Test Case Name" Test Suite Name
Example: robot - t "PON Type Test Case" Aquarium_Project.robot

If you want to run all the test cases in Robot Framework, use the below example

Syntax: robot Test Suite Name
Example: robot Aquarium_Project.robot

like image 21
Logan M Avatar answered Sep 21 '22 02:09

Logan M