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:
<testsuite name="core_message_testsuite">
<directory suffix="_test.php">message/tests</directory>
</testsuite>
With this change, it becomes possible to run all tests for an entire
component quickly and easily:
mdk phpunit -s core_message_testsuite
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
;;
}
),
(
+ ['-s', '--testsuite'],
+ {
+ 'default': None,
+ 'help': 'testsuite to run',
+ 'metavar': 'testsuite'
+ }
+ ),
+ (
['-u', '--unittest'],
{
'default': None,
'coverage': args.coverage,
'filter': args.filter,
'testcase': args.testcase,
+ 'testsuite': args.testsuite,
'unittest': args.unittest
}
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():
cmd.append(unittest)
elif filter:
cmd.append('--filter="%s"' % filter)
+ elif testsuite:
+ cmd.append('--testsuite')
+ cmd.append(testsuite)
return cmd