Add code coverage report in jenkins job
authorrohitsakala <rohitsakala@gmail.com>
Sat, 21 Jan 2017 16:00:33 +0000 (21:30 +0530)
committerrohitsakala <rohitsakala@gmail.com>
Mon, 23 Jan 2017 06:35:02 +0000 (12:05 +0530)
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>
testapi/run_test.sh
testapi/test-requirements.txt [deleted file]

index 9b25f8f..d1f05f2 100755 (executable)
@@ -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
diff --git a/testapi/test-requirements.txt b/testapi/test-requirements.txt
deleted file mode 100644 (file)
index ddbdefc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# The order of packages is significant, because pip processes them in the order
-# of appearance. Changing the order has an impact on the overall integration
-# process, which may cause wedges in the gate later.
-
-testtools>=1.4.0
-discover
-futures
\ No newline at end of file