Help:Pickle/Quick tour/es


 * This is the original documentation for the module before repackaging. The module is not ready for production.

The purpose of this module is to support testing in behavior-driven development (BDD), a software development process that emerged from test-driven development (TDD), in on-going development of modules written in Lua. It makes an assumption of a test module on a separate page, possibly a subpage, and presentation on another page like the talk page or generated through an API call.

The module mimics some ideas from other BDD libs, like RSpec, Jasmine , and Busted. There are no clear standard on how to do this, so there are some variation and adaption.

The module is not built for great speed, it uses closures to build a number of small objects, that is methods returns a value that holds a closure. This creates a fairly efficient implementation for simple access, but it is not very efficient for caching larger structures. Some larger structures are put in tables and built once. This is done for  where each new instance would otherwise create a lot of methods.

The module avoids as much caching as possible, as this can poison the tests.

Usage
If you have a module like «Module:HelloWorld», the ubiquitous and quite pesky example, coded as something like

Then on a test page you would test this like like the following

In the first line the test framework is not only loaded, but it is also installed in the global name space. The trailing parenthesis is a call on the loaded table, and it will install additional global functions. It is not necessary to keep a pointer to the test framework, the functions keep their own pointers.

In the second line the module under test is loaded. Usually it is necessary to keep a pointer to the returned value.

The  function adds a title and evaluates the function from a   (not done yet). The same happens with  and. These three are really the same, it is only our interpretation that changes.

The  function adds a comment and the statement that creates the actual value. It then builds a closure and returns a structure in a flow style. This makes it possible to manipulate the instance, before we finally evaluates it and stores the result for later visualization. In this case we simply tests it to see if it is equal.

The final results are returned by a call to. Like before this can add a title.

The tests can be prepared for for localization into several languages, for example English and Norwegian Bokmål

In this case the languages will be chosen according to the site content language, and if that isn't defined it will use the languages from the fallback chain. If the first argument is a string, then that string will always be used. The language can be changed if the tests are run through the api, which makes it easy to check tests if they are prepared for the requested language.

Normalmente es buena práctica tanto usar un lenguaje común para hacer las pruebas legibles y reutilizables, como utilizar un lenguaje local para hacerlos legibles para la comunidad local de cada proyecto.