robotframeworkdata-driven-tests

Data driven test cases on robot framework


I have found many cases where described how can be executed some test case with data range inside, but I need create separated test cases based on some array.

For example I have a boxes range on which I need check some scenarios:

In all cases login, password, test command would be the same. One difference - IP\Computername.

Now it is look like this, and for me it's look strange when VM count > 10:

*** Settings ***
Library     SSHLibrary
Library     OperatingSystem
Library     String

*** Variable ***
${HOST}
${USERNAME}
${PASSWORD}

*** Test Case ***
Logging-into-VM1
    Open Connection And Log In     ${VM1}
Executing-Commands-on-VM1
    Executing commands

Logging-into-VM2
    Open Connection And Log In     ${VM2}
Executing-Commands-on-VM2
    Executing commands

.....

Logging-into-VMn
    Open Connection And Log In     ${VMn}
Executing-Commands-on-VMn
    Executing commands


*** Keywords ***
Open Connection And Log In
    [Arguments]     ${BOX}
    Open Connection     ${BOX}
    Login               ${USERNAME}     ${PASSWORD}
Executing commands
    ${testcmd}=     Execute Command     echo 'Hello world'

In this case I receive correct output, but it's strange for me use Copy\Paste method for tests if their more than 10 (example if I need test 100 VM's i need write 400 strings with 1 difference for every 4 strings)

If i tries execute something like that (which looks much better for me):

*** Settings ***
Library     SSHLibrary
Library     OperatingSystem
Library     String

*** Variable ***
${USERNAME}
${PASSWORD}

*** Test Case ***

Logging and commands executes
    [Template]    Conectivity tests {BOX}
    ${VM1}
    ${VM2}
    ${VM3}
    ....    
    ${VMn}


*** Keywords ***

Conectivity tests
    [Arguments]     ${BOX}
    Open Connection     ${BOX}
    Login               ${USERNAME}     ${PASSWORD}
    ${hostname}=     Execute Command    hostname

I get only one test case with non informal result:

=================================================================
ttestcase12
=================================================================
Logging and commands executes                            | FAIL |
Several failures occurred:

1) timeout: timed out

2) timeout: timed out

3) timeout: timed out

4) timeout: timed out

5) timeout: timed out

6) timeout: timed out

7) timeout: timed out
------------------------------------------------------------------
ttestcase12                                               | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed

I receive this "great" result, looking on which I do not understand what was passed, and what not

This sample looks much better:

*** Settings ***
Library          SSHLibrary
Library          OperatingSystem
Library          String
Test Template    Conectivity tests

*** Variable ***
${USERNAME}
${PASSWORD}

*** Test Cases ***          BOX

Conectivity tests VM1       ${VM1}
Conectivity tests VM2       ${VM2}
Conectivity tests VM3       ${VM3}

....

Conectivity tests VMn       ${VMn}

*** Keywords ***

Conectivity tests
    [Arguments]       ${BOX}
    Open Connection   ${BOX}
    Login             ${USERNAME}     ${PASSWORD}
    ${hostname}=      Execute Command     hostname





====================================================================
ttestcase12
====================================================================
Conectivity tests VM1                                       | FAIL |
timeout: timed out
--------------------------------------------------------------------
Conectivity tests VM2                                       | PASS |
--------------------------------------------------------------------
Conectivity tests VM3                                       | FAIL |
timeout: timed out
--------------------------------------------------------------------
Conectivity tests VM4                                       | FAIL |
timeout: timed out

.....

--------------------------------------------------------------------
Conectivity tests VMn                                       | FAIL |
timeout: timed out
--------------------------------------------------------------------
Sanityv8                                                    | FAIL |
99 critical tests, 12 passed, 87 failed
99 tests total, 12 passed, 87 failed

Also all of this scenarios require different test suites for example if in some case I need test 99 VMs and sometimes 100 (which include previous 99)...

I want once more time akcent that I need separate tests (with separate results PASS\FAIL) instead loop in one test case

Link on similar question but without answer: In Robot Framework, how to perform data-driven testing by creating a separate test case for each line of data in a text file?

Links with scenarios stored in one test case (not the same that I need): http://www.thinkpalm.com/blogs/data-driven-testing-robot-framework/


Solution

  • So for now solution was found in python: