From ce41bfb7391dce51a15684cdea5e25aa811052ad Mon Sep 17 00:00:00 2001 From: freewind Date: Sat, 24 Mar 2018 13:14:01 +0800 Subject: [PATCH] add 'coverage' to generate testing coverage report --- .gitignore | 2 ++ README.md | 17 +++++++++++++++++ coverage_report.sh | 5 +++++ requirements.txt | 1 + setup.py | 3 ++- 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 coverage_report.sh diff --git a/.gitignore b/.gitignore index f7f8e9c4..bd8a15e9 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ dist laser* lol* .idea* +htmlcov/ +.coverage diff --git a/README.md b/README.md index b6736f8b..0753a536 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,23 @@ $ pip3 install mythril If you plan to analyze Solidity code you'll also need the [native version of solc](http://solidity.readthedocs.io/en/v0.4.21/installing-solidity.html#binary-packages). Solcjs is not supported. +## Running tests + +```bash +pip3 install -r requirements.txt +./all_tests.sh +``` + +It will run all the tests. + +### Generating test coverage report + +```bash +./coverage_report.sh +``` + +It will generate a coverage testing report `htmlcov/index.html` in html format, which will be automatically opened in browser. + ## Security analysis Run `myth -x` with one of the input options described below to run the analysis. This will run the Python modules in the [/analysis/modules](https://github.com/b-mueller/mythril/tree/master/mythril/analysis/modules) directory. diff --git a/coverage_report.sh b/coverage_report.sh new file mode 100755 index 00000000..fc10bd70 --- /dev/null +++ b/coverage_report.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +coverage run --source=mythril -m unittest discover -p "*_test.py" +coverage html +open htmlcov/index.html diff --git a/requirements.txt b/requirements.txt index eb28bc0f..66379de7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,3 +13,4 @@ eth-keyfile>=0.5.1 eth-keys>=0.2.0b3 eth-rlp>=0.1.0 eth-tester>=0.1.0b21 +coverage diff --git a/setup.py b/setup.py index baf998f2..3855da90 100755 --- a/setup.py +++ b/setup.py @@ -301,7 +301,8 @@ setup( 'eth-keyfile>=0.5.1', 'eth-keys>=0.2.0b3', 'eth-rlp>=0.1.0', - 'eth-tester>=0.1.0b21' + 'eth-tester>=0.1.0b21', + 'coverage' ], python_requires='>=3.5',