How to Run Test

Running tests in GdUnit is a straightforward process, and you have several options to choose from:

Using the GdUnit Inspector

The GdUnit Inspector provides various options to run single unit tests or sets of testsuites:

  • Using the Button Bar: You can use the buttons available in the GdUnit Inspector’s to run tests.
    Refer to the Using the Button Bar section for more details.

  • Using the Inspector Tree: The Inspector Tree allows you to run tests from a hierarchical view.
    Explore the Using the Inspector Tree section for instructions on running tests using this approach.

  • Using the Run Overall Button: The Run Overall button enables you to run all tests at once.
    Find more information in the Using the Run Overall Button section.

Using the Editor Context Menu

The Editor Context Menu provides options to run or debug individual test cases or entire testsuites:

  • Using the Context Menu: You can right-click on a specific test case or testsuite in the editor and select the appropriate option from the context menu.
    For detailed steps, refer to the Using the Context Menu section.

Using the FileSystem Context Menu

The FileSystem Context Menu allows you to run or debug individual testsuites or sets of testsuites by selecting the desired testsuite or folder:

FileSystem Context Menu

These options provide flexibility in running tests based on your preferences and requirements.

The GdUnit Test Inspector/Explorer

Definition

The GdUnit inspector provides an overview of the currently executed tests and allows you to navigate them. It allows you to select individual tests and view possible test failures. The integrated status and info bar gives you a quick overview of the last test run.


Button Bar

The button bar contains several buttons that allow you to perform different actions in GdUnit:

Button Description
(1) Opens the GdUnit documentation page in your browser
(2) Opens the GdUnit settings window
(3) Run Overall tests
(4) (Re)Run the tests in runtime mode
(5) (Re)Run the tests in debug mode
(6) Stops the current test run
(7) Displays the version of GdUnit

Note that the keyboard shortcuts for these buttons may vary depending on your specific GdUnit configuration.

Advice
When running tests in GdUnit, it is recommended to first run them in debug mode (4) in order to get the line number where the failure occurred in the test report. This is because Godot does not provide stack trace information when running in runtime mode (3), which can result in the failure line not being displayed in the report.

The Run Overall Button

The Run Overall button provides a convenient way to execute all the tests in your project at once, instead of running them one by one or selecting a custom set of tests. By clicking the “Run Overall” button, you can initiate the execution of all the tests in your project, saving you time and effort. To enable the Run Overall button in GdUnit4, you need to adjust the UI settings.
Once you have enabled the Run Overall button, it should be visible in the inspector.


Status Bar

This area gives you information about the current/last test execution, such as the progress and errors/failures found.
With the arrow buttons, you can navigate back and forth over found failures.

Marker Description
(1) Test execution progress (indicator of test run)
(2) Number of errors found (parse/runtime errors)
(3) Number of test case failures found
(4) Navigate to previous failure
(5) Navigate to next failure
(6) Run discover tests
(7) Sort the tree
(8) Change the tree presentation
  • Sorting Options

    The sorting option controls how the test results are displayed in the inspector tree. You can sort the results by:

    • Name Ascending: Sorts the test cases alphabetically from A to Z.
    • Name Descending: Sorts the test cases alphabetically from Z to A.
    • Test Execution Time: Sorts the test cases based on the time they took to execute, from longest to shortest.
  • Tree Presentation

    The tree presentation setting allows you to switch between two views:

    • Flat View: Displays all test cases in a single, flat list without any hierarchical structure.
    • Tree View: Displays test cases in a hierarchical structure, reflecting the path of your test files and suites.
Advice
Whats the difference between errors and failures?
GdUnit distinguishes between errors and failures. An error is a hard failure such as a test abort or timeout, while a failure is a test error caused by a failed assertion.

Test Run Overview Tree

This area provides an overview of all executed/executing tests and their execution status in real-time. Here, you can navigate through the tests and view the report for each individual test by selecting it. You can also run the currently selected test or test suite again by right-clicking to open a context menu.

Advice
Double-clicking on a test in the test run overview allows you to jump directly to the test or test error if a failure line was reported in Debug Mode (4).

Failure Report

This area displays the failure report of the currently selected failed test.
GdUnit generates the failure report based on the used assert, according to the scheme expected vs current value.


Info Bar

This section provides you with information about the total duration of the test execution and any orphaned nodes found.

  • Time
    The time taken to execute all tests.
  • Orphans
    The number of nodes that were not cleaned up after the execution of the tests. Orphaned nodes can cause memory leaks, and it’s essential to clean them up after the execution of the tests.
Advice
It's recommended to always check for orphaned nodes after the execution of tests to ensure there are no memory leaks in your game/application.

document version v4.3.0


Copyright © 2021-2024 Mike Schulze. Distributed by an MIT license.