From 496484dc6df8c682c5465762b5d47915f6945688 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Mon, 9 Apr 2018 20:35:02 -0400 Subject: [PATCH] Add sample unit test script and test directories --- game/tests/integration/.gitkeeper | 0 game/tests/test.tscn | 44 +++++++++++++++++++++++++++++++ game/tests/unit/.gitkeeper | 0 game/tests/unit/test_example.gd | 16 +++++++++++ 4 files changed, 60 insertions(+) create mode 100644 game/tests/integration/.gitkeeper create mode 100644 game/tests/test.tscn create mode 100644 game/tests/unit/.gitkeeper create mode 100644 game/tests/unit/test_example.gd diff --git a/game/tests/integration/.gitkeeper b/game/tests/integration/.gitkeeper new file mode 100644 index 0000000..e69de29 diff --git a/game/tests/test.tscn b/game/tests/test.tscn new file mode 100644 index 0000000..a97654f --- /dev/null +++ b/game/tests/test.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://addons/gut/gut.gd" type="Script" id=1] +[ext_resource path="res://addons/gut/icon.png" type="Texture" id=2] + +[node name="Gut" type="WindowDialog" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 48.0 +margin_bottom = 40.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +popup_exclusive = false +window_title = "" +resizable = false +script = ExtResource( 1 ) +__meta__ = { +"_editor_icon": ExtResource( 2 ) +} +_run_on_load = false +_select_script = null +_tests_like = null +_should_print_to_console = true +_log_level = 1 +_yield_between_tests = true +_disable_strict_datatype_checks = false +_test_prefix = "test_" +_file_prefix = "test_" +_file_extension = ".gd" +_directory1 = "res://tests/unit" +_directory2 = "res://tests/integration" +_directory3 = "" +_directory4 = "" +_directory5 = "" +_directory6 = "" + + diff --git a/game/tests/unit/.gitkeeper b/game/tests/unit/.gitkeeper new file mode 100644 index 0000000..e69de29 diff --git a/game/tests/unit/test_example.gd b/game/tests/unit/test_example.gd new file mode 100644 index 0000000..592735f --- /dev/null +++ b/game/tests/unit/test_example.gd @@ -0,0 +1,16 @@ +extends "res://addons/gut/test.gd" +# @see https://github.com/bitwes/Gut#creating_tests +var node = null; + +func setup(): + var n = preload('res://tests/test-2d.tscn') + node = n.instance() + +func test_node_has_exit_button(): + var b = node.get_node('CenterContainer/exit') + assert_true(b != null, 'CenterContainer/exit is not null') + if (b): + assert_true(b.get_class() == 'Button', 'CenterContainer/exit is a Button') + var connected = gut.p(b.get_signal_connection_list('pressed')) + assert_true(connected != [], 'CenterContainer/exit has connected signals') +