Phabricator のプロジェクト名 #MediaWiki-extensions-Pickle


Jump to navigation Jump to search
This page is a translated version of the page Extension:Pickle and the translation is 12% complete.

Other languages:
English • ‎norsk bokmål • ‎norsk nynorsk • ‎日本語
MediaWiki 拡張機能マニュアル
Crystal Clear action run.svg
リリースの状態: 実験的
実装 User interface, Data extraction
説明 Provides a basic on-site testing framework for Scribunto.
作者 John Erling Blad (Jebladtalk)
ライセンス GNU General Public License 2.0 or later
Pickle 拡張機能の翻訳にご協力ください
使用状況とバージョン マトリクスを確認してください。
問題点 未解決のタスク · バグを報告

The Pickle (or Behavior-driven development, BDD, previously Spec) extension is a extension for "spec" style testing for Scribunto . Spec type testing is the same type of unit testing that is done in Rspec, Busted and other similar testing frameworks. It will provide a very thin integration to PHP and a few Lua modules and their localizations.

The actual code is still valid Lua, and all editing tools will work, except for missing definitions for intellisense in the various editors. An overview of the pickle extension from a user perspective can be found at Help:Pickle .

The extension is called Pickle because you pick on your code.

Still note that gherkins are used for pickles, and that is also a language for "step" style testing, a kind of acceptance testing, so you might say these kinds of code snippets are pickles.

At some time in the future the extension might be extended with step style testing, and then the name would fit even better.


The code at Phabricator might lag behind the code at GitHub: jeblad/Pickle, the later is used during development and might be unstable. Spec depends on the Scribunto extension. For recreating the Vagrant-based development environment, see Help:Pickle/Vagrant .

  • ダウンロードして、ファイルを extensions/ フォルダー内の Pickle という名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    wfLoadExtension( 'Pickle' );
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。


The extension can be configured for implicit style or explicit style of tests. The implicit style piggybacks the installation on the describe() call, but this depends on a functional getfenv() call. The Scribunto extension limits the getfenv() call, and according to Extension:Scribunto/Lua reference manual#Differences from standard Lua it is not quite predictable, thus only the explicit style will work.

The reason for the dependency on getfenv() is that the functions are constructed before the describe is called, and thus the calling environment are bound without the global functions. To insert the globals in the correct environment the describe() call use getfenv(). Without this call the environment must be created before the function, thus an explicit call for installing the globals must be available.

Switching between the styles are done by the config { "Setup": "implicit" } or { "Setup": "explicit" }.

If you have a module like "Module:HelloWorld", the ubiquitous and quite pesky example, it will be coded as something like

local p = {}

function p.helloWorld()
	return "Hi there!"

return p

Then on a subpage /pickle you would test this like like the following

Implicit form
return describe 'Hello world' (function()
	subject .helloWorld()
	it 'says hello' (function()
		expect :toBe("Hi there!");
Explicit form

describe 'Hello world' (function()
	subject .helloWorld()
	it 'says hello' (function()
		expect :toBe("Hi there!");

return mw.pickle:reports()

The implicit form has the lines in the beginning and end removed, and the return statement moved down to the new end of code.

There might be additional changes, like where the tap() call is available, and how many describe() calls that can be made.