Help:Pickle/よくある質問

From mediawiki.org
This page is a translated version of the page Help:Pickle/FAQ and the translation is 21% complete.

This tries to answer some of the most common questions. If you have additional questions post them on the discussion page.

よくある質問

What is a pickle test?

A pickle test is a test written in a style similar to what has become common in RSpec. It focuses on the expected outcome of examples. It also focuses on tests that can be written before the code exists, not tests added after everything is finished.

Where do I define pickle tests?

Pickle tests resides on subpages with the suffix .spec. Usually only one page will hold tests for a single module, but all matching subpages will be included in a test run.

Where are the reports?

Reports from a static test run—those that will be automatically reevaluated on each run—are usually posted as part of the spec doc page. It is not posted on the talk page; that page should only be used for discussion purposes.

How to run tests during editing?

If the module is edited, then there is an additional button under the editor (possibly console). Pushing this will run the found tests, and output the report.

テスト モジュール向け

Pushing the button will only run tests from the current module (spec page).

ソース モジュール向け

Pushing the button will run all the tests from the subpage for the current module (source page).

How to run tests from the console?

To run tests from the console you have to some of the background job yourself. This is quite simple, but not similar on the two types of pages.

テスト コンソールで

The special p export variable holds the test module, but the internal require points to the saved source module. If this is correct you can use the following.

=p(null) -- the first argument is the language, which is not used

If that is not sufficient you can use the following where the last table can hold any replacement as key-value pairs where the key is a page otherwise loaded.

=p(null, {}) -- the first argument is the language, which is not used
ソース コンソールで

The special p export variable holds the source module, but the test modules require points to the saved source module. If this is correct you can use the following.

=require 'Module:Foo/bar.spec'(null) -- the first argument is the language, which is not used

If that is not sufficient you can use the following where the last table can hold any replacement as key-value pairs where the key is a page otherwise loaded.

=require 'Module:Foo/bar.spec'(null, {baz=p}) -- the first argument is the language, which is not used

How to run tests for another locale?

Tests are run for the current user language unless another is explicitly given. You can only do that through the console. The language is the first entry in the function call.

テスト コンソールで
=p('nb') -- the first argument is the language, which is Norwegian Bokmål
ソース コンソールで
=require 'Module:Foo/bar.spec'('nb', p) -- the first argument is the language, which is Norwegian Bokmål