godot_test_main

Macro godot_test_main 

Source
macro_rules! godot_test_main {
    ($($test_name:ident),* $(,)?) => { ... };
}
Expand description

Generates a main function for running Godot tests with cargo test.

This macro creates all the necessary boilerplate for:

  • Setting up libtest_mimic for proper test output
  • Running tests on the main thread (required for macOS)
  • Initializing Godot runtime only once
  • Supporting cargo test filtering and options

§Usage

In your test file (with harness = false in Cargo.toml):

use godot::prelude::*;
use godot_testability_runtime::prelude::*;
use godot_testability_runtime::godot_test_main;

fn test_vectors(scene_tree: &mut Gd<SceneTree>) -> TestResult<()> {
    let v = Vector2::new(1.0, 2.0);
    assert_eq!(v.x, 1.0);
    Ok(())
}

fn test_strings(scene_tree: &mut Gd<SceneTree>) -> TestResult<()> {
    let s = GString::from("test");
    assert!(!s.is_empty());
    Ok(())
}

// Generate the main function with your tests
godot_test_main! {
    test_vectors,
    test_strings,
}