1

I have created some test cases using the data-driven style testing.

But when attaching the Test Setup/Teardown to the Setting section, both the setup and teardown runs before and after the testing all the data sets.

Robot

*** Settings ***
Test Setup  setup
Test Teardown  teardown

*** Keywords ***

Test Case Should Pass
    [Arguments]  ${arg1}  ${arg2}  ${arg3}
    something "${arg1}"
    something "${arg2}"
    something "${arg3}"

something "${arg}"
    Log To Console  ${arg}

setup
    Log To Console  setup

teardown
    Log To Console  teardown

*** Test Case ***

Test Case
    [Template]  Test Case Should Pass
    a1  a2  a3
    b1  b2  b3

Actual

==============================================================================
Something
==============================================================================
Test Case                                                             setup
.a1
a2
a3
.b1
b2
b3
.teardown
Test Case                                                             | PASS |
------------------------------------------------------------------------------
Something                                                             | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================

Expected

==============================================================================
Something
==============================================================================
Test Case                                                             setup
.a1
a2
a3
teardown
setup
.b1
b2
b3
.teardown
Test Case                                                             | PASS |
------------------------------------------------------------------------------
Something                                                             | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================

Are there any way that I can have the Setup/Teardown to be executed in between each data set tested?

1 Answer 1

1

This would work:

*** Settings ***
Test Setup  setup
Test Teardown  teardown
Test Template  Test Case Should Pass

*** Keywords ***

Test Case Should Pass
    [Arguments]  ${arg1}  ${arg2}  ${arg3}
    something "${arg1}"
    something "${arg2}"
    something "${arg3}"

something "${arg}"
    Log To Console  ${arg}

setup
    Log To Console  setup

teardown
    Log To Console  teardown

*** Test Case ***
A
    a1  a2  a3
B
    b1  b2  b3
Sign up to request clarification or add additional context in comments.

2 Comments

I have tried this approach as well. But I was hoping that it can be achieved without having to put them under different test cases.
Me too, however, it's not possible to use [Setup] in the template keyword, so it has to be introduced as a regular keyword as the first step of the template or do like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.