Check Your Lua
Write clear, expressive assertions using Check Your Lua, a small, custom unit testing library developed specifically for this book.
Lua is a beautifully minimal language, making it highly extensible but also incredibly easy to misuse.
By writing unit tests first, you will learn how to design production ready Lua modules that stand up to real-world complexity.
Check Your Lua
Write clear, expressive assertions using Check Your Lua, a small, custom unit testing library developed specifically for this book.
LuaUnit Ecosystem
Learn to navigate classic xUnit testing patterns with LuaUnit, the most widely utilized testing framework in the Lua community.
Red, Green, Refactor
Write a failing test to define your intent, write the minimal code required to make it pass, and confidently refactor your design with total safety.
Core Language Mechanics
Demystify Lua’s distinct features: tables, metatables, closures, lexical scoping, and coroutines.
While I was learning Lua, the only resource I felt I needed was the official Lua manual. I highly recommend reading it if you plan on writing Lua. It will be more effective at teaching you the fundamentals than any paid resource or video. The manual tells you exactly what the language tools are.
However, knowing what a tool does is different from knowing how to build with it safely.
Since Lua was created, a lot has changed in software development, including the way we write code. TDD and BDD have become the norm for many software teams, yet Lua doesn’t seem to get the same treatment as languages like Go or Python when it comes to writing unit tests. This guide aims to change that by treating Lua testing as a first-class citizen.
Traditional learning resources usually fail software teams in one of two ways:
This guide approaches programming where you mimick the actual daily workflow of a software engineer.
You will:
Lua code can easily become hard to reason about, especially with its prototypes via the metatable approach and the inherent lack of typed data. By writing tests first, you eliminate the guesswork and ensure your code is correct, readable, and resilient.
To get the most out of this guide, you should comfortably meet the following requirements:
I have multiple years experience transitioning software teams and codebases to Test Driven Development, mainly in C#.
For the last two years, I have been enjoying writing Lua instead of Python for many personal projects. Along the way, I developed Check Your Lua, one of the libaries used in this book to teach you TDD. This library helps me develop clean Lua code with minimal bugs. I feel much more comfortable selling code with full coverage.
This guide is developed for free by me, Nick Stambaugh. It is published by Luniv Technology, an independent software engineering studio.
If you find this resource valuable, consider contributing to the project:
License: Distributed under the MIT License!