How to execute two different test cases, one with Template and another one just a random test case in a robot file

*** Settings ***
Library DataDriver …/…/test-data/data.csv dialect=userdefined delimiter=; encoding=utf_8

*** Test Cases *** ${command} ${response}
Locate commands
[Tags] car bus
[Template] Find a device
${command} ${response}

Locate a device
[Tags] car bus
if ${device} = car
print “car”
else
print “bus”
end

*** Keyword ***
Find or a device
[Arguments] ${command} ${response}
Invoke command ${command}
response should be: ${response}

when I am trying to Run the below command its only executing test case with template.

python -m robot device.robot

Hi @nanicoderrf, I’m also having similar situation. Following is what I’m working on:

For ex.: I have the following scenarios
Test Suite #1

  1. Test #1 with template(Data Driver)
  2. Test #2 without template
  3. Test #3 without template

Test Suite #2

  1. Test #1 without template
  2. Test #2 without template
  3. Test #3 with template(Data Driver)

The tests in the suite needs to run in the order. When I import DataDriver library, the other test cases doesn’t run. When I comment out the DataDriver import statement, the templated test doesn’t run. I couldn’t figure it out.

Hi Sandeep,

Why do you need to have them in the same file?

You can have a Suite directory instead of a Suite file.

Create a directory for Test Suite #1, create one file for the test with template and a second file for the tests without template, and then run the Suite directory. Do the same for Test Suite #2.

Dave.

Hi @damies13,
I would like to put the tests in suite files rather than directories, so that the project will have less files.

Suites(Directory)
|___ Test_Suite_1.robot
|___ Test_Suite_2.robot

Suites(Directory)
|___ Test_Suite_1(Directory)
===>|___ Test_1_with_Template
===>|___ Test_2_without_Template
===>|___ Test_3_without_Template

If I can’t use suites as files, because of templated test, then I’ll follow your suggestion to have a folder for each test suite. Thanks

Hi Sandeep,

To have less files you could combine Test 2 and 3 into the same file, so you’d only need 2 files for this example.

I remember reading somewhere when using the Data Driver template you couldn’t have the tests without template in the same file (I’m not an expert on this so don’t remember the details)

If you refer to Test templates there are 2 ways to do test templates

  1. the method you’re probably using for Data Driver:
*** Settings ***
Test Template    Example keyword
  1. applying a template to a test:
*** Test Cases ***
Normal test case
    Example keyword    first argument    second argument

Templated test case
    [Template]    Example keyword
    first argument    second argument

I’m not sure if this second method works with Data Driver, if you can get that working with Data Driver then you might be able to put all test cases in the same file.

Hope that helps,

Dave.

Hi Dave,
I did try both ways and none of them work when I add standard tests with templated tests. I’ll test with suite directories and see how it goes. Also, with the suite folder, how can I set the order of tests?

Thanks

Hi Sandeep,

I can’t find it in the documentation, I think the order the tests are executed in is as they are found or processed by robot framework. So I would expect that if you prefixed the files with a number/letter then you should be able to control the order the files get processed.

The only thing I found in the documentation is Randomizing execution order which is probably the opposite of what you want.

Dave.