Skip to main content

Writing Your First Test Cases

The language should seem familiar

describe("TVL unit testing framework", function()
describe("should be awesome", function()
it("should be easy to use", function()
assert.truthy("Yup.")
end)

it("should have lots of features", function()
-- deep check comparisons!
assert.are.same({ table = "great"}, { table = "great" })

-- or check by reference!
assert.are_not.equal({ table = "great"}, { table = "great"})

assert.truthy("this is a string") -- truthy: not false or nil

assert.True(1 == 1)
assert.is_true(1 == 1)

assert.falsy(nil)
assert.has_error(function() error("Wat") end, "Wat")
end)

it("should provide some shortcuts to common functions", function()
assert.are.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }})
end)
end)
end)