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

05/14/14 02:51:15 (8 years ago)
Arnav Sharma



  • DeveloperGuidelines/Testing/EdenTest

    v1 v1  
     1= ROBOTEDEN =
     4!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'''.
     6== About Robot Framework ==
     8[ 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:
     9* Enables easy-to-use tabular syntax for creating test cases in a uniform way.
     10* Provides ability to create reusable higher-level keywords from the existing keywords.
     11* Provides easy-to-read result reports and logs in HTML format.
     12* Is platform and application independent.
     14== Installation guidelines ==
     16!RobotEden requires three python packages.
     18* [ robotframework]
     19* [ robotframework-selenium2library]
     20* [ robotframework-databaselibrary]
     22All the three packages mentioned above are available with two most commonly used python package installation tools, namely, [ pip] and [ easy_install].
     24=== Installation using pip ===
     27pip install robotframework
     28pip install robotframework-selenium2library
     29pip install robotframework-databaselibrary
     32=== Installation using easy_install ===
     35easy_install robotframework
     36easy_install robotframework-selenium2library
     37easy_install robotframework-databaselibrary
     40If you have successfully installed the packages, you should be able to run !RobotEden.
     42== Using !RobotEden ==
     46Before running !RobotEden, it is important to have a mental picture of the directory structure of !RobotEden and the importance of its sub-directories.
     48=== Directory structure ===
     51├── docs
     52│   ├── auth.html
     53 |     ...
     54│   ├── main.html
     55│   └── widgets.html
     56├── execution
     57│   ├──
     58│   └──
     59└── implementation
     60    ├── libs
     61    ├── resources
     62    │   ├── auth.txt
     63     |     ...
     64    │   ├── main.txt
     65    │   └── widgets.txt
     66    └── testsuites
     67        ├── __init__.txt
     68        ├── hrm
     69        │   └── human_resource.txt
     70        ├── ...
     72        └── project
     73            ├── project_project.txt
     74            └──
     78We distinguish between the implementation and the execution of the tests.
     80* '''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.
     81* '''execution''': Execution directory 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.
     82* '''implementation''': It contains the implementation aspects.
     83 * '''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.
     84 * '''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'''.
     85  * '''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.
     86 * '''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.
     88=== Start Sahana Eden ===
     891. Make sure your have Sahana Eden running.
     912. Populate the database
     93   Delete the contents of databases/* , errors/* and sessions/* in your eden directory.
     95   E.g. for Linux, cd to your eden directory and do:
     96   {{{
     97    rm databases/* sessions/* errors/*
     98   }}}
     100   On Windows, use Explorer to delete the contents of the eden\databases, eden\errors, and eden\sessions folders.
     102   To re-populate the database, for either Linux or Windows (using a command prompt window), cd to the web2py       directory, and do:
     103   {{{
     104   python -S eden -M -R applications/eden/static/scripts/tools/
     105   }}}
     107=== Creating ===
     108Before running the tests, there has to exist a '''''' file inside the execution directory. It contains the various settings variables that are imported by RobotEden. Copy the into by
     109[assuming the current working directory is /tests/]
     111cp execution/ execution/
     113Edit the file according to your requirements.
     116=== Running !RobotEden ===
     118Robot 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.
     120The 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.
     122 * '''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.
     124 * '''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.
     125 * '''output.xml''': Output files contain all the test execution results in machine readable XML format.
     128'''Most common usage'''
     130[Assuming the current working directory is /tests]
     132* Run all the testsuites
     134pybot implementation/testsuites
     136   This will run all the testsuites found under the testsuites folder.
     138* Run a specific testsuite file
     140pybot implementation/testsuites/hrm/human_resource.txt
     142* Change the execution speed of selenium
     144pybot --variable DELAY:10 implementation/testsuites
     147   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 ''''''.
     148* Run a specific testcase
     150pybot -t Create_Organisation implementation/testsuites
     152   `-t` flag is used to select the testcase.
     154* Run a specific testsuite
     156pybot -s project_project implementation/testsuites
     158  `-s` flag is used to select the testsuite.
     160* Change the output directory
     162pybot -d [path to the directory] implementation/testsuites
     166To read the results after running the tests, open ''report.html'' in your browser.