Version 1 (modified by Arnav Sharma, 10 years ago) ( diff )


Writing testcases for EdenTest

The F.I.R.S.T principle of Test Driven Development

  • Fast: run (subset of) tests quickly (since you'll be running them all the time)
  • Independent: no tests depend on others, so can run any subset in any order
  • Repeatable: run N times, get same result (to help isolate bugs and enable automation)
  • Self-checking: test can automatically detect if passed (no human checking of output)
  • Timely: written before writing the code

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.

How to write good testcases?

Before beginning to write a testcase, please go through the article 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.

Writing a testcase for EdenTest

Before 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 EdenTest.

Here 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

What we have to do?

So, our testcase needs to do the following

  1. Go to eden/hrm/staff/create
  2. Select an organisation from dropdown list National Society / Branch.
  3. Input text into the person name field
  4. Input text into the person email field
  5. Submit the CRUD form
  6. Check for confirmation message

Adding variables

Before we write the testcase, we should assign variables to the link we are going to visit, ids we are going to use etc.

Inside the variables section of the testsuite file, indicated by *** Variables *** add the variables as

variable name [delimited by two tabs/8 spaces] id/url/etc .
For ex:

${StaffCreateUrl}       ${STAFF URL}/create  #${STAFF URL} already exists
${HrmOrgSelector}       hrm_human_resource_organisation_id  #Selector for the dropdown list National Society / Branch.
${PersonNameField}      hrm_human_resource_person_id_full_name #ID of Name field
${PersonEmailField}     hrm_human_resource_person_id_email #ID of email field

Writing the test case

Add this to the *** Test Cases *** section of the testsuite file.

Create Staff
    Go To  ${StaffCreateUrl}
    Select From List By Label  ${HrmOrgSelector}  Indian Red Cross Society
    Input Text  ${PersonNameField}  Fname Lname
    Input Text  ${PersonEmailField}
    Submit CRUD Form
    Should Show Confirmation

Note: Please make sure that the various arguments are separated by two spaces.

Compare 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

pybot tests/implementation/testsuites

Open report.html to see the outcome.

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

To understand the selenium keywords visit Selenium2Library Keyword Documentation and the documentation of keywords implemented under EdenTest in tests/docs

Note: See TracWiki for help on using the wiki.