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


Ignore:
Timestamp:
05/14/14 02:51:15 (11 years ago)
Author:
Arnav Sharma
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Testing/EdenTest

    v1 v1  
     1= ROBOTEDEN =
     2[[TOC]]
     3
     4!RobotEden is a Robot Framework based testsuite used for automated testing in Sahana Eden. The project was initiated by Redsin as [https://github.com/nerdis/edentest EdenTest]. It is located in the eden codebase under directory '''eden/tests'''.
     5
     6== About Robot Framework ==
     7
     8[http://robotframework.org/ 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.
     13
     14== Installation guidelines ==
     15
     16!RobotEden requires three python packages.
     17
     18* [https://code.google.com/p/robotframework/wiki/Installation robotframework]
     19* [https://github.com/rtomac/robotframework-selenium2library robotframework-selenium2library]
     20* [http://franz-see.github.io/Robotframework-Database-Library/ robotframework-databaselibrary]
     21
     22All the three packages mentioned above are available with two most commonly used python package installation tools, namely, [http://pip.readthedocs.org/en/latest/installing.html pip] and [https://pypi.python.org/pypi/setuptools easy_install].
     23
     24=== Installation using pip ===
     25
     26{{{
     27pip install robotframework
     28pip install robotframework-selenium2library
     29pip install robotframework-databaselibrary
     30}}}
     31
     32=== Installation using easy_install ===
     33
     34{{{
     35easy_install robotframework
     36easy_install robotframework-selenium2library
     37easy_install robotframework-databaselibrary
     38}}}
     39
     40If you have successfully installed the packages, you should be able to run !RobotEden.
     41
     42== Using !RobotEden ==
     43
     44
     45
     46Before running !RobotEden, it is important to have a mental picture of the directory structure of !RobotEden and the importance of its sub-directories.
     47
     48=== Directory structure ===
     49{{{
     50/tests
     51├── docs
     52│   ├── auth.html
     53 |     ...
     54│   ├── main.html
     55│   └── widgets.html
     56├── execution
     57│   ├── config.example.py
     58│   └── config.py
     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        ├── ...
     71                 
     72        └── project
     73            ├── project_project.txt
     74            └── variables.py
     75
     76
     77}}}
     78We distinguish between the implementation and the execution of the tests.
     79
     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 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.
     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 config.py 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.
     87
     88=== Start Sahana Eden ===
     891. Make sure your have Sahana Eden running.
     90
     912. Populate the database
     92
     93   Delete the contents of databases/* , errors/* and sessions/* in your eden directory.
     94
     95   E.g. for Linux, cd to your eden directory and do:
     96   {{{
     97    rm databases/* sessions/* errors/*
     98   }}}
     99
     100   On Windows, use Explorer to delete the contents of the eden\databases, eden\errors, and eden\sessions folders.
     101
     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 web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
     105   }}}
     106
     107=== Creating config.py ===
     108Before 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
     109[assuming the current working directory is /tests/]
     110{{{
     111cp execution/config.example.py execution/config.py
     112}}}
     113Edit the config.py file according to your requirements.
     114
     115
     116=== Running !RobotEden ===
     117
     118Robot Framework test cases are executed from the command line. The command used to run the tests is [http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.4#all-command-line-options pybot]. The link redirects to the wiki where the command line arguments are documented. You can also use `pybot --help` for the same.
     119
     120The end result is, by default, an [http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.4#output-file output file] in XML format and an HTML [http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.4#report-file report] and a [http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.4#log-file log]. These three files are created in the current working directory by default.
     121
     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.
     123
     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.
     126
     127
     128'''Most common usage'''
     129
     130[Assuming the current working directory is /tests]
     131
     132* Run all the testsuites
     133{{{
     134pybot implementation/testsuites
     135}}}
     136   This will run all the testsuites found under the testsuites folder.
     137
     138* Run a specific testsuite file
     139{{{
     140pybot implementation/testsuites/hrm/human_resource.txt
     141}}}
     142* Change the execution speed of selenium
     143{{{
     144pybot --variable DELAY:10 implementation/testsuites
     145}}}
     146
     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 '''config.py'''.
     148* Run a specific testcase
     149{{{
     150pybot -t Create_Organisation implementation/testsuites
     151}}}
     152   `-t` flag is used to select the testcase.
     153
     154* Run a specific testsuite
     155{{{
     156pybot -s project_project implementation/testsuites
     157}}}
     158  `-s` flag is used to select the testsuite.
     159
     160* Change the output directory
     161{{{
     162pybot -d [path to the directory] implementation/testsuites
     163}}}
     164
     165
     166To read the results after running the tests, open ''report.html'' in your browser.
     167