Analysis of our test coverage and code complexity
| Newsgroups | gmane.network.freenet.devel |
|---|---|
| Organization | Freenet Project |
| Message-ID | <2872955.LTZJPAQZYq@1337h4x0r> |
TL;DR:
Summary of analysis:
Freenet core: http://i.imgur.com/xTuZwBv.png
Web of Trust: http://i.imgur.com/Ht1pQbj.png
Detailed HTML output (you need Freenet for those links):
Freenet core: http://127.0.0.1:8888/CHK@ukoL~NGt6t0p9VRJ7RATO0vxlGVr0mBvL0qB164A4Y8,DbjfwdzSP7hDN11-s20k79tRURobCRtyZyVGppVH1ZY,AAMC--8/test-coverage-fred_testing-build-1474-pre1-122-g5baa142/index.html
Web of Trust: http://127.0.0.1:8888/CHK@PmCkInFQYV4pMk~hf4D3cS7KPQWobQVMLY3kRaXnqh4,x2gH3qBymq4fbayvZbudvD9EXWG9J6OuIR41iFUvxCc,AAMC--8/test-coverage-WebOfTrust_build0018-147-gae56c33/index.html
I've provided code to use Cobertura for test analysis.
Cobertura is a tool which injects its own code during the unit tests to
analyze which code of the fred core is called during test runs. This yields
HTML output which contains things such as:
- a view of the source code with the lines being color-coded as:
red = untested, green = tested.
- a percentage of how many lines of code are covered by the tests.
- a percentage of how many code paths (if() etc) are covered by the tests.
- bonus (static?) analysis: the "average McCabe's cyclomatic code complexity for
all methods." = average number of code paths. This can be used to find giant
functions which need to be split up.
- the above statistics both for the whole repository and also for each package
and class.
I've amended the Ant builders of fred and Web of Trust to optionally use
Cobertura and provide the HTML output at ./test-coverage/html.
As dependency you only need to install the standard Ubuntu "cobertura"
package. Alternatively, put a cobertura.jar into /usr/share/java/
It can then be executed by:
ant clean && ant -Dtest.coverage=true
fred's incremental compilation, i.e. leaving out the "ant clean", should also work as
long as you don't delete classes.
You can also compute test coverage as caused by only a specific single unit
test class:
ant -Dtest.coverage=true -Dtest.class=freenet.packageName.ClassName
For fred, the code is pending as a pull request:
https://github.com/freenet/fred/pull/553
For WoT, it has been merged into the "next" branch already.
Greetings!
[1] http://cobertura.github.io/cobertura/
_______________________________________________
Devl mailing list
[email protected]
https://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
signature.asc
(application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABCAAGBQJXU4zIAAoJEMtmZ+8tjWt5WGQP/2AMMCwMbxU/m/W26cZMU966 2vMbm/nEiZYeRWl5+GIeoGT8AorTUwMclwr5rpin156FCv9nNu8RugTBTJMFwAA/ 8a9SDls1piKeRfm6vBvuuEwnYatlvzv1G0hMkJTcsWYnAG9fA2H6lCFmuQTQxqF4 02uglr5M+PPdkWc74WZUs8bEHPgobvPOWYcjusKDoDMMrDNVuRFFoXOlVPRTkVtl rpczoD4JslHAEMxMci9tAmLSmuKpNZRc1l8kArdaRe1ZVvRoHWPqLWYvJi9wKejz 2/1VrYAsNp2B4DyNsCRXcOUFb59IzaaaH/I7AXMGPu+ckB+cfzIlXkeuf9iWScFX TnV7s3wLo2hFVwglJ23dwWSO8Gw+SofQXtZ8xVb5o7UXbX3BR8kD+SOnK0fbuSkk HVF5zCOtKquH3R4OM8tua9muLKdHtBQaUH1c9/Ec7qn8CZxFtZoVeWSeNKhYA9xC tnD+ZUR4wBYfjNjuxTfWtn4TJOnJWvGgAo4Qi7CUsS+0nCWBnE2nuSKeobBvL57n b3J3/EoKt1YC2v7uU3GlMywV4D5+ywfioSxBgmg4uoIXLCHGr0HBainG90UmHKif LDF6+fLTQIPGyOS3vm+rfwiRDgSYJajauwmwLlAVTKzdpTkzwt+10pDImgnbIFbV TwVljTZq8ghbIWTkAqBy =XJVl -----END PGP SIGNATURE-----