Skip to content

MikeSchulze/gdUnit4Net

Repository files navigation

A Unit Testing Framework in C# for Godot

This version of GdUnit4 is based on Godot v4.2.1.stable.official [b09f793f5] (master branch)

Supported Godot Versions

What is gdUnit4Net

This project provides an API and a VS test adapter to run your Godot C# test in Visual Studio (Code) and JetBrains Rider.

Main Features

  • Writing, executing and debugging tests
  • Configurable template for generating new test-suites when creating test-cases
  • Wide range of assertion methods for verifying the behavior and output of your code
  • Parameterized Tests (Test Cases) for testing functions with multiple sets of inputs and expected outputs
  • Scene runner for simulating different kinds of inputs and actions, such as mouse clicks and keyboard inputs
    For example, you can simulate mouse clicks and keyboard inputs by calling the appropriate methods on the runner instance. Additionally, you can wait for a specific signal to be emitted by the scene, or you can wait for a specific function to return a certain value.
  • Visual Studio Test Adapter to run and debug your tests

There are two packages you need to install

  • gdUnit4.api is the package to enable GdUnit4 to write unit tests in C#.
  • gdUnit4.test.adapter is the GdUnit4 Test Adapter, designed to facilitate the integration of GdUnit4 with test frameworks supporting the Visual Studio Test Platform.

Using the gdunit4.api

Checkout the readme to install the gdunit4.api package.

Install the gdUnit4.test.adapter

Checkout the readme to install the gdunit4.test.adapater package.

Example Project

This example project gives you a short insight into how to set up a Godot project to use the GdUnit4 API and test adapter. It contains a single test suite as an example with two tests, the first test will succeed and the second test will fail.

namespace Examples;

using GdUnit4;
using static GdUnit4.Assertions;

[TestSuite]
public class ExampleTest
{
    [TestCase]
    public void success()
    {
        AssertBool(true).IsTrue();
    }


    [TestCase]
    public void failed()
    {
        AssertBool(false).IsTrue();
    }

}

The test run looks like this.


Documentation

How to Install GdUnit

API Documentation

You Are Welcome To


Contribution Guidelines

Thank you for your interest in contributing to GdUnit4!
To ensure a smooth and collaborative contribution process, please review our contribution guidelines before getting started. These guidelines outline the standards and expectations we uphold in this project.

Code of Conduct: We strictly adhere to the Godot code of conduct in this project. As a contributor, it is important to respect and follow this code to maintain a positive and inclusive community.

Using GitHub Issues: We utilize GitHub issues for tracking feature requests and bug reports. If you have a general question or wish to engage in discussions, we recommend joining the GdUnit Discord Server for specific inquiries.

We value your input and appreciate your contributions to make GdUnit4 even better!

Join GdUnit Server

Thank you for supporting my project


Sponsors