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

**URL:** <https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150>\
**Category:** DataDriver\
**Created:** [6 July 2022 21:05 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150 "2022-07-06T21:05:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanicoderrf](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nanicoderrf/32/1667_2.png) [@nanicoderrf](https://forum.robotframework.org/u/nanicoderrf)\
**Post date:** [6 July 2022 21:05 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/1 "2022-07-06T21:05:53Z")

</div>

\*\*\* 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}

---

<div class="post-metadata">

**Author:** ![nanicoderrf](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nanicoderrf/32/1667_2.png) [@nanicoderrf](https://forum.robotframework.org/u/nanicoderrf)\
**Post date:** [6 July 2022 21:10 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/2 "2022-07-06T21:10:02Z")

</div>

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

python -m robot device.robot

---

<div class="post-metadata">

**Author:** ![sunny09](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@sunny09](https://forum.robotframework.org/u/sunny09)\
**Post date:** [11 December 2023 03:34 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/3 "2023-12-11T03:34:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [11 December 2023 14:28 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/4 "2023-12-11T14:28:45Z")

</div>

Hi Sandeep,

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

You can have a [Suite directory](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-298) 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.

---

<div class="post-metadata">

**Author:** ![sunny09](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@sunny09](https://forum.robotframework.org/u/sunny09)\
**Post date:** [12 December 2023 02:06 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/5 "2023-12-12T02:06:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [12 December 2023 03:12 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/6 "2023-12-12T03:12:15Z")

</div>

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](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-286) there are 2 ways to do test templates

1. the method you’re probably using for Data Driver:

```python
***Settings***
Test Template Example keyword

```

1. applying a template to a test:

```python
***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.

---

<div class="post-metadata">

**Author:** ![sunny09](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@sunny09](https://forum.robotframework.org/u/sunny09)\
**Post date:** [12 December 2023 03:15 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/7 "2023-12-12T03:15:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [12 December 2023 03:35 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/8 "2023-12-12T03:35:37Z")

</div>

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](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-515) which is probably the opposite of what you want.

Dave.

---

<div class="post-metadata">

**Author:** ![divyab05](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@divyab05](https://forum.robotframework.org/u/divyab05)\
**Post date:** [20 November 2024 05:58 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/9 "2024-11-20T05:58:47Z")

</div>

How to execute 2 diffèrent testcase with 2 diff templates in same suite, Is it even possible

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [20 November 2024 07:34 UTC](https://forum.robotframework.org/t/how-to-execute-two-different-test-cases-one-with-template-and-another-one-just-a-random-test-case-in-a-robot-file/4150/10 "2024-11-20T07:34:26Z")

</div>

Hi Divya,

As i mentioned previously it’s all in the [Test templates](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-templates) documentation

The second example in [Templates with embedded arguments](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#templates-with-embedded-arguments) shows 3 templates being used in the one suite with 5 test cases:

```python
***Test Cases***
Different argument names
    [Template] The result of ${foo} should be ${bar}
    1 + 1 2
    1 + 2 3

Only some arguments
    [Template] The result of ${calculation} should be 3
    1 + 2
    4 - 1

New arguments
    [Template] The ${meaning} of ${life} should be 42
    result 21 * 2

```

Dave.
