From: Andrew Nicols Date: Wed, 12 Nov 2014 03:25:27 +0000 (+0800) Subject: Add testsuite coverage to phpunit X-Git-Tag: v1.5.1~15^2 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=059abb287d9b2375c84df3036b9ae7c0302835ff;p=mdk.git Add testsuite coverage to phpunit In Moodle, we put all of our test directories into testsuites. For example, the message/tests directory is defined in the core_message_testsuite testsuite. Because of our naming scheme for files, we cannot simply pass the directory as this only looks for files with the suffix Test.php. We can however make use of the testsuite option to phpunit. Suites are named as per their frankenstyle component and the complete list can be found in the generated phpunit.xml configration. Here's an excerpt for the above example: message/tests With this change, it becomes possible to run all tests for an entire component quickly and easily: mdk phpunit -s core_message_testsuite --- diff --git a/extra/bash_completion b/extra/bash_completion index 230c46f..e422c8a 100644 --- a/extra/bash_completion +++ b/extra/bash_completion @@ -172,7 +172,7 @@ function _mdk() { OPTS="$(compgen -A file $CUR)" compopt -o nospace else - OPTS="--force --run --testcase --unittest --filter --coverage" + OPTS="--force --run --testcase --unittest --filter --coverage --testsuite" OPTS="$OPTS $(_list_instances)" fi ;; diff --git a/mdk/commands/phpunit.py b/mdk/commands/phpunit.py index f859a46..a87f6c0 100644 --- a/mdk/commands/phpunit.py +++ b/mdk/commands/phpunit.py @@ -57,6 +57,14 @@ class PhpunitCommand(Command): } ), ( + ['-s', '--testsuite'], + { + 'default': None, + 'help': 'testsuite to run', + 'metavar': 'testsuite' + } + ), + ( ['-u', '--unittest'], { 'default': None, @@ -144,6 +152,7 @@ class PhpunitCommand(Command): 'coverage': args.coverage, 'filter': args.filter, 'testcase': args.testcase, + 'testsuite': args.testsuite, 'unittest': args.unittest } diff --git a/mdk/phpunit.py b/mdk/phpunit.py index b72c0a3..1f5628e 100644 --- a/mdk/phpunit.py +++ b/mdk/phpunit.py @@ -40,7 +40,7 @@ class PHPUnit(object): self._Wp = Wp self._M = M - def getCommand(self, testcase=None, unittest=None, filter=None, coverage=None): + def getCommand(self, testcase=None, unittest=None, filter=None, coverage=None, testsuite=None): """Get the PHPUnit command""" cmd = [] if self.usesComposer(): @@ -58,6 +58,9 @@ class PHPUnit(object): cmd.append(unittest) elif filter: cmd.append('--filter="%s"' % filter) + elif testsuite: + cmd.append('--testsuite') + cmd.append(testsuite) return cmd