From 07545f796499e7b460ee39a70f284eb669c93373 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 17 Mar 2015 10:14:54 +0100 Subject: [PATCH] MT#9683 improve unit-tests execution - add Makefile with test rule - add use of virtualenv to run tests - add requirements.txt - use junit report - skip it on debian/rules Change-Id: I393431317de7dd1b445ae568a14291a370bc22b3 --- Makefile | 27 +++++++++++++++++++++++++++ debian/rules | 6 +++++- requirements.txt | 2 ++ tests/test_check.py | 11 ++++++++--- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 Makefile create mode 100644 requirements.txt mode change 100644 => 100755 tests/test_check.py diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..1aa5c9fd --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +# do nothing as default +all: + +.ONESHELL: +SHELL = /bin/bash +venv: requirements.txt + virtualenv --python=python2.7 venv + source ./venv/bin/activate && \ + pip install -r ./requirements.txt >install.log + +test_check: venv tests/test_check.py + mkdir -p reports + source ./venv/bin/activate && \ + ./tests/test_check.py > reports/$(@).xml + +# run this in parallel!! -j is your friend +test: test_check + +# get rid of test files +clean: + rm -rf install.log + +# also get rid of pip environment +dist-clean: clean + rm -rf venv + +.PHONY: all \ No newline at end of file diff --git a/debian/rules b/debian/rules index 46536e94..5607cbd4 100755 --- a/debian/rules +++ b/debian/rules @@ -10,6 +10,10 @@ #export DH_VERBOSE=1 %: - dh $@ + dh $@ override_dh_usrlocal: + echo "skipping dh_usrlocal" + +override_dh_auto_test: + echo "skipping dh_auto_test" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..1e240c92 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +unittest-xml-reporting +pyaml diff --git a/tests/test_check.py b/tests/test_check.py old mode 100644 new mode 100755 index 0d3fb59e..17091872 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -20,12 +20,13 @@ # import os import sys +import unittest +import xmlrunner +import yaml lib_path = os.path.abspath('bin') sys.path.append(lib_path) from check import check_sip, check_sip_out from check import XAvp, Test, check_flow, check_flow_vars -import unittest -import yaml class TestXAvp(unittest.TestCase): @@ -160,4 +161,8 @@ class TestCheckSipOut(unittest.TestCase): self.assertFalse(self.ctest.isError()) if __name__ == '__main__': - unittest.main() + unittest.main( + testRunner=xmlrunner.XMLTestRunner(output=sys.stdout), + # these make sure that some options that are not applicable + # remain hidden from the help menu. + failfast=False, buffer=False, catchbreak=False)