Extension:MWUnit/API

MWUnit adds two API modules, one API query module, and one regular API module. These modules can be used to query or run unit tests via the MediaWiki Action API.

action = rununittests edit

Run unit tests. Any combination of parameters is possible, and all tests specified by the parameters will be run. This API modules requires the mwunit-runtests user right.

parameters edit

group
The name of a group of tests.
test
The canonical name of a test.
page
The name of a test page (with the namespace prefix).
covers
The name of a template covered by one or more tests.

Example edit

Run all unit tests in the group `foobar`

Result
{
   "Qux::foobb":{
      "result":{
         "code":1,
         "message":"This test is marked as risky, because it contains 0 assertions."
      },
      "metadata":{
         "name":"foobb",
         "group":"foobar",
         "title":"Test:Qux",
         "assertions":0,
         "covers":""
      }
   },
   "Boofar::foo":{
      "result":{
         "code":2,
         "message":""
      },
      "metadata":{
         "name":"foo",
         "group":"foobar",
         "title":"Test:Boofar",
         "assertions":1,
         "covers":"banana"
      },
      "output":[
         "string(4) \"asdf\""
      ]
   },
   "Boofar::foobb":{
      "result":{
         "code":1,
         "message":"This test is marked as risky, because it contains 0 assertions."
      },
      "metadata":{
         "name":"foobb",
         "group":"foobar",
         "title":"Test:Boofar",
         "assertions":0,
         "covers":""
      }
   },
   "Foobar::foo":{
      "result":{
         "code":2,
         "message":""
      },
      "metadata":{
         "name":"foo",
         "group":"foobar",
         "title":"Test:Foobar",
         "assertions":1,
         "covers":"banana"
      },
      "output":[
         "int(12343)"
      ]
   },
   "Foobar::foobb":{
      "result":{
         "code":1,
         "message":"This test is marked as risky, because it contains 0 assertions."
      },
      "metadata":{
         "name":"foobb",
         "group":"foobar",
         "title":"Test:Foobar",
         "assertions":0,
         "covers":""
      }
   }
}

list = unittests edit

List all unit tests that match certain criteria. This module requires the read user right.

parameters edit

group
The name of a group of tests.
page
The name of a test page (with the namespace prefix).
covers
The name of a template covered by one or more tests.

Example edit

List all unit tests in the group `foobar`

Result
{
    "batchcomplete": "",
    "Kaaskroket::foobb": {
        "name": "foobb",
        "group": "foobar",
        "article_id": 2,
        "article_text": "Test:Kaaskroket"
    },
    "Fksdl::foo": {
        "name": "foo",
        "group": "foobar",
        "article_id": 7,
        "article_text": "Test:Fksdl"
    },
    "Fksdl::foobb": {
        "name": "foobb",
        "group": "foobar",
        "article_id": 7,
        "article_text": "Test:Fksdl"
    },
    "FKl::foo": {
        "name": "foo",
        "group": "foobar",
        "article_id": 8,
        "article_text": "Test:FKl"
    },
    "FKl::foobb": {
        "name": "foobb",
        "group": "foobar",
        "article_id": 8,
        "article_text": "Test:FKl"
    }
}