About a year ago, I teased a user interface for a Unit Testing plugin. For many reasons, that version of the plugin was never released. After releasing Nexus Plugin Framework, I started work on a new Unit Testing plugin to release a fully polished Unit Testing plugin for Roblox development.
Why Unit Test
Most developers on the Roblox platform use manual testing for developing systems. While this works for most games, manual testing is a long and fault-prone activity that still leads to major bugs reaching players. Unit testing provides a fast and consistent way to test the logic of games, plugins, and subsystems for cases that could come up in production, both as common cases and edge cases.
How to Write Unit Tests
Writing unit tests for Nexus Unit Testing and TestEZ is described in the docs for both projects:
- Nexus Unit Testing: Writing Tests - Nexus Unit Testing Documentation
- TestEZ: Writing Tests - TestEZ Documentation
For the broader topic of “how to write unit tests”, this thread does not cover practices for creating unit tests. At a super high level, you should focus on:
- “Edge coverage”: Test cases that hit specific logic (ex: the if and else conditions are ran).
- “Branch coverage”: Test cases that reach logic (ex: all cases that determines how an if statement is evaluated is ran)
- “Path coverage”: Test cases that cover all possible branches through all possible edges.
Major Features of the Plugin
- Side buttons for running all tests, only failed tests, or only selected tests.
- Output window that can support very long outputs from tests.
- Nesting tests.
- TestEZ support.
- Plugin actions for allowing shortcuts.
- Theme support, even without restarting Roblox Studio.
V.1.2.0 and newer as of September 24th, 2022 has 3 options:
- Itch.io - Free with the option to donate.
- Rbolox Plugin marketplace - Fixed price of 50,000 Robux. This will change if variable pricing is added by Roblox.
- GitHub - Free.
You are free to start using it and maybe decide to donate back if it proves to be a major aid in developing games. I have been using it for years and it has helped enable tens of thousands of dollars in revenue with relatively small-scale games.
The current design does have some limitations that should be known going in. For bugs, see the README in the GitHub repository.
- When rerunning test cases, the
ModuleScriptis rerun with all tests. This may change in the future since it doesn’t require that much in terms of changes.
- Some tests require a running session. Running tests does not automatically do it and you should skip the test if a running game is not detected.