Ride and Data Driven Tests

Here is an example of Data Driven Test with RIDE:

Test suite:

*** Settings ***
Test Template     Login with invalid credentials should fail
Library           Process
Variables         my_login_app_variables.py

*** Test Cases ***    USERNAME         PASSWORD
Invalid User Name     invalid          ${VALID PASSWORD}

Invalid Password      ${VALID USER}    invalid

Invalid User Name and Password
                      invalid          invalid

Empty User Name       ${EMPTY}         ${VALID PASSWORD}

Empty Password        ${VALID USER}    ${EMPTY}

Empty User Name and Password
                      ${EMPTY}         ${EMPTY}

*** Keywords ***
Login with invalid credentials should fail
    [Arguments]    ${username}    ${password}
    ${result}=    Run Process    python    ${CURDIR}/my_login_app.py    ${username}    ${password}
    Should Be True    ${result.stdout.startswith("Invalid")}

Variables file (my_login_app_variables.py):

# Variables definitions fot the Login app
VALID_PASSWORD = 'AV3RRys3cR3tPaAssWoiD'
VALID_USER = 'User'

Application under test (my_login_app.py):

# Simulates a Login app
import sys
from my_login_app_variables import VALID_PASSWORD, VALID_USER

def do_login(username:str, password:str):
        if  username == VALID_USER and password == VALID_PASSWORD:
            print(f"Authentication OK")
        else:
            print(f"Invalid Credentials")
            exit(255)
    
if __name__ == "__main__":
    try:
        do_login(sys.argv[1], sys.argv[2])
    except IndexError:
        print(f"Usage: python my_login_app.py  Username   Password")

Screenshot of RIDE Grid Editor:

Screenshot of RIDE Text Editor:

Example of Run:

1 Like