A unit testing framework for C# scripts in Godot. See the Godot Asset Page Here: https://godotengine.org/asset-library/asset/2100
Optimized and multithreaded to allow you to run your tests at blazingly fast speeds! 🔥🚀
A minimal and simple user-interface that displays all the unit tests and results all in a single dock.
Sometimes you might just want to run a certain set of tests. That's now possible with the filter option. Include a filter to match whatever tests you need to run.
Minimal overhead added to create unit tests. Declare a unit test function by adding a [CSTestFunction]
onto a static, parameterless function with a Result
return type. After that, you can load and run your tests effortlessly.
- Press the build button before enabling the plugin. This is to allow the plugin to build the necessary files to run.
- Ensure the plugin is enabled in the Godot editor.
- In a script, write a test function. Test functions must be static, parameterless, be prepended with the
[CSTestFunction]
attribute, and return aResult
type, indicating it's success or failure.- If an exception is thrown in your function, it will be counted as a fail.
- Open the "C# Testing" ui on the editor (it should be on the right by default).
- Click "Load Tests". This should populate the dock with a list of all your test functions and the types that they reside in.
- Click on "Run Tests" to run each of the tests.
using GdMUT;
/// <summary>
/// This is a test class for GDMUT. This is purely for demonstration. If you added
/// this into your project, feel free to delete it =)
/// </summary>
public class TestClass
{
#if TOOLS
[CSTestFunction]
public static Result ExamplePass()
{
int x = 0;
x *= 100;
return (x == 0) ? Result.Success : Result.Failure;
}
[CSTestFunction]
public static Result ExampleFail()
{
int x = 0;
x *= 100;
return (x != 0) ? Result.Success : Result.Failure;
}
[CSTestFunction]
public static Result ExampleCustomFail()
{
int x = 0;
x *= 100;
return (x != 0)
? Result.Success
: new Result(false, "You can't multiply 0 and expect anything else than 0!");
}
[CSTestFunction]
public static Result ExampleCustomSuccess()
{
int x = 0;
x *= 100;
return (x == 0) ? new Result(true, "Proved that 0 * 100 = 0") : Result.Failure;
}
#endif
}
NOTE: The '#region
' and '#if TOOLS
' preprocessor directives are optional. Just good practice :)
Multithreaded testsTest filtering (filter by name which tests to run)- Parameterized functions
- Async functions