From 9e23368b095f0b66780902dfb4021710e3a74296 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 14 Apr 2024 20:23:30 +0200 Subject: [PATCH] Add test result message after test finished --- addons/besseretests/src/runtimescene.gd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/besseretests/src/runtimescene.gd b/addons/besseretests/src/runtimescene.gd index 9cb4328..c4193e0 100644 --- a/addons/besseretests/src/runtimescene.gd +++ b/addons/besseretests/src/runtimescene.gd @@ -28,6 +28,9 @@ var stats_unknown: int = 0 # To stop any still running test var crashed: bool = false +# To decrease allocations == to increase performance +var temp_test_message: String = "" + # +++ initialization +++ # Startup function func _ready() -> void: @@ -252,8 +255,17 @@ func run_suite(suite: String) -> void: await suite_node.after_each() if crashed: return + temp_test_message = lsanitize(suite_node.test_message) if suite_node.test_message != "" else "[i]No message has been set.[/i]" # Merge result into result dictionary - results.merge({ suite + ":" + test_method["name"].replace("test_", ""): { "status": suite_node.test_status, "message": lsanitize(suite_node.test_message) if suite_node.test_message != "" else "[i]No message has been set.[/i]" } }) + results.merge({ suite + ":" + test_method["name"].replace("test_", ""): { "status": suite_node.test_status, "message": temp_test_message } }) + # Print result + match(suite_node.test_status): + 0: lresu("[color=green]Test " + suite + ":" + test_method["name"].replace("test_", "") + " has passed: " + temp_test_message + "[/color]") + 1: lresu("[color=yellow]Test " + suite + ":" + test_method["name"].replace("test_", "") + " has passed with warnings: " + temp_test_message + "[/color]") + 2: lresu("[color=red]Test " + suite + ":" + test_method["name"].replace("test_", "") + " has failed: " + temp_test_message + "[/color]") + 3: lresu("[color=gray]Test " + suite + ":" + test_method["name"].replace("test_", "") + " was skipped: " + temp_test_message + "[/color]") + 505: lresu("[color=red]Test " + suite + ":" + test_method["name"].replace("test_", "") + " returned an invalid status (did you forget to set the test status?).[/color]") + _: lresu("[color=red]Test " + suite + ":" + test_method["name"].replace("test_", "") + " returned an invalid status.[/color]") # Execute after_all() suite_node.lfunc = "after_all"