Changes between Version 1 and Version 2 of DeveloperGuidelines/Testing/EdenTest/WriteTestcase/Advanced


Ignore:
Timestamp:
06/06/14 19:30:16 (10 years ago)
Author:
Arnav Sharma
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Testing/EdenTest/WriteTestcase/Advanced

    v1 v2  
    107107Note: `*** Settings ***`, `*** Variables ***` sections stay as it is.
    108108
     109== Data driven testing ==
     110
     111=== What is Data-Driven testing? ===
     112Data-driven approach to testing is where test cases use only one higher-level keyword, normally created as a user keyword (as shown above), that hides the actual test workflow. These tests are very useful when there is a need to test the same scenario with different input and/or output data. It would be possible to repeat the same keyword with every test, but the test template functionality allows specifying the keyword to use only once. Thus, a testsuite file will run the same Test template with a lot of test data, each of which will be a testcase. Example follows.
     113
     114
     115=== Using Data-Driven Testing ===
     116Now, testing the login functionality with various permutations of email and password can be done using the Data-driven approach. Here is how:
     117
     118{{{
     119*** Settings ***
     120Documentation       Test case to check the login functionality of Eden
     121Library     Selenium2Library
     122Variables         ../../execution/config.py
     123Test Teardown       Close Browser
     124Test Template   Login should fail
     125
     126
     127*** Variables ***
     128${LOGIN URL}        http://${SERVER}/eden/default/user/login
     129${SUBMIT}       xpath=//input[@class='btn' and @value='Login']
     130${EMAIL ID}        auth_user_email
     131${PASSWORD ID}     auth_user_password
     132
     133
     134*** Keywords ***
     135Login with email and passwd
     136    [Documentation]      Opens a browser to login url, inputs username and password
     137    [Arguments]     ${email}    ${passwd}
     138    Open Browser        ${LOGIN URL}
     139    Input Text      ${EMAIL ID}     ${email}
     140    Input Text      ${PASSWORD ID}      ${passwd}
     141    Click Button        ${SUBMIT}
     142
     143Login should fail
     144    [Documentation]      Opens a browser to login url, inputs invalid username or password and checks for failure
     145    [Arguments]     ${email}    ${passwd}
     146    Login with email and passwd         ${email}    ${passwd}
     147    Page Should Contain     Invalid login
     148
     149
     150*** Test Cases ***                          email                         password
     151The email is invalid        nottheadmin@example.com        testing
     152The password is Invalid     admin@example.com              incorrect
     153Both are Invalid                nottheadmin@example.com     incorrect
     154}}}
     155
     156There are three test cases above, all of which implement the keyword `Login should fail` given against the setting `Test Template`. All the testcases implement the keyword with the arguments given against it.  The keyword `Login should fail` takes two arguments and asserts that the login should fail for that case. Run the tests and
     157
     158=== Further exercise ===
     159As an exercise, implement these two tests in a separate file
     160* Login form validation
     161* Login should pass [email] [password]