[5770] | 1 | Developer Notes |
---|
| 2 | *************** |
---|
| 3 | |
---|
[7818] | 4 | How to setup a developer instance of the WAeUP.Kofa, handle tests, docs |
---|
[5770] | 5 | etc. |
---|
| 6 | |
---|
[7818] | 7 | The new WAeUP.Kofa is based on `Grok <http://grok.zope.org/>`_. |
---|
[5770] | 8 | |
---|
| 9 | Installing a developer copy |
---|
| 10 | =========================== |
---|
| 11 | |
---|
[11386] | 12 | See :ref:`installing_linux` |
---|
[5770] | 13 | |
---|
| 14 | Documentation |
---|
| 15 | ============= |
---|
| 16 | |
---|
[7808] | 17 | With the :mod:`waeup.kofa` package we try to reach high standards in |
---|
[5770] | 18 | both, documentation and testing. |
---|
| 19 | |
---|
[7808] | 20 | :mod:`waeup.kofa` makes extensive use of doctests, which this way also |
---|
[5770] | 21 | become both: executable (i.e. testable) examples and documentation. |
---|
| 22 | |
---|
[11386] | 23 | Building documentation |
---|
| 24 | ---------------------- |
---|
[5770] | 25 | |
---|
[11386] | 26 | See :ref:`building_documentation` |
---|
[5770] | 27 | |
---|
| 28 | Writing documentation |
---|
| 29 | --------------------- |
---|
| 30 | |
---|
| 31 | means explaining to other developers what your code does and test it |
---|
[7808] | 32 | at the same time. See the many .txt files in the :mod:`waeup.kofa` |
---|
[5770] | 33 | package for examples. |
---|
| 34 | |
---|
| 35 | Testing |
---|
| 36 | ======= |
---|
| 37 | |
---|
[7808] | 38 | Tests are most important to the reliability of the :mod:`waeup.kofa` |
---|
[5770] | 39 | package. We don't tell someone that our code works, if we cannot prove |
---|
| 40 | it. And we prove it by testing. |
---|
| 41 | |
---|
| 42 | Running tests |
---|
| 43 | ------------- |
---|
| 44 | |
---|
| 45 | You can run all the tests for the package by doing:: |
---|
| 46 | |
---|
| 47 | $ bin/test |
---|
| 48 | |
---|
| 49 | If you like colored output (can improve readability of failure |
---|
| 50 | messages), use the ``-c`` switch:: |
---|
| 51 | |
---|
| 52 | $ bin/test -c |
---|
| 53 | |
---|
[7808] | 54 | We have many tests in the :mod:`waeup.kofa` package so that sometimes |
---|
[5770] | 55 | you only want the functional *or* the unit tests to run. This can be |
---|
| 56 | done like this:: |
---|
| 57 | |
---|
| 58 | $ bin/test -c -u |
---|
| 59 | |
---|
| 60 | if you want only unit tests or like this:: |
---|
| 61 | |
---|
| 62 | $ bin/test -c -f |
---|
| 63 | |
---|
| 64 | if you only want functional tests. |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | Writing tests |
---|
| 68 | ------------- |
---|
| 69 | |
---|
| 70 | Is a wiiide topic. For now, please see the numerous .txt files in the |
---|
| 71 | source. Most of the **are** tests. |
---|
| 72 | |
---|
| 73 | Generally, we use `z3c.testsetup` for finding and setting up tests. |
---|
| 74 | |
---|
| 75 | There are mainly two kinds of tests we use: |
---|
| 76 | |
---|
| 77 | * unit- or simple doctests |
---|
| 78 | |
---|
| 79 | These are included in test runs automatically, if they provide a |
---|
| 80 | marker like this somewhere (normally near top of file):: |
---|
| 81 | |
---|
| 82 | .. :doctest: |
---|
| 83 | |
---|
| 84 | Most unit tests furthermore declare that they want to be run inside |
---|
[7818] | 85 | the `WAeUPKofaUnitTestLayer` defined in `waeup.kofa.testing`. This |
---|
[7808] | 86 | layer groks the whole `waeup.kofa` package, so that all ZCA |
---|
[5770] | 87 | components are already setup when you start your tests. |
---|
| 88 | |
---|
| 89 | To declare that a unit test testfile should be run inside this |
---|
| 90 | layer, the testfile has to provide the following line:: |
---|
| 91 | |
---|
[7818] | 92 | .. :layer: waeup.kofa.testing.WAeUPKofaUnitTestLayer |
---|
[5770] | 93 | |
---|
| 94 | Use it, if in your tests you make use of registered components like |
---|
| 95 | utilities, adapters and the like. |
---|
| 96 | |
---|
| 97 | * integration or functional tests |
---|
| 98 | |
---|
| 99 | These provide a full-blown ZODB storage, so that we can emulate |
---|
| 100 | browser requests to the whole system. Functional tests are much more |
---|
| 101 | expensive in terms of memory and runtime but needed, if you want to |
---|
| 102 | test UI components. |
---|
| 103 | |
---|
| 104 | A testfile is registered as functional test on testruns when it |
---|
| 105 | provides a line like the following:: |
---|
| 106 | |
---|
| 107 | :Test-Layer: functional |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | Code coverage |
---|
| 111 | ------------- |
---|
| 112 | |
---|
| 113 | We want to make sure, that all aspects of our software are |
---|
| 114 | tested. This means, that all parts of the codes should be tested |
---|
| 115 | somewhere. |
---|
| 116 | |
---|
| 117 | To tell how good our test coverage is, we can also use the testrunner |
---|
| 118 | (``bin/test``):: |
---|
| 119 | |
---|
| 120 | $ bin/test --coverage=coverage |
---|
| 121 | |
---|
| 122 | will run the tests but also look, which parts of code were touched by |
---|
| 123 | them. For releases we want 100% coverage. Beware: running tests with |
---|
| 124 | the ``--coverage`` switch slows down tests by factor 10 or more. |
---|
| 125 | |
---|
| 126 | The command above will output a table with percentages. Furthermore, |
---|
| 127 | in ``/parts/test/coverage`` you will (after the testrun) find your |
---|
| 128 | sources preceeded by markers which tell, how often (or none) a certain |
---|
| 129 | line was used in tests. |
---|
| 130 | |
---|
| 131 | To have a more convenient cmdline interface, we also provide some |
---|
| 132 | shortcuts:: |
---|
| 133 | |
---|
| 134 | $ bin/coverage-detect |
---|
| 135 | |
---|
| 136 | will run all the tests as shown above and put the results in |
---|
| 137 | ``parts/coverage-detect/coverage``. |
---|
| 138 | |
---|
| 139 | After that you can run:: |
---|
| 140 | |
---|
| 141 | $ bin/coveragereport |
---|
| 142 | |
---|
| 143 | to get a browsable HTML representation of test coverage in |
---|
| 144 | ``coverage-report/`` subdir. |
---|
| 145 | |
---|
| 146 | Both, the coverage reports and HTML documentation generated by sphinx |
---|
| 147 | can be packed and put onto a website as-is. |
---|
| 148 | |
---|
| 149 | It is also possible to generate the docs and reports nightly by a |
---|
| 150 | buildbot or something like this. |
---|