Difference between revisions of "Automated Testing"

From Rosalab Wiki
Jump to: navigation, search
(Created a stub of the page)
 
(Prepared the common part of the docs)
Line 5: Line 5:
 
The source code: https://abf.rosalinux.ru/spectre/rosa-autotest/
 
The source code: https://abf.rosalinux.ru/spectre/rosa-autotest/
  
The system is build upon [http://docs.python.org/2.7/library/unittest.html Python unit testing framework]. Besides that, the system includes a modified version of [https://wiki.ubuntu.com/Xpresser Xpresser tool].
+
The system is build upon [http://docs.python.org/2.7/library/unittest.html Python unit testing framework], Python 2.7 is needed. Besides that, the system includes a modified version of [https://wiki.ubuntu.com/Xpresser Xpresser tool].
  
 
= Testing GUI Applications =
 
= Testing GUI Applications =
 +
 +
The tests for GUI applications may run in two different modes in our system:
 +
* A test runs locally, that is, on the same machine where the application under test is running. This mode is more suitable during the development and debugging of the tests. It can also be used for testing the applications on the real hardware.
 +
* A test operates on the applications that run on a different (usually, virtual) machine. This is convenient for automated runs of the testing system to check the new builds of the distro. Besides, it is possible to check the boot and installation of the OS in this mode, as well as other things that are difficult to check if the tests run locally.
 +
 +
The tests for the applications in the installed OS should usually be written so that they could run in both modes. If the test uses only Python unittest API and the API provided by our system, this will be achieved automatically.
 +
 +
== Testing Applications Running on a Separate Machine ==
 +
 +
''Note. For most developers, it will likely be more convenient to run the tests locally instead (see below).''
 +
 +
Setup instructions for the software needed for this mode are available here: https://abf.rosalinux.ru/spectre/rosa-autotest/tree/master/doc
 +
 +
The following script runs the whole test suite: [https://abf.rosalinux.ru/spectre/rosa-autotest/blob/master/rosa_autotest/launcher.py launcher.py]
 +
 +
== Testing Applications Locally ==
 +
 +
Here it is assumed that everything is performed on ROSA Desktop Fresh.
 +
 +
* First, install the prerequisites:
 +
<pre>
 +
# urpmi python-distribute python-xlib opencv-devel python-opencv python-numpy python-imaging
 +
# urpmi git scrot
 +
# easy_install pyuserinput
 +
</pre>
 +
 +
* Some image editor will also be needed to prepare the images for the tests (usually, parts of the screenshots). For example, GIMP can be used.
 +
 +
* The newest version of the testing system is available in the git repository:
 +
<pre>
 +
$ git clone https://abf.rosalinux.ru/spectre/rosa-autotest.git
 +
</pre>
 +
 +
Here we assume the source code of the testing system is now in ''/home/user/rosa-autotest''.
 +
 +
For Python to find the needed modules when the tests are executed, one may prepare symlinks to their directories in ''/usr/lib/python2.7/site-packages/'' (as root):
 +
 +
<pre>
 +
# ln -s /home/user/rosa-autotest/rosa_autotest /usr/lib/python2.7/site-packages/
 +
# ln -s /home/user/rosa-autotest/rosatest /usr/lib/python2.7/site-packages/
 +
# ln -s /home/user/rosa-autotest/xpresser /usr/lib/python2.7/site-packages/
 +
</pre>
 +
 +
The path to the modules could be specified in PYTHONPATH environment variable instead.
 +
 +
To check that all the necessary paths are set correctly, one may launch Python and try to import the modules, for example:
 +
 +
<pre>
 +
$ python -c "import rosa_autotest, rosatest, xpresser"
 +
</pre>
 +
 +
If this command completes successfully, the paths are OK.
 +
 +
== Creating the Tests - Tutorial #1 ==
  
 
TBD
 
TBD

Revision as of 17:30, 5 June 2013

The automated testing system for the applications running under ROSA Linux allows to check different usage scenarios of these applications by emulating user actions:

  • keyboard input
  • mouse movement and button clicks

The source code: https://abf.rosalinux.ru/spectre/rosa-autotest/

The system is build upon Python unit testing framework, Python 2.7 is needed. Besides that, the system includes a modified version of Xpresser tool.

Testing GUI Applications

The tests for GUI applications may run in two different modes in our system:

  • A test runs locally, that is, on the same machine where the application under test is running. This mode is more suitable during the development and debugging of the tests. It can also be used for testing the applications on the real hardware.
  • A test operates on the applications that run on a different (usually, virtual) machine. This is convenient for automated runs of the testing system to check the new builds of the distro. Besides, it is possible to check the boot and installation of the OS in this mode, as well as other things that are difficult to check if the tests run locally.

The tests for the applications in the installed OS should usually be written so that they could run in both modes. If the test uses only Python unittest API and the API provided by our system, this will be achieved automatically.

Testing Applications Running on a Separate Machine

Note. For most developers, it will likely be more convenient to run the tests locally instead (see below).

Setup instructions for the software needed for this mode are available here: https://abf.rosalinux.ru/spectre/rosa-autotest/tree/master/doc

The following script runs the whole test suite: launcher.py

Testing Applications Locally

Here it is assumed that everything is performed on ROSA Desktop Fresh.

  • First, install the prerequisites:
# urpmi python-distribute python-xlib opencv-devel python-opencv python-numpy python-imaging
# urpmi git scrot
# easy_install pyuserinput
  • Some image editor will also be needed to prepare the images for the tests (usually, parts of the screenshots). For example, GIMP can be used.
  • The newest version of the testing system is available in the git repository:
$ git clone https://abf.rosalinux.ru/spectre/rosa-autotest.git

Here we assume the source code of the testing system is now in /home/user/rosa-autotest.

For Python to find the needed modules when the tests are executed, one may prepare symlinks to their directories in /usr/lib/python2.7/site-packages/ (as root):

# ln -s /home/user/rosa-autotest/rosa_autotest /usr/lib/python2.7/site-packages/
# ln -s /home/user/rosa-autotest/rosatest /usr/lib/python2.7/site-packages/
# ln -s /home/user/rosa-autotest/xpresser /usr/lib/python2.7/site-packages/

The path to the modules could be specified in PYTHONPATH environment variable instead.

To check that all the necessary paths are set correctly, one may launch Python and try to import the modules, for example:

$ python -c "import rosa_autotest, rosatest, xpresser"

If this command completes successfully, the paths are OK.

Creating the Tests - Tutorial #1

TBD