A Godot Unit Test Framework

GdUnit3 GitHub release (latest by date)

A Godot Integrated Unit Testing Framework


GitHub branch checks state




What is GdUnit3

GdUnit3 is a framework for testing GdScrips and Scenes within the Godot editor. GdUnit3 is very useful for test-driven development and will help you get your code bug-free.

Features

  • Fully integrated in the Godot editor
  • Run test-suite(s) by using the context menu on FileSystem, ScriptEditor or GdUnitInspector
  • Create test's directly from the ScriptEditor
  • Configurable template for the creation of a new test-suite
  • A spacious set of Asserts use to verify your code
  • Argument matchers to verify the behavior of a function call by a specified argument type.
  • Fluent syntax support
  • Test Fuzzing support
  • Mocking a class to simulate the implementation which you define the output of certain function
  • Spy on a instance to verify that a function has been called with certain parameters.
  • Mock or Spy on a Scene
  • Provides a scene runner to simulate interactions on a scene
    • Simulate by Input events like mouse and/or keyboard
    • Simulate scene processing by a certain number of frames
    • Simulate scene proccessing by waiting for a specific signal
  • Update Notifier to install latest version from GitHub
  • Command Line Tool
  • CI - Continuous Integration support

Short Example

# this assertion succeeds
assert_int(13).is_not_negative()

# this assertion fail because the value '-13' is negative
assert_int(-13).is_not_negative()

To Install the GdUnit3 Plugin

You have to install the GdUnit3 plugin over the AssetLib in the Godot Editor. image

  1. Select the tab AssetLib in the middle on the top
  2. Enter GdUnit3 in the search bar
  3. Select GdUnit3 and press the install button
  4. Finally you have to activate the plugin

image

  1. Choose Project->Project Settings, click the Plugins tab and activate GdUnit.

image

  1. After activation the GdUnit3 inspector is displayed in the top left
  2. Done, GdUnit is ready to use

You are welcome to report bugs or create new feature requests. I would also appreciate feedback.

Join GdUnit3 Server

Documentation

GitHub issues GitHub closed issues
GitHub top language GitHub code size in bytes

