source: main/waeup.kofa/trunk/docs/source/userdocs/testing.rst @ 12926

Last change on this file since 12926 was 12926, checked in by Henrik Bettermann, 9 years ago

Enable temporary suspension of officer accounts. Plugins must be updated after restart.

File size: 4.2 KB
Line 
1.. _testing:
2
3Testing :sup:`in progress`
4**************************
5
6Introduction
7============
8
9Kofa's Python code is being tested automatically. The developers'
10goal is to reach 100% code coverage by Kofa's test runners, which
11means that each single line of code is passed at least one time when
12running the tests.
13
14Why testing? Testing makes sure that our code works properly under
15given sets of conditions and, only comprehensive testing ensures
16that changing or customizing the code does not break existing
17functionality. Why *automated* testing? Simply because no developer
18likes to click around the user interface to check tons of
19functionality. In Kofa more than 1300 tests, with dozens of actions
20per test, are being executed each time when the testrunner is
21started. This job can't be done manually.
22
23There are two different ways to test the code of a web application
24automatically: *unit tests* and *functional tests*. The goal of unit
25testing is to isolate each part of the program and show that the
26individual parts are correct. Functional tests of a web application
27are more wholistic, they require a running web application in the
28background with even a working (temporary) database. Functional
29tests are typically linked to a particular use case, they are
30interacting with the portal as a user would. That implies that
31functional testing has to make use of a test browser. A test browser
32does the same job as normal web browser does, except for visualizing
33the rendered html code.
34
35There are also two different ways to integrate tests, either
36functional or unit, into a Python package: *doc tests* (or doctests)
37and *Python tests*. Python test modules are a collection of
38isolatable Python test cases. A test case combines a collection of
39unit test methods which are being executed by the testrunner one
40after the other. Python test modules are automatically identified by
41means of their filenames which start with ``test_``. In contrast,
42doctests can be wrapped up in simple text files (ending with
43``.txt``), or they can be put into docstrings of the application's
44source code itself. Common to all doctests is that they are based on
45output from the standard Python interpreter shell (indicated by the
46interpreter prompt ``>>>``. The doctest runner parses all ``py`` and
47``txt`` files in our package, executes the interpreter commands
48found and compares the output against an expected value. Example::
49
50  Python's `math` module can compute the square root of 2:
51
52  >>> from math import sqrt
53  >>> sqrt(2)
54  1.4142135623730951
55
56Why wrapping tests into documentation? An objective of testdriven
57software development is also the documentation of the 'Application
58Programming Interface' (API) and, to a certain extent, providing a
59guideline to users, how to operate the portal. The first is mainly
60done in the docstrings of Python modules which present an expressive
61documentation of the main use cases of a module and its components.
62The latter is primarily done in separate ``txt`` files.
63
64When starting the development of Kofa, we relied on writing a
65coherent documentation including doctests in restructured text
66format. During the software development process the focus shifted
67from doctesting to pure Python testing with a lot of functional
68tests inside. It turned out that Python tests are easier to handle
69and more powerful. Drawback is, that these tests cannot easily be
70integrated into the Sphinx documentation project (the documentation
71which you are reading right now). However, we will list some of
72these tests and try to explain what they are good for.
73
74
75Doctests
76========
77
78Browsing
79--------
80
81.. toctree::
82   :maxdepth: 2
83
84   testing/browser
85   testing/breadcrumbs
86
87Cataloging
88----------
89
90.. toctree::
91   :maxdepth: 2
92
93   testing/catalog
94
95Data Center
96-----------
97
98.. toctree::
99   :maxdepth: 2
100
101   testing/datacenter
102
103Security
104--------
105
106.. toctree::
107   :maxdepth: 2
108
109   testing/permissions
110
111Officers
112--------
113
114.. toctree::
115   :maxdepth: 2
116
117   testing/userscontainer
118
119Academic Section
120----------------
121
122.. toctree::
123   :maxdepth: 2
124
125   testing/certificate
126
127Batch Processing
128----------------
129
130.. toctree::
131   :maxdepth: 2
132
133   testing/batching
134   testing/batchprocessing
135
136Access Codes
137------------
138
139.. toctree::
140   :maxdepth: 2
141
142   testing/accesscode
143
144
145Pythontests
146===========
Note: See TracBrowser for help on using the repository browser.