Hopp til innhold

Bruker:Jeblad/Module:BDD/dok

Fra Wikipedia, den frie encyklopedi
Note that the module is not ready for production, it is still under active development!

The purpose of this module is to support behavior-driven development (BDD), a software development process that emerged from 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 RSpec [1], Jasmine [2] and Busted [3]. All of which implements BDD.

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 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('')

Further work

  • Formatting
  • Setup/teardown
  • Protect function evaluation
  • Spy on public calls
  • Stub public calls

See also