This is a community driven best-effort initiative to create a suite of automated tests for all basic Garry's Mod functionality.
Here are some of our primary goals with this project:
- Help catch GLua regressions as soon as an update is released (and someday, we can test the
dev
branch and catch them before they're released!). - Help contributors in the official Garry's Mod repo increase confidence in their PRs
- Improve the Wiki with knowledge gained from writing tests
You can keep an eye on our progress (or find somewhere to jump in and contribute!) in our Issues Tab
This project uses GLuaTest to run the test suite. A secondary goal is actually to improve GLuaTest based on our experiences writing tests here. Please don't be shy about asking for new features or complaining about GLuaTest!
Anyone can contribute test cases!
- Clone this repository into your
addons/
dir - Clone GLuaTest into your
addons/
dir
Now you can add your test suites or make changes to existing ones.
Simply run gluatest_run_tests
in the server console to run the test suite. This works even if you add new files.
All tests go in the lua/tests/gmod/
dir.
It's scoped into three Sections right now:
- Globals (All global Functions)
- Classes (Tests for each Class type like
Entity
,PhysObj
,IMesh
, etc.) - Libraries (Tests for all libraries, like
bit
,ents
, etc.)
Inside each Section, we create new directories for each sub-object.
For example, if you were going to write tests for the File
class, you would:
- Create a new file:
lua/tests/gmod/classes/file/file.lua
and begin writing the meta-level tests for this class - Decide if all Class tests can go in a single file.
- If so, write them all in
lua/tests/gmod/classes/file/file.lua
- If not, we'll make new files for each method or "sets" of methods:
lua/tests/gmod/classes/file/close.lua
lua/tests/gmod/classes/file/endoffile.lua
lua/tests/gmod/classes/file/flush.lua
- If so, write them all in
In general, we want to keep each test file from getting way too big. Given that most methods you test will require 3-5 tests for the "success" cases and at least 1 test for the "failure" case, these can get big quickly.
Once you've added/changed the tests you'd like, simply make a PR. The tests will automatically run inside the PR.