Manual:Parser tests/de

Jeder Parsertest-Fall gibt eine Wikitext-Eingabe und eine HTML-Ausgabe an, um sicherzustellen, dass der Parser wie erwartet arbeitet. Der tatsächliche Output wird mit dem gewünschten Ergebnis verglichen, wodurch die Parsertest-Fälle (auch Parsertsts genannt) hilfreich sein können, um Regressionen zu erkennen.

Die Parsertests befinden sich unter. Erweiterungen sollten ihre Tests in einem -Verzeichnis platzieren.

Sie können sowohl durch die phpunit-Testsuite als auch durch das alleinstehende parserTests.php ausgeführt werden -- daher sollte ein Parsertest-Fehler zu einem Fehlschlag der Jenkins-Tests führen.



Version 2 format

 * Starting with 1.35, parser tests are required to be in the Version 2 format. Specifying version 2 indicates that the tests are ready to be run in "tidy" mode (See T249138).
 * To indicate your parser tests are run in version 2 format, the first line in your parser test file must be
 * To indicate your parser tests are run in version 2 format, the first line in your parser test file must be

Enabling hooks
Um sicherzugehen, dass der Erweiterungs-Tag tag1 geladen ist, füge zum Anfang der Datei dies hinzu:

Adding articles
In order to create a new article, the syntax is:

Layout of a parser test
Besides the test time, a test has a number of sections:  (optional),   (optional), ,   (optional),   (optional),   (optional),   (optional),   (optional).

The  and the various   sections are only relevant when running a test with Parsoid. Parsoid also allows additional configuration with additional test-specific options in the options section.

Die Syntax ist wie folgt:

Configuration section
Der "config"-Abschnitt kann weggelassen werden. Wenn du dort Konfigurationswerte angibst, stelle sicher, dass du keinen Whitespace zwischen deinen Ausdrücken hast, da Whitespace durch den Test Runner nicht entfernt wird.

Options section
Each option should come on its own line.

changes format
 * disables the test.
 * runs the test only with the core's default parser unless Parsoid-specific HTML sections are present. The "php" name is a historical remnant from when Parsoid was a Node.js codebase.
 * or  (JSON format object) enable Parsoid-specific options.
 * Ex:  runs this test in only those 2 modes. By default, the test is run all available test modes for the test given the wikitext and html sections. In the common case, this defaults to running the test in wt2html, wt2wt, html2wt, html2html, and selser modes. The selser mode is an abbreviation for a test mode where the HTML section is edited in a number of automated ways which is then converted to wikitext using Parsoid's selective-serialization (selser henceforth) transformations. TODO: Add a link to a wikipage that explains Parsoid's various transformations.
 * In the JSON format object, the following keys are current recognized
 * : This is a comma separated list of Parsoid modes to run
 * : If selser is one of the test modes in the modes property, this property can optionally specify  to indicate automatic edits for this test should not be generated. If so, only manual edits as specified by the   property will be applied.
 * : This format is described separately below. This option will need to be paired with a   section in the test (see below)  that specifies the expected wikitext output when this edited HTML is converted (via selser) to wikitext by Parsoid.

This is an array of individual changes to apply to the DOM of the HTML generated by transforming wikitext. Each element of the array contains 3 or more elements: (a) jquery selector to select a DOM node (b) the type of change to apply to the selected node (c) the relevant values / content needed to apply the change specified.

More succinctly, each array element represents a jquery method call. So, [x,y,z...] becomes  So, ['fig', 'attr', 'width', '120'] is interpreted as

Right now, the following jquery methods are recognized:

See http://api.jquery.com/ for documentation of these methods.

"contents" as second argument calls the jquery .contents method on the results of the selector in the first argument, which is a good way to get at the text and comment nodes.

Wikitext sections

 * section: This is expected to be present in all tests is the that specifies the wikitext to be processed to HTML (or in Parsoid html2wt and wt2wt test modes, the wikitext to generate from the HTML sections).
 * section: This section is only relevant in Parsoid test runs. For tests that provide a manual set of changes to apply to the HTML generated from the wikitext section, this is the output expected when Parsoid converts that edited HTML back to wikitext.

HTML sections
TODO

Extension.json & parser tests
Für Erweiterungen, die ihre Tests in  platzieren und extension.json verwenden, werden die Parsertests automatisch ausgeführt. Erweiterungen die das alte System zum Laden von Erweiterungen verwenden, können dies verwenden:

Running tests with parserTests.php
Um Parsertests auszuführen, führe im Wurzelverzeichnis deiner MediaWiki-Installaton folgendes per Kommandozeile auf:

Um Tests nur für eine Datei durchzuführen, verwende den -Parameter. Siehe  für weitere Parameter.

Parsoid-specific test runner options
These options aren't available with MediaWiki core's paresr test runner in MW 1.38 and prior. You can run tests in Parsoid mode via the  option. The best and most up-to-date documentation of all available options is to run

Setting global config variables
To set default global variables for all parser tests in an extension, use the hook.

In a specific test, set the config variables as follows:



Siehe auch

 * QA und Testen
 * QA und Testen