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



Testing is not about finding and fixing defects in the code - it's about preventing them from being introduced into the code the first place.

EdenTest is a Robot Framework based testsuite used for automated testing in Sahana Eden. The project was initiated by Redsin as EdenTest. It is located in the eden codebase under directory eden/tests.

About Robot Framework

Robot Framework is a Python-based, extensible keyword-driven (keywords are methods in Robot Framework) test automation framework used for testing. It provides many features that make writing tests, reading their results and finding errors hassle free. Some of its key features are:

  • Enables easy-to-use tabular syntax for creating test cases in a uniform way.
  • Provides ability to create reusable higher-level keywords from the existing keywords.
  • Provides easy-to-read result reports and logs in HTML format.
  • Is platform and application independent.

Installation guidelines

EdenTest requires three python packages.

All four packages mentioned above are available with two most commonly used python package installation tools, namely, pip and easy_install.

Installation using pip

pip install robotframework
pip install robotframework-selenium2library
pip install robotframework-databaselibrary
pip install requests

Installation using easy_install

easy_install robotframework
easy_install robotframework-selenium2library
easy_install robotframework-databaselibrary
easy_install requests

If you have successfully installed the packages, you should be able to run EdenTest. If for some reason, you can not install the packages using either of the two methods mentioned above, please visit the three links given above. Manual install instructions for each package are given there.

You can also run the script inside /tests/ to install all the dependencies.

Directory structure

Before running EdenTest, it is important to have a mental picture of the directory structure of EdenTest and the importance of its sub-directories.

├── docs
│   ├── auth.html
 |     ...
│   ├── main.html
│   └── widgets.html
├── execution
│   ├── libs
│   │   ├──
│   │   └──
│   └── settings
│       ├──
│       └──
└── implementation
    ├── libs
    ├── resources
    │   ├── auth.txt
     |     ...
    │   ├── main.txt
    │   └── widgets.txt
    └── testsuites
        ├── __init__.txt
        ├── hrm
        │   └── human_resource.txt
        ├── ...
        └── project
            ├── project_project.txt

We distinguish between the implementation and the execution of the tests.

  • docs: It contains the documentation of keywords in html format. The name of the file is same as the keyword file present in resources sub-directory. The documentation is extracted from the text written next to the [Documentation] setting below the keyword definition.
  • execution: Execution directory contains two sub folders, settings and libs. settings contains the settings local to your system to run the tests. It has a file using which file is created. is not under version control. It has settings variables like server address, valid username, valid password etc. libs contains the python library files that created for EdenTest eg: It might be also used to store ready-made libraries to ensure they are kept stable for example the selenium2library.
  • implementation: It contains the implementation aspects.
    • resources: It is imperative from a test-design point of view to have higher-level keywords. These are kept in the resource files. The keywords are stored in a file as per the function they serve for eg: Keyword Login To Eden is kept in auth.txt.
      • main.txt: It is the center resource file. All the resource files like auth.txt, settings like are imported in this file. Further, this file is imported in the tests.
    • testsuites: Testsuites directory contains all the different testsuites differentiated based on the basis of functionality they test eg: hrm. Inside each testcase, there is at least one .txt file which contains the testcases.

Using EdenTest

Start Sahana Eden

  1. Make sure your have Sahana Eden running.
  1. Populate the database

Delete the contents of databases/* , errors/* and sessions/* in your eden directory.

E.g. for Linux, cd to your eden directory and do:

 rm databases/* sessions/* errors/*

On Windows, use Explorer to delete the contents of the eden\databases, eden\errors, and eden\sessions folders.

To re-populate the database, for either Linux or Windows (using a command prompt window), cd to the web2py directory, and do:

python -S eden -M -R applications/eden/static/scripts/tools/


Before running the tests, there has to exist a file inside the execution directory. It contains the various settings variables that are imported by EdenTest. Copy the into by [assuming the current working directory is /tests/]

cp execution/settings/ execution/settings/

Edit the file according to your requirements.

Changes made to the in the main branch would not be reflected in your file locally. So, a possible point of error could that you have a stale file. Check to see if you have an updated file.

Running EdenTest

EdenTest testcases are run from the command line. They are run from inside web2py. The command used to run the tests is python --no-banner -M -S eden -R applications/eden/tests/ -A <name of the testsuite>. All the command line arguments to EdenTest are given after -A argument. Give it --help to know about more command line options.

The end result is, by default, an output file in XML format and an HTML report and a log. These three files are created in the current working directory by default.

  • report.html: Report files contain an overview of the test execution results in HTML format. They have statistics based on tags and executed test suites, as well as a list of all executed test cases. When both reports and logs are generated, the report has links to the log file for easy navigation to more detailed information. It is easy to see the overall test execution status from report, because its background color is green, if all critical tests pass, and bright red otherwise.
  • log.html: Log files contain details about the executed test cases in HTML format. They have a hierarchical structure showing test suite, test case and keyword details. Log files are needed nearly every time when test results are to be investigated in detail. Even though log files also have statistics, reports are better for getting an higher-level overview.
  • output.xml: Output files contain all the test execution results in machine readable XML format.

Some common usages

[Assuming the current working directory is the location of web2py]

  • Run all the testsuites
    python --no-banner -M -S eden  -R applications/eden/tests/ #no argument
    ython --no-banner -M -S eden  -R applications/eden/tests/ -A testsuites #testsuites folder as argument

This will run all the testsuites found under the testsuites folder.

  • Run a specific testsuite file. Just give the name of the file present inside the testsuites folder as an argument. eg: hrm
    python --no-banner -M -S eden  -R applications/eden/tests/ -A hrm
  • Change the execution speed of selenium
    python --no-banner -M -S eden  -R applications/eden/tests/ -A hrm --variable DELAY:10 

Similarly, other variables like BASEURL, HOMEPAGE etc can be manipulated from the command line. -V flag can be used to give a path of a file containing a list of variables. The format of the file should be similar to

  • Run a specific testcase
    python --no-banner -M -S eden  -R applications/eden/tests/ -A org -t Create_Organisation 

-t flag is used to select the testcase.

  • Run a specific testsuite
    python --no-banner -M -S eden  -R applications/eden/tests/ -A hrm
    -s flag is disabled in EdenTest
  • Change the output directory
    python --no-banner -M -S eden  -R applications/eden/tests/ -A hrm -d [path to the directory] 

To read the results after running the tests, open report.html in your browser.

Writing a testcase

Please see the tutorial How to write a testcase for EdenTest?

For more advanced usage, please refer to Advanced Test Design.

Note: See TracWiki for help on using the wiki.