Comments
  • GD-113: Updating to v1.0.0 wipes out existing plugin on Windows10 (tar ends with `Cannot connect to C:`)

    GD-113: Updating to v1.0.0 wipes out existing plugin on Windows10 (tar ends with `Cannot connect to C:`)

    The used Godot version: 3.3

    OS including version: Windows 10

    Describe the bug After upgrading to v1.0.0, the addons/gdunit3 directory gets wiped out.

    Steps to Reproduce

    • Install gdUnit from the assetlib. You get version v0.9.7-rc
    • Activate it. You get a prompt to upgrade.
    • Upgrade
    • Wait

    Expected: the plugin upgrades itself Actual: the plugin wipes out the addons/gdunit3 directory

    You could also update the assetlib version to v1.0.0 to temporarily work around this problem.

  • GD-24: [Master] Request for nonexistent project setting: gdunit/report/error_notification

    GD-24: [Master] Request for nonexistent project setting: gdunit/report/error_notification

    The used Godot version: 3.3.rc6

    OS including version: Ubuntu 20.04 x64 x11 GTX 1650M (proprietary drives)

    Describe the bug I just cloned the master and copied gdUnit3 and GdCommons to /addons folders. When I started godot on my existing project, the following error shows up: Request for nonexistent project setting: gdunit/report/error_notification.

    When testing on a new clean project, there are two more erros:

     Request for nonexistent project setting: gdunit/report/error_notification.
     Couldn't create an ENet multiplayer server.
     modules/gdscript/gdscript_functions.cpp:803 - Can't establish server, error code: 20
    

    Steps to Reproduce Steps to reproduce the behavior:

    1. Open the test project
    2. See error Request for nonexistent project setting: gdunit/report/error_notification.

    Minimal reproduction project: test_project.zip

  • GD-112: Running tests in editor does not reveal compilation errors

    GD-112: Running tests in editor does not reveal compilation errors

    Version 1.0.0

    The used Godot version: v3.3.2.stable.arch_linux

    OS including version: Manjaro, kernel 5.20.49-1 (64 bit)

    Describe the bug When the code under test has a compilation error, running the tests normally (not in debug mode) will return green. This means that these test results are actually lying to us, because non-compiling code can by definition not complete the test :).

    Running the tests in debug mode does break at the compilation error, so currently I only run tests this way. The runtest.sh -a command does also break at the error and opens a debug prompt. However running with the -c option wont continue the testing (probably another bug report).

    Steps to Reproduce

    1. Open the test_gdunit project.
    2. Run the tests in the test folder.
    3. Note how the tests return green.
    4. Run the tests in debug mode.
    5. Note how line 6 in Main.gd does not actually compile. Meaning that the green test results from the non-debug run were actually lying to us.

    Minimal reproduction project: test_gdunit.zip

  • GD-111: Auto-update from 0.9.7-rc to 1.0.0 removes old version, but does not re-install new version

    GD-111: Auto-update from 0.9.7-rc to 1.0.0 removes old version, but does not re-install new version

    The used Godot version: v3.3.2.stable.arch_linux

    OS including version: Manjaro, kernel 5.10.49-1 (64-bit) Windows 10 (#113 )

    Describe the bug After running the auto-update, the addons directory is empty. The runtest.cmd and runtest.sh scripts are still there.

    Steps to Reproduce

    1. Start a new Godot project.
    2. Go to the "AssetLib" tab ad install GdUnit3. At the moment (2021-07-22) this installs 0.9.7-rc (which I'm guessing will soon change to 1.0.0). Don't uncheck any files when installing.
    3. Enable the plugin.
    4. The updater pops up as expected. And notifies that v1.0.0 is available.
    5. Click update
    6. The update bar will show that the download is successful and the installation is complete.
    7. Look in the addons folder, the plugin is no longer there. An update.zip sits in the project directory, with the files for v1.0.0 inside.

    Workaround As workaround you have to reinstall and press cancel on the upgrade screen

  • GD-32: Unable to mock script which uses snake_case naming convention

    GD-32: Unable to mock script which uses snake_case naming convention

    The used Godot version: 3.3-rc6

    OS including version: Ubuntu 20.04 x64 x11 GTX 1650M (proprietary drives)

    Describe the bug When trying to mock a script which has a snake_case.gd naming convention, gdUnit3 tries to use the file name to find the class, so if I'm trying to mock a class, named main_player.gd or mob.gd, gdUnit3 will extends main_player and mob classes, which doesn't exists.

    Since snake_case is the convention recomended by godot style guide, many users will have the same problem.

    Steps to Reproduce

    1. Create a new script using snake_case.gd
    2. Try to create a mock of this script
    3. Run any tests and the error will appear

    Minimal reproduction project: N/A

  • GD-347: Allow to compare real vs int typed dictionary

    GD-347: Allow to compare real vs int typed dictionary

    The used Godot version: v3.5.1.stable.official [6fed1ffa3]

    OS including version: Windows 11

    Describe the bug I'm using a dictionary in a parameterised test in GdUnit3 2.3.1. The dictionary contains key/value pairs of type string/double. When I define my expected value dictionary, I define the values using whole numbers (i.e. without the decimal point). The difference report shows the actual values are identical to the expected values (see image). image The expected values in the above test run were defined as { left = 50, top = 50, right = 50, bottom = 50 }. As a workaround, if I define my expected values as { left = 50.0, top = 50.0, right = 50.0, bottom = 50.0 } then the test passes.

    Steps to Reproduce

    1. Create a parameterised test containing a Dictionary expected value containing key/value pairs of type string/double.
    2. Create a test parameter containing valid integer values
    3. Run the test
    4. Observe the assert fails but the "expecting" is the same as the "actual" in the report.
  • GD-331: Timeout of test cases lead to crash of test execution

    GD-331: Timeout of test cases lead to crash of test execution

    The used Godot version: 3.5

    OS including version: Max OS, Windows

    Describe the bug https://github.com/MikeSchulze/gdUnit3/blob/master/addons/gdUnit3/src/core/GdUnitExecutor.gd#L375 duplicate fails sometimes. I bumped the timeout for tests and it looks like that resolved the issue. This leads me to believe this is related to timeout logic. Maybe it deletes the node which causes duplicate to fail. I have not had time to investigate further yet.

    Steps to Reproduce

    • Run this simple test that times out
    extends GdUnitTestSuite
    
    func test_timeout(timeout=1500):
    	var node := Node.new()
    	node.filename = "does_not_exist"
    	add_child(node)
    	yield(get_tree().create_timer(60), "timeout")
    

    Errors: image

    Reaults:

    A node must have an valid filename. Means the file must exists or you have to set to an empty string.

    Minimal reproduction project:

  • GD-289: Spy do not copies initalizied variables

    GD-289: Spy do not copies initalizied variables

    The used Godot version: all

    OS including version: all

    Describe the bug I am trying to spy on an instance, the spy object has invalid/unset variables.

    Steps to Reproduce

    • Create a simple class and initialize a variable in the constructor.
    • create a spy on this instance
    • check the variable on the spy object The variable is not set.

    Minimal reproduction project:

    res://addons/gdUnit3/test/mocker/resources/TestPersion.gd

    extends Object
    
    
    var _name
    
    func _init(name :String):
    	_name = name
    
    func name() -> String:
    	return _name
    
    
    func test_spy_copied_class_members():
    	var instance = auto_free(load("res://addons/gdUnit3/test/mocker/resources/TestPersion.gd").new("user-x"))
    	assert_str(instance.name()).is_equal("user-x")
    	
    	# spy it
    	var spy_instance = spy(instance)
    	
    	# verify members are inital copied 
    	assert_str(spy_instance.name()).is_equal("user-x") <--- Fails
    
  • GD-243: CLI doesn't fail when test code throws errors

    GD-243: CLI doesn't fail when test code throws errors

    Hi,

    As we discussed in a previous issue, you can run gdUnit3 tests in "Debug" mode (fails if the code throws an error).

    How do I run it in this mode, when running the tests as part of a build? Currently, I'm using this code:

    ./Godot_v3.4.2-stable_linux_headless.64 -s addons/gdUnit3/bin/GdUnitCmdTool.gd --add tests/test_cases/gdunit
    

    I just noticed that several tests are failing due to a refactoring change. (The game code is correct, but the test code refers to variables that no longer exist.) But, the build still passes, and shows that all tests are passing. Sure enough, if I use "Run tests" in Godot, I see everything pass; if I use "Debug tests," I see errors (not failures).

    Is there a way to make the build fail in this scenario? I think a lot of other test frameworks (e.g. NUnit) return a status code on exit indicating a failure. That would be helpful here (tests look like they pass, but there are errors).

  • GD-205: Nested testing suits

    GD-205: Nested testing suits

    Now that im following unit testing best practices and aiming for higher code coverage i end up with lots of tests within the same suite, which makes it a little hard to read. I noticed that you can collapse the tests by their testing suite, I was wondering if there is a way to nest or group related suites. So that the ui allows to go from this:

    > my suite
      - test a1
      - test a2
      - test a3
      - test b1
      - test b2
    

    To this:

    > my suite
      > a test suite
        - test a1
        - test a2
        - test a3
      > b test suite
        - test b1
        - test b2
    
  • Note: performance issue?

    Note: performance issue?

  • GD-363: Update Documentation,  Is class_name on scripts a hard requirement?

    GD-363: Update Documentation, Is class_name on scripts a hard requirement?

    Discussed in https://github.com/MikeSchulze/gdUnit3/discussions/361

    Originally posted by maximinus December 31, 2022 Started testing GDUnit this week and it took me an age to get the first test running, because I could not find a way to reference the object I was testing. After really carefully looking at the code images in the docs, I finally discovered that I had to add class_name to the gdscript node I was testing, and then I could reference that object in the test.

    I think this needs to be made a bit clearer in the tutorial because it nearly made me delete the addon.

    Secondly, is this a hard requirement? I'm not necessarily against adding class_name, however it's something I've typically not done with my gdscript code before.

  • GD-353: Update GdUnit Documentation

    GD-353: Update GdUnit Documentation

    A Task is not a bug or feature request

    Description

    Document the new settings #345 #347

    Document diverenze between runtime and debug test execution. #349

    Document SceneRunner changes #365

Prosper - General app launcher with support for translation, calc, currency and unit conversion.
Prosper - General app launcher with support for translation, calc, currency and unit conversion.

Prosper Description General app launcher with support for translation, calc, currency and unit conversion. Global shortcut is Option (Alt) + Space Fea

Dec 6, 2022
Kubernetes-native framework for test definition and execution

████████ ███████ ███████ ████████ ██ ██ ██ ██ ██████ ███████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████

Dec 31, 2022
terraform-plugin-mux Example (framework + framework)

Terraform Provider Scaffolding (Terraform Plugin Framework) This template repository is built on the Terraform Plugin Framework. The template reposito

Feb 8, 2022
Aceptadora provides the boilerplate to orchestrate the containers for an acceptance test.

aceptadora Aceptadora provides the boilerplate to orchestrate the containers for an acceptance test. Aceptadora is a replacement for docker-compose in

Nov 16, 2022
Test and benchmark KPHP code
Test and benchmark KPHP code

Overview ktest is a tool that makes kphp programs easier to test. ktest phpunit can run PHPUnit tests using KPHP ktest bench run benchmarks using KPHP

Dec 14, 2022
A simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app to Docker Hub

go-pipeline-demo A repository containing a simple Go app and GitHub workflow that shows how to use GitHub Actions to test, build and deploy a Go app t

Nov 17, 2021
This is a K6 extension to be able to test using NATS protocol
This is a K6 extension to be able to test using NATS protocol

xk6-nats This is a k6 extension using the xk6 system, that allows to use NATS protocol. ❗ This is a proof of concept, isn't supported by the k6 team,

Nov 24, 2022
General-purpose actions for test and release in Go

go-actions This repository provides general-purpose actions for Go. setup This action runs actions/setup-go with actions/cache. For example, jobs: l

Nov 28, 2021
A docker image for test redis HA

Guide 测试集群模式(Test Redis Cluster) redis-test --arch cluster 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 测试哨兵模式(TEST Redis Sentinel) redis-test --arc

Nov 30, 2021
used Terratest to write a test in GO for validating a Terraform module.

Terraform--Terragrant--Test used Terratest to write a test in GO for validating a Terraform module. will write a test for a Terraform module using Ter

Dec 4, 2021
k6 extension to load test Apache Kafka with support for Avro messages and SASL Authentication

xk6-kafka This project is a k6 extension that can be used to load test Kafka, using a producer. Per each connection to Kafka, many messages can be sen

Dec 7, 2021
Test Operator using operator-sdk 1.15

test-operator Test Operator using operator-sdk 1.15 operator-sdk init --domain rbt.com --repo github.com/ravitri/test-operator Writing kustomize manif

Dec 28, 2021
Output all versions of a local git repo, which could be used as test data for your ML program.

gitwalker Output all versions of a local git repo, which could be used as test data for your ML program. Notice This program is under development. Cur

Dec 27, 2021
Stockbit Test : Aldo Verrell Valiant

stockbit-test Stockbit Test : Aldo Verrell Valiant In this repository, there are answers to questions number 1,3, and 4. The answer to question number

Dec 28, 2021
Stockbit Test no. 2

movies_service Stockbit Test no. 2 This microservice is built with Clean Architecture. There are 2 routes: Search & Get movie detail by ID http://loca

Dec 28, 2021
Test - A program that validates your progress on the SQLite challenge

SQLite Challenge Tester This is a program that validates your progress on the SQ

Jan 6, 2022
Navmux - Test project evaluate writing the equivalent of boat repro using go

navmux Test project evaluate writing the equivalent of boat repro using go. The

Jan 10, 2022
Topology-tester - Application to easily test microservice topologies and distributed tracing including K8s and Istio

Topology Tester The Topology Tester app allows you to quickly build a dynamic mi

Jan 14, 2022
First Go project. Backend hiring test for Array engineering.

BACKEND TEST 1 Submitted by: Mitchell Sullivan Intro This is basically my first-ever project in Go. As such, it's quite simple and bears little resemb

Jan 19, 2022