diff options
Diffstat (limited to 'utils/test/testapi/run_test.sh')
-rwxr-xr-x | utils/test/testapi/run_test.sh | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/utils/test/testapi/run_test.sh b/utils/test/testapi/run_test.sh index 9b25f8ffc..51db09f65 100755 --- a/utils/test/testapi/run_test.sh +++ b/utils/test/testapi/run_test.sh @@ -1,10 +1,36 @@ -#! /bin/bash +#!/bin/bash -# Before run this script, make sure that testtools and discover -# had been installed in your env -# or else using pip to install them as follows: -# pip install testtools, discover +set -o errexit + +# Get script directory +SCRIPTDIR=`dirname $0` + +echo "Running unit tests..." + +# Creating virtual environment +virtualenv $SCRIPTDIR/testapi_venv +source $SCRIPTDIR/testapi_venv/bin/activate + +# Install requirements +pip install -r $SCRIPTDIR/requirements.txt +pip install coverage +pip install nose>=1.3.1 find . -type f -name "*.pyc" -delete -testrargs="discover ./opnfv_testapi/tests/unit" -python -m testtools.run $testrargs + +nosetests --with-xunit \ + --with-coverage \ + --cover-erase \ + --cover-package=$SCRIPTDIR/opnfv_testapi/cmd \ + --cover-package=$SCRIPTDIR/opnfv_testapi/common \ + --cover-package=$SCRIPTDIR/opnfv_testapi/resources \ + --cover-package=$SCRIPTDIR/opnfv_testapi/router \ + --cover-xml \ + --cover-html \ + $SCRIPTDIR/opnfv_testapi/tests + +exit_code=$? + +deactivate + +exit $exit_code |