|Version 2 (modified by 8 years ago) ( diff ),|
Table of Contents
RobotEden 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.
RobotEden requires three python packages.
Installation using pip
pip install robotframework pip install robotframework-selenium2library pip install robotframework-databaselibrary
Installation using easy_install
easy_install robotframework easy_install robotframework-selenium2library easy_install robotframework-databaselibrary
If you have successfully installed the packages, you should be able to run RobotEden.
Before running RobotEden, it is important to have a mental picture of the directory structure of RobotEden and the importance of its sub-directories.
/tests ├── docs │ ├── auth.html | ... │ ├── main.html │ └── widgets.html ├── execution │ ├── config.example.py │ └── config.py └── implementation ├── libs ├── resources │ ├── auth.txt | ... │ ├── main.txt │ └── widgets.txt └── testsuites ├── __init__.txt ├── hrm │ └── human_resource.txt ├── ... └── project ├── project_project.txt └── variables.py
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 the settings local to your system to run the tests. It has a file config.example.py using which config.py file is created. config.py is not under version control. It has settings variables like server address, valid username, valid password etc.
- implementation: It contains the implementation aspects.
- libs: This will be used to check-in Eden specific test libraries implemented in python, but it might be also used to store ready-made libraries to ensure they are kept stable for example the selenium2library.
- 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 Edenis kept in auth.txt.
- main.txt: It is the center resource file. All the resource files like auth.txt, settings like config.py 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.
Start Sahana Eden
- Make sure your have Sahana Eden running.
- 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 web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
Before running the tests, there has to exist a config.py file inside the execution directory. It contains the various settings variables that are imported by RobotEden. Copy the config.example.py into config.py by [assuming the current working directory is /tests/]
cp execution/config.example.py execution/config.py
Edit the config.py file according to your requirements.
Robot Framework test cases are executed from the command line. The command used to run the tests is pybot. The link redirects to the wiki where the command line arguments are documented. You can also use
pybot --help for the same.
- 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 /tests]
- Run all the testsuites
This will run all the testsuites found under the testsuites folder.
- Run a specific testsuite file
- Change the execution speed of selenium
pybot --variable DELAY:10 implementation/testsuites
Similarly, other variables like BASEURL, HOMEPAGE etc can be manipulated from the command line.
-Vflag can be used to give a path of a file containing a list of variables. The format of the file should be similar to config.py.
- Run a specific testcase
pybot -t Create_Organisation implementation/testsuites
-tflag is used to select the testcase.
- Run a specific testsuite
pybot -s project_project implementation/testsuites
-sflag is used to select the testsuite.
- Change the output directory
pybot -d [path to the directory] implementation/testsuites
To read the results after running the tests, open report.html in your browser.