[commits] [Wiki] changed: Doc/Dev/Test

Ralf Lang (B1 Systems GmbH) lang at b1-systems.de
Sun Dec 1 10:26:34 UTC 2019


rlang  Sun, 01 Dec 2019 10:26:34 +0000

Modified page: https://wiki.horde.org/Doc/Dev/Test
New Revision:  10
Change log:  Actual unit testing

@@ -115,4 +115,30 @@

  For single or individual tests use phpunit.

  In a developer checkout, unit tests can also be run by calling  
<code>../components/bin/horde-components qc</code> from the app's root  
dir.
+
+++ Unit testing a simple library
+
+I call a library simple to test which does not do IO (db, downloads,  
interact with devices), does not apply side effects to its input  
arguments and does not depend on global state.
+
+This is quite straight forward.
+For example, look at  
[[https://github.com/horde/Argv/tree/master/test/Horde/Argv|the  
Horde_Argv library's test suite]].
+
+The logic is easy to test as all the classes get their complete state  
from input to methods or the constructor. You can just insert what you  
want to test and look at the results. Some very minimal test setup is  
done in the base class Horde_Argv_TestCase from which the actual test  
cases are derived. Each test case may have a setUp method before the  
individual tests are run. This method sets up the environment with the  
unit under test. Look at the ParserTest. In setUp, the parser is  
configured with commandline switches it should recognize. Then, the  
individual tests interact with the parser. Individual assertions which  
are non-trivial and reused can be factored out into helper methods  
like assertRemoved.
+
+++ Not so simple libraries
+
+It gets more complicated the more libraries either mix logic with  
data retrieval, IO, side effects or if they are essentially adapters  
to backends.
+For example, a lot of code in Horde_Core is essentially glue between  
standalone libraries to provide easy to use wrappers and derived  
classes for horde applications.
+
++++ database access
+
+
+
++++ File IO, streams, internet
+
+++ Testing horde applications
+
++++ Unit testing well definded subsystems of applications
+
++++ Integration tests / end to end tests



More information about the commits mailing list