Bruker:Jeblad/Module:BDD/dok
- Note that the module is not ready for production, it is still under active development!
The purpose of this module is to support w:en:Behavior-driven development (BDD), a w:en:software development process that emerged from w:en:test-driven development (TDD), in on-going development of Lua-based modules. It uses the assumption of a test module on a separate page, possibly a subpage, and presentation on the talk page.
The module implements some ideas from en:RSpec [1], en:Jasmine [2] and en:Busted [3]. All of which implements BDD.
The module is not built for great speed, it uses closures to build small objects, that is methods returns a value that is wrapped in a closure. This makes a fairly efficient implementation for simple access, but it is not very efficient for caching larger structures. The module also avoids as much caching as possible, as this can poison the testing.
Usage
If you have a module like
local p = {}
function p.helloWorld()
return "Hi there!"
end
return p
On the test page a call will then be something like the following
require 'Module:BDD'()
describe('Hello world', function()
context('On all pages', function()
it('says hello', function()
expect(helloWorld()).toBe("Hi there!");
end);
end);
end);
return result('')