0

How to create a data-driven test using robotframework based on the following:

  • test data are stored in a separate text file.
  • the test data file contains test data for multiple testsuites.
  • common keywords are store in a resource file.

    This is my first time to create a data-driven test using robotframework, I have no clue how to do it. I've read robotframework documentations but none of it give a clear explanation on how to do it.

    Thanks...

  • 1 Answers1

    -2

    A simple example is:

    testData.py:

    TESTVAR = "test"
    THETEXT = "I am stored text" 
    

    testResource.txt

    *** Settings ***
    
    Documentation    An example resource file!
    
    Variables    testData.py
    
    *** Keywords ***
    
    Test Keyword
        Run Keyword If    '${TESTVAR}' == 'test'    Log To Console    ${THETEXT}
    

    Test_Suite_1.txt

    *** Settings ***
    
    Documentation    An example test suite!
    
    Resource    testResource.txt
    
    *** Test Cases ***
    
    First Test
        Log    This is my first test!
        Test Keyword
    

    Hope this helps!

    Zenon Buratta
    • 200
    • 1
    • 2
    • 13
    • Your code has incorrect syntax. You're mixing spaces and pipes. For robot to use pipes, the first character on a line needs to be a pipe – Bryan Oakley Oct 28 '14 at 18:20
    • Thanks, this is exactly what I needed. - Based on the example above is it possible to create a testData.txt rather than testData.py? - Where should I save all these files so that I will be able run the testcases? – splongplang Oct 30 '14 at 22:31
    • Erm I have no idea about the .txt you would have to try it, the documentation doesnt confirm or deny it. For the test above you would save all the files in the same folder – Zenon Buratta Oct 31 '14 at 16:42