-
Notifications
You must be signed in to change notification settings - Fork 4
1. Getting Started
A test suite starts off with a call to the Lilac function describe, which has two parameters: a string and a function. The string is a name or title for a test suite – usually what is under test. The function is a block of code that implements the suite.
All of your describe calls must exist in a special Lilac function called TestSuites.
function TestSuites()
describe("A suite", myTestSuite())
endFunction
Test cases (or "specs") are defined by calling the Lilac function it, which, like describe, takes a string and a function. The string is a title for the test case and the function is the test itself. A test case contains one or more expectations of the code under test.
An expectation in Lilac is an assertion that can be either true or false. A test case with all true expectations is a passing spec. A test case with one or more expectations that evaluate to false is a failing spec.
function myTestSuite()
it("contains spec with an expectation", myTestCase())
endFunction
function myTestCase()
expectBool(True, to, beEqualTo, True)
endFunction
Since describe and it are just functions that call other functions, they can contain any code necessary to implement the test.
function TestSuites()
describe("A suite is just a function", suite())
endFunction
function suite()
it("and so is a spec", spec())
endFunction
function spec()
bool a = True
expectBool(a, to, beEqualTo, True)
endFunction