← Lua Academy

First steps · 1 / 69

Your first green test

YOUR TASK

Make this happen

3 steps
  1. A test compares an actual value with an expected value. Run the starter, read the failure, then change the exported answer. Lua chunks can expose functions and values through the platform’s exports table.

  2. Read the cases in lesson.test.lua, then choose Check solution to see what needs to change.

  3. Update subject.lua until every test passes. Keep the supplied tests unchanged.

Read the starter and tests

subject.lua

exports.answer = 0

lesson.test.lua

local t = require("test")
local subject = require("cococo.subject")

t.it("the answer is 42", function()
  local s = subject.load()
  t.expect(s.answer):eq(42)
end)