System testing of Semantic MediaWiki can be done using Selenium and the Selenium Framework provided by MediaWiki.
Selenium IDE can be used well for quick recording of tests, debugging of tests, and learning how to write Selenium tests. Recorded Selenium tests can be exported as PHP to be included in the SMW code. In this HowTo we describe the usage of the IDE.
This section describes the general environment for Selenium Tests. The environment is valid for the whole system testing process, whether you are creating only one or several test cases.
After installing Selenium IDE you can open this tool via the Firefox menu: Tools --> Selenium IDE. Selenium IDE opens in an own window.
Uncheck "Start recording immediately on open"
define Base URL: Main Page of your wiki (AUT). Each test case shall start and end on the wikis Main Page.
The aim of the Selenium Tests is to create several modular test cases, which all only check a single functionality or a single use case (for example: Define type of property).
In the setUp you achieve the prerequisites for the respective test case. Mostly you will create and edit pages in the setUp or make some annotations, but you will not make any tests in this section. The general rule is: If a test afterwards will fail in the setUp, then the source of this problem is not in the respective feature or use case which is checked by the whole test case.
The single tests in contrast should check exactly the feature or use case of the whole test case. If you divide them, you may create several tests. Choose significant names for the tests (for example: check semantic search and check displaying).
With the tearDown you bring back the system to its original state before the tests. This means: delete all created pages and undo all of your editings. Finally you have to return to the Main page. The tearDown is very important to not leave any traces in the wiki. So, you can make sure, that your test be used several times in succession without any problems.
Please make sure, that you choose a clear nomination. With Selenium you will create a file for the setUp, for the several tests and the tearDown of each test case.
You should use the name of the test case for every file and add an prefix (for example, setUp, test01, etc.). If you have created more than one test for a test case, you need to illustrate the order of the several tests in their nomination.
"Einen Knoten zum Inspezieren durch Draufklicken suchen"
Click on element -> Copy&Paste locator -> Put extra slash in front of locator to indicate "XPath" locator, e.g., "//html/body/div[@id='globalWrapper']/div[@id='column-content']/div[@id='content']/div[@id='bodyContent']/div[@id='mw-data-after-content']/div"
Note, that this is not a robust way of defining targets.
You can also use the context menu in your browser to add commands. Just right-click the concerning element when Selenium is running (not recording).
After you have finished recording the test, you need to check, if the whole test is running without problems.
Run the whole test case (Selenium: "Play entire test suite") in the browser, for each Test Case there is indicated whether it run successfully or failed.
The task of Creating SMW Selenium Tests ends with the creation of the php test files. The next task is Running SMW Selenium Tests.
This section should give some advices for creating tests in the future. Please add your experiences to reach a better workflow in the test creation process.
Note, that you have to select a test on the left with a double click before editing. A single click is only highlighting a test but you will still edit the last one.
If you create similar test cases, you may reuse them (load test case, rename and make changes).
You may also just reuse the setUp and the tearDown and extend them.
In order to have special characters shown correctly in the browser, the TestSuite and TestCase PHP files were saved in UTF-8 format.
Bear in mind to read Selenium command documentation: e.g., getValue() and getText() are different.
Aim: Running SMW Selenium tests on a local SMW instance.
We install one instance of MW and SMW.
MW contains the Selenium Framework.
SMW contains the SMW Selenium Tests.
The instance is the AUT (application under test). Could also be another wiki, but here the wiki itself is tested. The AUT is configured to be empty and the Vektor skin is used.
Selenium RC (remote control) is used by the Selenium Framwork to run the SMW Selenium Tests on the instance.
MediaWiki with Selenium Framework. The WMF Selenium Framework is available for later versions of MediaWiki, only. It also is still under development, especially in regard to Continuous Integration.
This Documentation uses MW 1.18alpha (r90094).
Selenium tests for SMW: They will be (not published yet) found in "MediaWiki/extensions/SemanticMediaWiki/tests/selenium/suites"
Selenium Server remote controlling the browsers: selenium-server.jar .
Hint: WMF-Selenium-Framework possibly does this.
Add SMW test suite: testSuite[SMWSeleniumTestSuite] = "extensions/SemanticMediaWiki/tests/selenium/suites/SMWSeleniumTestSuite.php"
; path to selenium-server.jar from the selenium-remote-control package.
Failure or sucess of tests/assertions is indicated in the console.
After a failure, pages might not have been deleted properly from the AUT.
WMF Selenium Framework provides a way to automatically create a clean wiki instance before running the tests. See more information at . However, this does not seem to work properly, yet.
As a workaround: In order to re-run tests after a failure, create a backup from the database or use the Extension Nuke to delete all pages.
We have created a wiki that shall support the creation of system tests. It is a Single-Source-Framework for describing functionality of SMW to be explained in the user/admin manual and tested with Selenium.
Note, this is work in progress.
This page was last edited on 10 May 2013, at 17:06.