Extension testbot testset sources
Contents |
Sources for the testset
The source for the testset may differ. It it what you prefer most. Internally is the testset is XML.
Wikipage
This is the most easiest way of generation a testset. If you use the template it is even easier. Using a Wikipage makes it easy to fine tune all setting until the test is Ok.
convert to file
A testset and corresponding test results can be stored in Python or XML format ("hello.py", "hello.xml"). This is useful for programmers who want direct access to wikiation_webtest for their own scripts and programs.
It helps to actually run a test, before attempting to dump its contents and results to file. ;-) (for example, run tests off of the wiki from the default category)
./wikiation_exttest.py --category --dump-py hello.py ./wikiation_exttest.py --category --dump-xml hello.xml
The Python file has a dependency inside the wikiation_exttest. (to wit test.py ) and like all such things, it's probably not the best format for long term storage. On the other hand, on the short term it's easier to play with when you happen to be using python anyway. (And thanks to our good friend repr() we get it practically for free anyway). The format was used a lot for early testing.
run a testset from file
The commands to run tests back from file are straightforward, they are, respectively:
./wikiation_exttest.py --pyfile hello.py ./wikiation_exttest.py --xmlfile hello.xml
If you'd like to roll your own files, you'll find some example files in the Examples directory. The format is fairly self-explanatory:
Python files consist of a (python) list of Test objects (see: test.py), That is to say: [Test(...), Test(...), Test(...), ...]. A Test object needs to be instantiated with at least the following 3 parameters: Test(name='my new test', code='Insert [[diverse]] {{wikicode}} <here>', expect='<html amount="lots">'). The name is an arbitrary string used to (uniquely) identify the test in all displays, code is the wikicode to be tested, and expect is the html you'd expect back from the mediawiki instance you are testing.
XML files are similar. The documentroot is <tests/>, and you fill that with <exttest/> subelements. Each exttest-element has at least 3 subelements of its own: name, code, and expect (sound familiar? :) ). The xml format is similar to that found on the wiki, and it should be possible to cut&paste the contents of the xml file on a wikipage and expect it to work, but this was not a program requirement.
Even more data
Both the Python and XML files that are dumped by wikiation-webtest contain extra elements. Both Python and XML contain result, which is the results of the test (this gets compared with the string in expect), and a diff, which is the outcome of the diff between the two, in ascii format (as produced by python difflib (class Differ)).
Python files may also contain pageReference data, if tests came directly off the wiki. This is the pageTitle where the test was found, The startPosition where the first character of the exttag is found on the page, and the endPosition which is the last position of the closing tag. Suffice to say this is mostly intended for internal processing. Warning: since the webtest obviously does not hold a lock on the page while you sit around staring at this data, I wouldn't wait a week and then still use this. If you're feeling confident, you might have your own scripts use this data right after wikiation_webtest has run.
This extra data is ignored by wikiation_exttest on reload, so you can just use a dumped python or xml file to run tests.
updating results to file
For your own scripts, you might want to run from file, and update results back to file, something like this for Python, XML respectively:
./wikiation_exttest.py --pyfile hello.py --dump-py hello.py ./wikiation_exttest.py --xmlfile hello.xml --dump-xml hello.xml
cross-conversions
Converting one thing into another currently requires that you run the 'thing' in question as a test (and thus get different results). Though you do convert the test-sets this way. If anyone wants more extensive features (and an ability to skip the test in between), this can be improved in future.
- to python
./wikiation_exttest.py --category-name hello --category --dump-py hello.py ./wikiation_exttest.py --xmlfile hello.xml --dump-py hello.py
- to xml
./wikiation_exttest.py --category-name hello --category --dump-xml hello.py ./wikiation_exttest.py --pyfile hello.py --dump-xml hello.xml
- to wiki
First convert to xml, then paste xml onto the wiki. You may want to add separate <result></result> blocks, if you'd like to use --category-and-test, or you may get undefined results.
Detail info
Detailed info can be found in the Default exttest directory with the statement :
./wikiation_exttest --help