Robot with FakerLibrary

With this short example Iäm going to show one way to regression test your system with faked data. With Robot Framework, you are able to use library called FakerLibrary to create faked/seeded data.

Why test with fake/seeded data?

Normally users might know very well how the system works and what kind of data to input. However, as import is that the system works with known data, it is important test also faked data or seeded data. This might not be as important test cases, but in order to test that the system responses right is should response, with faked/seeded data we might find new type of issues. For example, we could find out some input fields accept data that they should not accept and we could also find out that the randomized data breaks some functionalities that did not happen with known data cases.

However, these kind of test depends much about the application interface, module or the system where these test are runned. In addition the features life-cycle might also be considered, should the faked/seeded data be tested in unit test, regression or in acceptance testing. Also one should bare in mind that not everything must be fake/seeded data tested nor needed to be.

Short sample suite

*** Settings ***
Library    Selenium2Library   timeout=3.0  implicit_wait=1.0 
Library    FakerLibrary    locale=en_US

Suite Setup    Set browser and go to page
Suite Teardown    Close All Browsers

*** Variables ***
${browser}    chrome
${Url}    http://www.google.com

*** Test Cases ***

Scenario: Go to google and Search random text
    Given input random text for google search
    then results should be visible
    
*** Keywords ***
Set browser and go to page
    Open Browser    ${Url}    browser=${browser}
    
input random text for google search
    ${words} =  Text    20
    Log    ${words}
    Set Suite Variable    ${words}    
    Input Text    name=q    ${words}
    Press Key    name=q     \\13   
    
results should be visible
    Page Should Contain    ${words}    

So in this example we are going to Google and search with randomized words. So how could you use this in your own tests? With selenium library test cases, you could try to insert valid and invalid data and see if the system responses like it should be. For example, this also could be used to test login in to systems. Another one could be that if the system accepts files or uses files data, one could first create fake/seeded data file and then try to upload it to system and see if the results happen. This might be a bit problematic, if there is actual logic with the data or the file data needs to be machine-readable format.