创建新工程
This commit is contained in:
57
tests/RunAllTests.gd
Normal file
57
tests/RunAllTests.gd
Normal file
@@ -0,0 +1,57 @@
|
||||
extends Node
|
||||
## 统一测试运行器
|
||||
## 运行所有测试套件
|
||||
|
||||
func _ready():
|
||||
print("\n" + "=".repeat(60))
|
||||
print(" AI TOWN GAME - TEST SUITE")
|
||||
print("=".repeat(60))
|
||||
|
||||
# 运行所有测试
|
||||
await run_all_tests()
|
||||
|
||||
print("\n" + "=".repeat(60))
|
||||
print(" ALL TESTS COMPLETED")
|
||||
print("=".repeat(60) + "\n")
|
||||
|
||||
# 等待一下让用户看到结果
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
get_tree().quit()
|
||||
|
||||
func run_all_tests():
|
||||
"""运行所有测试套件"""
|
||||
|
||||
# 1. 消息协议测试
|
||||
print("\n[TEST SUITE 1/4] Message Protocol Tests")
|
||||
var test_protocol = preload("res://tests/test_message_protocol.gd").new()
|
||||
add_child(test_protocol)
|
||||
await get_tree().process_frame
|
||||
test_protocol.queue_free()
|
||||
|
||||
# 2. 游戏状态管理器测试
|
||||
print("\n[TEST SUITE 2/4] Game State Manager Tests")
|
||||
var test_state = preload("res://tests/test_game_state_manager.gd").new()
|
||||
add_child(test_state)
|
||||
await get_tree().create_timer(0.1).timeout # 等待异步测试完成
|
||||
test_state.queue_free()
|
||||
|
||||
# 3. 角色数据测试
|
||||
print("\n[TEST SUITE 3/4] Character Data Tests")
|
||||
var test_character = preload("res://tests/test_character_data.gd").new()
|
||||
add_child(test_character)
|
||||
await get_tree().process_frame
|
||||
test_character.queue_free()
|
||||
|
||||
# 4. 角色控制器测试
|
||||
print("\n[TEST SUITE 4/5] Character Controller Tests")
|
||||
var test_controller = preload("res://tests/test_character_controller.gd").new()
|
||||
add_child(test_controller)
|
||||
await get_tree().create_timer(2.0).timeout # 等待异步物理测试完成
|
||||
test_controller.queue_free()
|
||||
|
||||
# 5. 输入处理器测试
|
||||
print("\n[TEST SUITE 5/5] Input Handler Tests")
|
||||
var test_input = preload("res://tests/test_input_handler.gd").new()
|
||||
add_child(test_input)
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
test_input.queue_free()
|
||||
Reference in New Issue
Block a user