chore: add GUT test framework

This commit is contained in:
xiaji
2026-05-29 09:16:10 +08:00
parent 5741ba1dc0
commit 07fc763413
808 changed files with 76903 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
extends GutTest
func test_manual_error():
gut.logger.error("This is a manual error")
pass_test('we did it')
func test_manual_warning():
gut.logger.warn("This is a manual warning")
pass_test('we did it')

View File

@@ -0,0 +1 @@
uid://b7cwum48use88

View File

@@ -0,0 +1,25 @@
extends 'res://addons/gut/test.gd'
func test_pass_1():
assert_eq('one', 'one')
func test_pass_2():
assert_eq('two', 'two')
func test_fail_1():
assert_eq(1, 'two')
func test_fail_2():
assert_eq('two', 2)
func test_pending_no_text():
pending()
func test_pending_with_text():
pending('this has text')
func test_parameterized_passing(p=use_parameters([1, 2, 3, 4])):
assert_gt(p, 0)
func test_parameterized_failing(p = use_parameters([[1, 2], [3, 4]])):
assert_eq(p[0], p[1])

View File

@@ -0,0 +1 @@
uid://b6pnje22lv3hj

View File

@@ -0,0 +1,11 @@
extends 'res://addons/gut/test.gd'
func test_pass():
assert_eq('one', 'one')
func test_fail():
assert_eq(1, 'two')
func test_pending():
pending('this has text')

View File

@@ -0,0 +1 @@
uid://cjsptipvnesa1

View File

@@ -0,0 +1,25 @@
extends GutTest
func test_pending_with_null_message():
pending("The < and > in this message mess up the XML")
func test_failure_message_includes_str_of_null_in_message_1():
assert_not_null(null)
func test_failure_message_includes_str_of_null_in_message_2():
assert_eq('null', str(null))
func test_failure_message_includes_str_of_null_in_message_3():
assert_eq('a', 'b', "The < and > in this message mess up the XML")
class TestSkipWithNullMessage:
extends GutTest
func should_skip():
return null
func test_something_that_is_skipped():
assert_true(false, 'hello world')

View File

@@ -0,0 +1 @@
uid://k2sec8vc8qfb

View File

@@ -0,0 +1,23 @@
extends 'res://addons/gut/test.gd'
func more_accurate_wait_time(time_to_wait_msec : int)->void:
gut.p(str('-- Awaiting ', time_to_wait_msec / 1000.0, ' second(s) -- '))
var start := Time.get_ticks_msec()
while (Time.get_ticks_msec() - start < time_to_wait_msec):
await get_tree().process_frame
func test_pass_time_taken_about_half_s():
await more_accurate_wait_time(500)
assert_eq('one', 'one')
func test_fail_time_taken_about_half_s():
await more_accurate_wait_time(500)
assert_eq(1, 'two')
func test_pending_time_taken_about_half_s():
await more_accurate_wait_time(500)
pending('this has text')
func test_pass_time_taken_about_2s():
await more_accurate_wait_time(2000)
assert_eq('one', 'one')

View File

@@ -0,0 +1 @@
uid://c3xtlyqvys7ls

View File

@@ -0,0 +1,30 @@
extends 'res://addons/gut/test.gd'
class TestClassOne:
extends 'res://addons/gut/test.gd'
func test_pass_1():
assert_eq('one', 'one')
func test_fail_1():
assert_eq(1, 'two')
func test_pending_with_text():
pending('this has text')
class TestClassTwo:
extends 'res://addons/gut/test.gd'
func test_pass_1():
assert_eq('one', 'one')
func test_fail_1():
assert_eq(1, 'two')
func test_pending_with_text():
pending('this has text')

View File

@@ -0,0 +1 @@
uid://dikra3pwwycgc