https://github.com/karrlab/unitth
Python interface for UnitTH unit test history report generator
https://github.com/karrlab/unitth
html-report unit-test unit-test-result-parser unitth
Last synced: 7 months ago
JSON representation
Python interface for UnitTH unit test history report generator
- Host: GitHub
- URL: https://github.com/karrlab/unitth
- Owner: KarrLab
- License: mit
- Created: 2016-08-04T15:42:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-26T19:49:21.000Z (over 5 years ago)
- Last Synced: 2025-05-25T12:50:06.723Z (8 months ago)
- Topics: html-report, unit-test, unit-test-result-parser, unitth
- Language: Python
- Size: 188 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pypi.python.org/pypi/unitth)
[](http://docs.karrlab.org/unitth)
[](https://circleci.com/gh/KarrLab/unitth)
[](https://coveralls.io/github/KarrLab/unitth)
[](https://codeclimate.com/github/KarrLab/unitth)
[](LICENSE)

# unitth
This package provides a Python method and command line interface for generating HTML reports of unit test histories. The package is a Python interface for the [UnitTH](http://junitth.sourceforge.net).
## Installation
* Latest release from PyPI
```
pip install unitth
```
* Latest revision from GitHub
```
pip install git+https://github.com/KarrLab/unitth.git#egg=unitth
```
## Usage
### Command line
```
usage: unitth (sub-commands ...) [options ...] {arguments ...}
Generate HTML unit test history report
positional arguments:
xml_report_dir Parent directory of XML reports of individual builds
to generate a history report of
optional arguments:
-h, --help show this help message and exit
--debug toggle debug output
--quiet suppress all output
--xml-report-filter [XML_REPORT_FILTER]
Starts-with filter for individual reports with `xml-
report-dir` that should be included in the history
report. Set `xml-report-filter` to to include all
files/subdirectories in the history report.
--html-report-path HTML_REPORT_PATH
Directory of HTML reports of individual
builds(relative to XML directories of individual
builds)
--generate-exec-time-graphs GENERATE_EXEC_TIME_GRAPHS
Whether execution time graphs shall be generated
--html-report-dir HTML_REPORT_DIR
directory to store generated HTML history report
--initial_java_heap_size INITIAL_JAVA_HEAP_SIZE
Initial Java heap size
--maximum_java_heap_size MAXIMUM_JAVA_HEAP_SIZE
Maximum Java heap size
```
## Example usage
### Python
```
from nose2unitth.core import Converter as nose2unitth
from junit2htmlreport.parser import Junit as JunitParser
from unitth.core import UnitTH
import os
import subprocess
os.mkdir('reports')
os.mkdir('reports/nose')
os.mkdir('reports/unitth')
os.mkdir('reports/html')
subprocess.check_call(['nosetests', 'tests/test_unitth.py:TestDummy.test_dummy_test',
'--with-xunit', '--xunit-file', 'reports/nose/1.xml'])
subprocess.check_call(['nosetests', 'tests/test_unitth.py:TestDummy.test_dummy_test',
'--with-xunit', '--xunit-file', 'reports/nose/2.xml'])
nose2unitth.run('reports/nose/1.xml', 'reports/unitth/1')
nose2unitth.run('reports/nose/2.xml', 'reports/unitth/2')
with open('reports/unitth/1/index.html', 'wb') as html_file:
print >> html_file, JunitParser('reports/nose/1.xml').html()
with open('reports/unitth/2/index.html', 'wb') as html_file:
print >> html_file, JunitParser('reports/nose/2.xml').html()
UnitTH.run('reports/unitth/*', xml_report_filter='', html_report_dir='reports/html')
```
### Command line
```
mkdir reports
mkdir reports/nose
mkdir reports/unitth
mkdir reports/html
nosetests tests/test_unitth.py:TestDummy.test_dummy_test --with-xunit --xunit-file reports/nose/1.xml
nosetests tests/test_unitth.py:TestDummy.test_dummy_test --with-xunit --xunit-file reports/nose/2.xml
nose2unitth reports/nose/1.xml reports/unitth/1
nose2unitth reports/nose/2.xml reports/unitth/2
junit2html reports/nose/1.xml reports/unitth/1/index.html
junit2html reports/nose/2.xml reports/unitth/2/index.html
unitth --xml_report_filter --html_report_dir reports/html "reports/unitth/*"
```
## Documentation
Please see the [API documentation](http://docs.karrlab.org/unitth).
## License
The build utilities are released under the [MIT license](LICENSE).
## Development team
This package was developed by [Jonathan Karr](http://www.karrlab.org) at the Icahn School of Medicine at Mount Sinai in New York, USA.
## Questions and comments
Please contact the [Jonathan Karr](http://www.karrlab.org) with any questions or comments.