summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/run_test.sh
diff options
context:
space:
mode:
authorrohitsakala <rohitsakala@gmail.com>2017-01-21 21:30:33 +0530
committerrohitsakala <rohitsakala@gmail.com>2017-01-23 12:05:02 +0530
commit1bf58ff929b2e06899b29c066bb7aa2815a22d6c (patch)
treecf819109c45a4c8aa22fb4945f46cd3ea0551fa4 /utils/test/testapi/run_test.sh
parent34338a12d9a8dd2ac9ddd2882efca18fc8fb33de (diff)
Add code coverage report in jenkins job
Modified existing bash script to enable code coverage report in jenkins job. Removed test-requirements.txt. JIRA: FUNCTEST-703 Change-Id: I7ea6b5c87ce7d098dcb0c74ed195db0f6c3b9692 Signed-off-by: rohitsakala <rohitsakala@gmail.com>
Diffstat (limited to 'utils/test/testapi/run_test.sh')
-rwxr-xr-xutils/test/testapi/run_test.sh44
1 files changed, 37 insertions, 7 deletions
diff --git a/utils/test/testapi/run_test.sh b/utils/test/testapi/run_test.sh
index 9b25f8ffc..d1f05f201 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`
+
+# Either Workspace is set (CI)
+if [ -z $WORKSPACE ]
+then
+ WORKSPACE="."
+fi
+
+echo "Running unit tests..."
+
+# Creating virtual environment
+virtualenv $WORKSPACE/testapi_venv
+source $WORKSPACE/testapi_venv/bin/activate
+
+# Install requirements
+pip install -r $SCRIPTDIR/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/commonn \
+ --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