Crates.io | godot-testability-runtime |
lib.rs | godot-testability-runtime |
version | 0.1.2 |
created_at | 2025-09-18 09:33:32.589289+00 |
updated_at | 2025-09-22 16:22:54.45622+00 |
description | Embedded Godot runtime for comprehensive Rust testing |
homepage | |
repository | https://github.com/bytemeadow/godot-testability-runtime |
max_upload_size | |
id | 1844472 |
size | 73,647 |
Embedded Godot runtime for comprehensive Rust testing - inspired by SwiftGodot's testability framework.
This crate provides the ability to run tests within a real Godot runtime environment, giving you access to the full Godot engine API for comprehensive testing. It's inspired by SwiftGodot's successful embedded testing approach and brings the same capabilities to the Rust ecosystem.
Unlike traditional unit tests that mock or simulate engine behavior, this framework runs your tests inside an actual Godot instance, allowing you to test:
#[test]
functionsAdd to your Cargo.toml
:
[dev-dependencies]
godot-testability-runtime = "0.1"
Write your first embedded test using standard Rust #[test]
functions:
// tests/my_godot_tests.rs
use godot_testability_runtime::prelude::*;
// Simple test using the embedded_test_fn! macro
embedded_test_fn!(test_basic_runtime, {
// This code runs inside a real Godot runtime!
assert!(GodotRuntime::is_running());
// Test runtime execution
let result = "Hello Godot!";
assert_eq!(result, "Hello Godot!");
Ok(())
});
// Test with actual Godot functionality
embedded_test_fn!(test_godot_variants, {
// Test Godot's Variant system
let variant = godot::prelude::Variant::from(42);
assert_eq!(variant.get_type(), godot::prelude::VariantType::INT);
let int_value: i32 = variant.to();
assert_eq!(int_value, 42);
Ok(())
});
Run with: cargo test
use godot_testability_runtime::prelude::*;
// Organize tests into logical groups using standard Rust test modules
mod scene_tests {
use super::*;
embedded_test_fn!(test_node_creation, {
// Test scene tree operations
// - Node creation and parenting
// - Scene loading and instantiation
// - Node lifecycle (ready, tree_entered, etc.)
assert!(GodotRuntime::is_running());
Ok(())
});
embedded_test_fn!(test_scene_loading, {
// Test scene loading functionality
assert!(GodotRuntime::is_running());
Ok(())
});
}
mod physics_tests {
use super::*;
embedded_test_fn!(test_physics_bodies, {
// Test physics body creation and behavior
assert!(GodotRuntime::is_running());
Ok(())
});
}
The framework is designed for automated testing:
# GitHub Actions example
- name: Run Godot Runtime Tests
run: |
# macOS runners have libgodot support
cargo test --release
# Tests automatically download libgodot at build time
This crate uses libgodot - a version of Godot built as a library rather than a standalone application. This allows us to:
┌─────────────────────────────────────┐
│ Your Test Code │
├─────────────────────────────────────┤
│ Testability Framework │
│ (This Crate) │
├─────────────────────────────────────┤
│ FFI Bindings │
│ (Rust ↔ libgodot.dylib) │
├─────────────────────────────────────┤
│ libgodot.dylib │
│ (Embedded Godot Engine) │
└─────────────────────────────────────┘
The tests/
directory contains comprehensive examples:
main.rs
- Complete test suite demonstrating all functionality:
Run examples: cargo test
- All examples run as real tests!
This crate is designed to benefit the entire Rust Godot ecosystem. Contributions are welcome!
Licensed under either of:
at your option.
Bring the power of embedded runtime testing to your Rust Godot projects! 🦀🎮