X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Ftest%2Ftestapi%2Frun_test.sh;h=1e05dd6ba2c0eb5a2604e1bc2a26b853fe4a6fd6;hb=c646dd47d0f75eb568ebadea4e9f64a8f9a14db3;hp=9b25f8ffc93fd3b7f421c923d52eff623622481b;hpb=a26858a97ee50374b406cdbaadad1284ae4b6185;p=releng.git diff --git a/utils/test/testapi/run_test.sh b/utils/test/testapi/run_test.sh index 9b25f8ffc..1e05dd6ba 100755 --- a/utils/test/testapi/run_test.sh +++ b/utils/test/testapi/run_test.sh @@ -1,10 +1,40 @@ -#! /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 +if [ ! -z $VIRTUAL_ENV ]; then + venv=$VIRTUAL_ENV +else + venv=$SCRIPTDIR/.venv + virtualenv $venv +fi +source $venv/bin/activate + +# Install requirements +pip install -r $SCRIPTDIR/requirements.txt +pip install -r $SCRIPTDIR/test-requirements.txt 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