summaryrefslogtreecommitdiff
path: root/_test/runtests.php
diff options
context:
space:
mode:
authorMichael Klier <chi@chimeric.de>2010-03-30 11:15:08 +0200
committerMichael Klier <chi@chimeric.de>2010-03-30 11:15:08 +0200
commit08d7babffe1bded4620d0a3624bdd80522283138 (patch)
tree0e5368bff1ab25457cd9b1150ac1d1fc2f2fea92 /_test/runtests.php
parent2a98590b375e0acfd24fb0da343eb09a3ff76ff3 (diff)
downloadrpg-08d7babffe1bded4620d0a3624bdd80522283138.tar.gz
rpg-08d7babffe1bded4620d0a3624bdd80522283138.tar.bz2
added support for plugin unittests
This patch adds support to include plugin tests in the DokuWiki testsuite. Plugin tests are located in a dedicated directory _test/within a plugin directory. The naming convention of the test files follows the one used in DokuWikis testsuite. <plugin>/_test/*.test.php -> single test <plugin>/_test/*.group.php -> group test The plugin tests are accessible via the web interface of the test suite and via the cli interface. It is recommend to bundle plugin test in a plugin group test. The webinterface also allows to run all plugin tests at once. Test files must include: <dokuwiki>/_test/lib/unittest.php Example Test: require_once(DOKU_INC.'_test/lib/unittest.php'); class plugin_test extends Doku_UnitTestCase { function test() { $this->assertEqual(1,1); } } Example Group Test: require_once(DOKU_INC.'_test/lib/unittest.php'); class plugin_group_test extends Doku_GroupTest { function group_test() { $dir = dirname(__FILE__).'/'; $this->GroupTest('plugin_grouptest'); $this->addTestFile($dir . 'plugin.test1.php'); $this->addTestFile($dir . 'plugin.test2.php'); $this->addTestFile($dir . 'plugin.test3.php'); } } At the moment unittest.php contains only two meta classes so plugins tests don't have to inherit from the simpletest classes. This patch should be treated as intermediate step to allow for plugin tests. The testsuite wasn't designed to include plugin tests. It should probably be refactored at a later point.
Diffstat (limited to '_test/runtests.php')
-rwxr-xr-x_test/runtests.php56
1 files changed, 53 insertions, 3 deletions
diff --git a/_test/runtests.php b/_test/runtests.php
index e122c59fb..8b93efec3 100755
--- a/_test/runtests.php
+++ b/_test/runtests.php
@@ -21,11 +21,17 @@ passes is printed on STDOUT. If ANY of the test cases fail (or raise
errors) details are printed on STDERR and this script returns a non-zero
exit code.
-c --case=NAME specify a test case by it's ID (see -i for list)
+ --pcase=NAME specify a plugin test case by it's ID
+ (see --plugincaselist for list)
-f --file=NAME specify a test case file (full or relative path)
-g --group=NAME specify a grouptest. If no grouptest is
specified, all test cases will be run.
+ --pgroup=NAME specify a plugin grouptest. If no grouptest is
+ specified, all test cases will be run.
-i --caselist list individual test cases by their ID
-l --grouplist list available grouptests
+ --plugincaselist list all individual plugin test cases by their ID
+ --plugingrouplist list avialable plugin grouptests
-s, --separator=SEP set the character(s) used to separate fail
details to SEP
-p, --path path to SimpleTest installation
@@ -40,14 +46,18 @@ EOD;
$opt_separator = '->';
$opt_caselist = FALSE;
$opt_grouplist = FALSE;
+$opt_plugincaselist = FALSE;
+$opt_plugingrouplist = FALSE;
$opt_caseid = FALSE;
+$top_plugincaseid = FALSE;
$opt_casefile = FALSE;
$opt_groupfile = FALSE;
+$opt_plugingroupfile = FALSE;
include_once(DOKU_INC.'inc/cliopts.php');
$short_opts = "c:f:g:hils:p:";
-$long_opts = array("case=","caselist","help", "file=", "group=", "grouplist", "separator=", "path=");
+$long_opts = array("case=","pcase=","caselist","help", "file=", "group=", "pgroup=", "grouplist", "plugincaselist", "plugingrouplist", "separator=", "path=");
$OPTS = Doku_Cli_Opts::getOptions(__FILE__,$short_opts,$long_opts);
if ( $OPTS->isError() ) {
fwrite( STDERR, $OPTS->getMessage() . "\n");
@@ -61,6 +71,9 @@ foreach ($OPTS->options as $key => $val) {
case 'case':
$opt_caseid = $val;
break;
+ case 'pcase':
+ $opt_plugincaseid = $val;
+ break;
case 'h':
case 'help':
usage();
@@ -73,6 +86,9 @@ foreach ($OPTS->options as $key => $val) {
case 'group':
$opt_groupfile = $val;
break;
+ case 'pgroup':
+ $opt_plugingroupfile = $val;
+ break;
case 'i':
case 'caselist':
$opt_caselist = TRUE;
@@ -81,6 +97,12 @@ foreach ($OPTS->options as $key => $val) {
case 'grouplist':
$opt_grouplist = TRUE;
break;
+ case 'plugincaselist':
+ $opt_plugincaselist = TRUE;
+ break;
+ case 'plugingrouplist':
+ $opt_plugingrouplist = TRUE;
+ break;
case 's':
case 'separator':
$opt_separator = $val;
@@ -110,8 +132,18 @@ if ($opt_caselist) {
echo CLITestManager::getTestCaseList(TEST_CASES);
}
+/* list plugin test cases */
+if ($opt_plugincaselist) {
+ echo CLITestManager::getPluginTestCaseList(TEST_PLUGINS);
+}
+
+/* list plugin group tests */
+if($opt_plugingrouplist) {
+ echo CLITestManager::getPluginGroupTestList(TEST_PLUGINS);
+}
+
/* exit if we've displayed a list */
-if ( $opt_grouplist || $opt_caselist ) {
+if ( $opt_grouplist || $opt_caselist || $opt_plugincaselist || $opt_plugingrouplist ) {
exit(0);
}
@@ -120,17 +152,35 @@ if ($opt_casefile) {
TestManager::runTestFile($opt_casefile, new CLIReporter($opt_separator));
exit(0);
}
-/* run a test case by id*/
+
+/* run a test case by id */
if ($opt_caseid) {
TestManager::runTestCase($opt_caseid, TEST_CASES, new CLIReporter($opt_separator));
exit(0);
}
+
+/* run a plugin test by case id */
+if ($opt_plugincaseid) {
+ TestManager::runTestCase($opt_plugincaseid, TEST_PLUGINS, new CLIReporter($opt_separator));
+ exit(0);
+}
+
/* run a grouptest */
if ($opt_groupfile) {
TestManager::runGroupTest($opt_groupfile, TEST_GROUPS,
new CLIReporter($opt_separator));
exit(0);
}
+
+/* run a plugin grouptest */
+if ($opt_plugingroupfile) {
+ TestManager::runGroupTest($opt_plugingroupfile, TEST_PLUGINS,
+ new CLIReporter($opt_separator));
+ exit(0);
+}
+
+/* run a plugin group test */
+//FIXME
/* run all tests */
TestManager::runAllTests(new CLIReporter($opt_separator));
exit(0);