Changes between Initial Version and Version 1 of DeveloperGuidelines/Testing/EdenTest/WriteTestcase


Ignore:
Timestamp:
05/22/14 17:52:56 (11 years ago)
Author:
Arnav Sharma
Comment:

--

Legend:

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

    v1 v1  
     1= Writing testcases for !EdenTest =
     2[[TOC]]
     3== The F.I.R.S.T principle of Test Driven Development ==
     4* '''Fast''': run (subset of) tests quickly (since you'll be running them all the time)
     5* '''Independent''': no tests depend on others, so can run any subset in any order
     6* '''Repeatable''': run N times, get same result (to help isolate bugs and enable automation)
     7* '''Self-checking''': test can automatically detect if passed (no human checking of output)
     8* '''Timely''': written before writing the code
     9
     10!EdenTest has been written using these principles. Whenever using EdenTest to create a new testcase, it is imperative to make sure that '''F.I.R.S.T''' mantra is followed.
     11
     12== How to write good testcases? ==
     13Before beginning to write a testcase, please go through the article [https://code.google.com/p/robotframework/wiki/HowToWriteGoodTestCases How to write good testcases for Robot Framework?]. It is a short and descriptive article that will help you a great deal to write precise and useful testcases.
     14
     15== Writing a testcase for !EdenTest ==
     16
     17Before writing your first testcase, please make sure that you have !EdenTest set up, you understand the directory structure and the know-how of how to run !EdenTest and see its results. If not, go through [http://eden.sahanafoundation.org/wiki/DeveloperGuidelines/EdenTest EdenTest].
     18
     19Here is a description of how to write a testcase in !EdenTest. Say for example, we want to test if a new staff member can be added or not. As the functionality is under hrm, open the testsuite file ''/tests/implementation/testsuites/hrm/human_resource.txt''. If the functionality to be tested does not fall under any  of the existing testsuites (eg hrm, projects etc), create a new folder/file under '''/tests/implementation/testsuites'''
     20
     21=== What we have to do? ===
     22
     23So, our testcase needs to do the following
     24
     251. Go to ''eden/hrm/staff/create''
     262. Select an organisation from dropdown list National Society / Branch.
     273. Input text into the person name field
     284. Input text into the person email field
     295. Submit the CRUD form
     306. Check for confirmation message
     31
     32=== Adding variables ===
     33
     34Before we write the testcase, we should assign variables to the link we are going to visit, ids we are going to use etc.
     35
     36Inside the variables section of the testsuite file, indicated by `*** Variables ***` add the variables as
     37[[BR]]
     38
     39''' variable name [delimited by two tabs/8 spaces] id/url/etc '''.
     40[[BR]]
     41For ex:
     42{{{
     43${StaffCreateUrl}       ${STAFF URL}/create  #${STAFF URL} already exists
     44${HrmOrgSelector}       hrm_human_resource_organisation_id  #Selector for the dropdown list National Society / Branch.
     45${PersonNameField}      hrm_human_resource_person_id_full_name #ID of Name field
     46${PersonEmailField}     hrm_human_resource_person_id_email #ID of email field
     47}}}
     48
     49=== Writing the test case ===
     50
     51Add this to the `*** Test Cases ***` section of the testsuite file.
     52
     53{{{
     54Create Staff
     55    Go To  ${StaffCreateUrl}
     56    Select From List By Label  ${HrmOrgSelector}  Indian Red Cross Society
     57    Input Text  ${PersonNameField}  Fname Lname
     58    Input Text  ${PersonEmailField}  flname@email.com
     59    Submit CRUD Form
     60    Should Show Confirmation
     61}}}
     62
     63Note: Please make sure that the various arguments are separated by two spaces.
     64[[BR]]
     65[[BR]]
     66
     67Compare the section '''What we have to do?''' and the testcase written above and marvel the beauty of Robot Framework. Run the testcase using the command
     68
     69{{{
     70pybot tests/implementation/testsuites
     71}}}
     72
     73Open '''report.html''' to see the outcome.
     74
     75
     76`Go To`, `Select From List By Label`, `Input Text`, `Submit CRUD Form` and `Should Show Confirmation` are all keywords imported using '''main.txt''' in the `*** Settings ***` section which in turn imports all the keyword files. If your use case requires a keyword that does not exist, create one under  '''/tests/implementation/resources''
     77
     78
     79To understand the selenium keywords visit [http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html Selenium2Library Keyword Documentation] and the documentation of keywords implemented under !EdenTest in '''tests/docs'''