diff options
author | Stevan Radakovic <stevan.radakovic@linaro.org> | 2012-05-11 17:43:53 +0200 |
---|---|---|
committer | Stevan Radakovic <stevan.radakovic@linaro.org> | 2012-05-11 17:43:53 +0200 |
commit | 8197ed75e9828bad9926e83854536d1020e73dbc (patch) | |
tree | bafefcdb5b5f55d9ebac865619ada55dd34788d4 | |
parent | b3d44b868f46699f36f5d8abc6540a5f949d7824 (diff) | |
parent | 6333a1518c26daadbfdfd38886089557ce27e353 (diff) |
Add tests to testrepository to run the PHP unit tests automatically.
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | testing/LicenseHelperTest.php | 2 | ||||
-rw-r--r-- | testing/__init__.py | 1 | ||||
-rw-r--r-- | testing/test_php_unit.py | 33 |
4 files changed, 36 insertions, 3 deletions
@@ -104,5 +104,4 @@ Recent (as of 2012-05-08) Ubuntu/Debian releases have a broken phpunit package a $ sudo pear install pear.phpunit.de/PHPUnit Then to run the test from the 'testing' directory: - $ cd testing/ - $ phpunit LicenseHelperTest + $ phpunit testing/LicenseHelperTest diff --git a/testing/LicenseHelperTest.php b/testing/LicenseHelperTest.php index f47c672..b7bc855 100644 --- a/testing/LicenseHelperTest.php +++ b/testing/LicenseHelperTest.php @@ -1,6 +1,6 @@ <?php -require_once("../licenses/LicenseHelper.php"); +require_once("licenses/LicenseHelper.php"); class LicenseHelperTest extends PHPUnit_Framework_TestCase { diff --git a/testing/__init__.py b/testing/__init__.py index 3b0984e..a02f6d3 100644 --- a/testing/__init__.py +++ b/testing/__init__.py @@ -8,6 +8,7 @@ def test_suite(): module_names = [ 'testing.test_click_through_license.TestLicense', 'testing.test_publish_to_snapshots.TestSnapshotsPublisher', + 'testing.test_php_unit.PhpUnitTest', ] loader = unittest.TestLoader() suite = loader.loadTestsFromNames(module_names) diff --git a/testing/test_php_unit.py b/testing/test_php_unit.py new file mode 100644 index 0000000..15da999 --- /dev/null +++ b/testing/test_php_unit.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import os +import subprocess +import xml.etree.ElementTree as etree + +from testtools import TestCase +from testtools.matchers import Equals + +class PhpUnitTest(TestCase): + '''Tests for executing the PHP Unit tests''' + + def setUp(self): + super(PhpUnitTest, self).setUp() + self.xml_path = "testing/php_unit_test_result.xml" + if subprocess.Popen(['phpunit', '--log-junit', + self.xml_path, 'testing/LicenseHelperTest'], + stdout=open('/dev/null', 'w'), + stderr=subprocess.STDOUT).wait(): + raise CommandNotFoundException("phpunit command not found. Please " + "install phpunit package and rerun tests.") + self.xml_data = etree.parse(self.xml_path) + + def tearDown(self): + super(PhpUnitTest, self).tearDown() + if os.path.exists(self.xml_path): + os.unlink(self.xml_path) + + def test_run_php_unit_tests(self): + self.assertThat(self.xml_data.getroot()[0].attrib['failures'], + Equals("0")) + self.assertThat(self.xml_data.getroot()[0].attrib['errors'], + Equals("0")) |