describe and it Blocks
Structure a test suite.
Structure of a Spec
busted organizes tests with two core functions: describe and it. A describe block groups related tests, and each it block is a single test case.
This structure comes from behavior driven development and reads like plain English.
describe("Stack", function()
it("starts empty", function()
assert.are.equal(0, Stack.new():size())
end)
end)The describe Block
describe takes a name string and a function. The name should identify the unit or feature being tested, such as a module or class.
Everything inside the function belongs to that group. The name appears in the test output to organize results.
describe("calculator", function()
-- tests live here
end)All lessons in this course
- Why Test
- describe and it Blocks
- Assertions
- Mocks and Spies