mikeschulze / gdunit4 Goto Github PK
View Code? Open in Web Editor NEWA Godot Unit Test Framework. Support for GDScript and C# unit testing
License: MIT License
A Godot Unit Test Framework. Support for GDScript and C# unit testing
License: MIT License
find replacement for script_editor._menu_option(EDITOR_ACTIONS.FILE_SAVE_ALL)
res://addons/gdUnit4/src/ui/GdUnitInspector.gd:323
described by rainlizard on Discord
https://discordapp.com/channels/212250894228652034/659154083130769438/1031112456354926642
get_editor_interface().get_script_editor().get_child(0).get_child(0).get_child(0).get_popup().emit_signal("id_pressed", 14)
<See --> Don't report -1 as failure line number at runtime mode](MikeSchulze/gdUnit3#349)
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
ALL
Describe the bug
remove this code when the bug is fixed
res://addons/gdUnit4/src/core/GdUnitClassDoubler.gd
static func _hotfix_invalid_method_descriptors(method :Dictionary):
if method["name"] == "get_script":
method["return"]["type"] = GdObjects.TYPE_VARIANT
Minimal reproduction project:
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
ALL
Describe the bug
Mocking inner classes is broken in Godot4
Steps to Reproduce
run res://addons/gdUnit4/test/mocker/GdUnitMockerTest.gd
test cases:
test_mock_class_with_inner_classs
test_mock_verify_emit_signal
res://addons/gdUnit4/test/spy/GdUnitSpyTest.gd : _test_spy_on_inner_class
res://addons/gdUnit4/test/cmd/CmdCommandHandlerTest.gd : test_execute_commands_with_cb_registered
n.a.
the tests are commented out, must be reactivated when the bug is fixed
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
All
Describe the bug
I want to mock on classes to define a custom return value without need to instanciate the full class.
On Godot 3 I was able to overwrite all functions of an Engine class to trag if is called or not, this is now broken on Godot4.
Like this simple example shows the overwritten function is not called anymore in Godot4.
class CustomNode extends Node:
func foo():
pass
class TestNode extends CustomNode:
# overwrite the orignal Node:is_inside_tree() function
func is_inside_tree() -> bool:
prints("is_inside_tree")
return true
func _ready():
var node := TestNode.new()
node.is_inside_tree()
Steps to Reproduce
Run testcase GdUnitMockerTest:test_mock_by_script_path
do not cast a mock back to original class type!
use allways
var mocked_node = mock(Node)
and not
var mocked_node :Node = mock(Node)
renable disabled test cases
and remove excluded from GdUnitClassDoubler @EXCLUDE_VIRTUAL_FUNCTIONS
With Godot4 GDScriptFunctionState
was removed and no equivalent exists.
Is your feature request related to a problem? Please describe.
I want to have better readable code to test my asserts works as expected
Describe the solution you'd like
assert_failure(func(): assert_bool(true).is_not_equal(true)) \
.has_message("Expecting:\n 'true'\n not equal to\n 'true'")
To use
assert_fail(await assert_signal(null, GdUnitAssert.EXPECT_FAIL).wait_until(50).is_emitted("test_signal_counted"))\
.has_failure_message("Can't wait for signal checked a NULL obsject.")
instead of unreadable code like this:
(await assert_signal(null, GdUnitAssert.EXPECT_FAIL).wait_until(50).is_emitted("test_signal_counted"))\
.has_failure_message("Can't wait for signal checked a NULL object.")
For GdUnit4 we use an alpha version of Godot4 where no image exists on barichello/godot-ci
We need to build your own image or dowload and install the Godot version manually
bring the workflow back in a succes state
https://github.com/bitbrain/godot-setup-action
No Duplicates.
The used Godot version:
v4.0.beta4.official [e6751549c] Vulkan AKA Forward+
OS including version:
OS: Linux Mint 20.3 Cinnamon 5.2.7
Kernel: 5.4.0-131-generic
CPU: AMD Ryzen 9 3900X 12-Core Processor × 12
GPU: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5700 XT]
Describe the bug
Specific Error from Godot:
res://test/SettingsTest.gd:18 - Parse Error: Used tab character for indentation instead of space as used before in the file.
Steps to Reproduce
Steps to reproduce the behavior:
Minimal reproduction project:
GDUnit4NullReturnIssue.zip
Note:
This is also an issue for GDUnit3 but it does not fail in Godot 3.
Describe What
Since migrated to Godot 4 the GdUnit plugin auto upgrade is broken.
Describe Why
Needs to rework because of Godo4 API changes
ZIPReader
Dev hints
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
Windows 10
Describe the bug
Runtime of testsuite res://addons/gdUnit4/test/fuzzers/FuzzerToolTest.gd
is increased
Godot 3.5
Steps to Reproduce
Think about to use callable instead of script code injection
https://docs.godotengine.org/en/latest/classes/class_callable.html?highlight=callable
Minimal reproduction project:
The used Godot version:
v4.0.beta4.official [e6751549c]
OS including version:
all
Describe the bug
For details show Godot Issue
Minimal reproduction project:
The used Godot version:
v4.0.beta4.official [e6751549c] Vulkan AKA Forward+
OS including version:
OS: Linux Mint 20.3 Cinnamon 5.2.7
Kernel: 5.4.0-131-generic
CPU: AMD Ryzen 9 3900X 12-Core Processor × 12
GPU: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5700 XT]
Describe the bug
Spy does not count interactions on the parent class, so verify can not be used correctly.
Steps to Reproduce
Minimal reproduction project:
Describe What
With GdUnit3 we had C# support and we want to have it with GdUnit4 too.
Describe Why
Requested by GdUnit3 users :)
Dev hints
needs to evaluate how c# is included in Godot4
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
All
Describe the bug
Godot issue 67547
res://addons/gdUnit4/test/spy/GdUnitSpyTest.gd
func test_spy_on_inner_class():
var instance :AdvancedTestClass.AtmosphereData = auto_free(AdvancedTestClass.AtmosphereData.new())
var spy_instance :AdvancedTestClass.AtmosphereData = spy(instance)
results at runtime in
Trying to assign value of type '' to a variable of type 'AdvancedTestClass.gd'.
Steps to Reproduce
run res://addons/gdUnit4/test/spy/GdUnitSpyTest.gd
test_spy_on_inner_class
free manually the instance at test end
revert to using auto_free
var instance :AdvancedTestClass.AtmosphereData = auto_free(AdvancedTestClass.AtmosphereData.new())
Minimal reproduction project:
The used Godot version:
v4.0.beta8.official [45cac42c0]
OS including version:
ALL
scene/resources/resource_format_text.cpp:452 - res://addons/gdUnit4/src/ui/GdUnitToolsDialog.tscn:3 - ext_resource, invalid UUID: uid://df84cyfuh76m8 - using text path instead: res://icon.png
Resource file not found: res://icon.png.
scene/resources/resource_format_text.cpp:178 - res://addons/gdUnit4/src/ui/GdUnitToolsDialog.tscn:135 - Parse Error: [ext_resource] referenced non-loaded resource at: res://icon.png
Steps to Reproduce
Minimal reproduction project:
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
all
Describe the bug
Open the GdUnit settings shows invalide sized settings dialoge.
The settings are not shown, is broken.
The console shows errors
editor/editor_settings.cpp:221 - EditorSettings::_get - Property not found: text_editor/highlighting/background_color
res://addons/gdUnit4/src/ui/templates/TestSuiteTemplate.gd:32 - Trying to assign value of type 'Nil' to a variable of type 'Color'.
scene/gui/control.cpp:1375 - Nodes with non-equal opposite anchors will have their size overridden after _ready().
If you want to set size, change the anchors or consider using set_deferred().
res://addons/gdUnit4/src/ui/GdUnitToolsDialog.gd:49 - Invalid get index 'minimum_size' (on base: 'Panel').
scene/gui/control.cpp:1375 - Nodes with non-equal opposite anchors will have their size overridden after _ready().
If you want to set size, change the anchors or consider using set_deferred().
res://addons/gdUnit4/src/ui/GdUnitToolsDialog.gd:49 - Invalid get index 'minimum_size' (on base: 'Panel').
res://addons/gdUnit4/src/ui/GdUnitToolsDialog.gd:24 - Invalid get index 'idle_frame' (on base: 'SceneTree').
Steps to Reproduce
The used Godot version:
v4.0.beta4.official [e6751549c]
OS including version:
all
Describe the bug
When open a single script and press right mouse the context menu do not show Create Test
Steps to Reproduce
Create Test
is not shownopen a second script and switch back to the first script, now the context menu is shown
Minimal reproduction project:
The used Godot version:
v4.0.beta14.official [28a24639c]
OS including version:
ALL
Describe the bug
using auto_free()
on a class type breaks the test run.
The main issue is testing for a valid instance by is_instance_valid(instance)
is not handling pure class types
Steps to Reproduce
assert_that(GdUnitTools.free_instance(RefCounted)).is_false()
Minimal reproduction project:
** Godot Issue **
godotengine/godot#71978
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
all
Steps to Reproduce
run testsuite res://addons/gdUnit4/test/spy/GdUnitSpyTest.gd
failing test test_spy_on_inner_class
The used Godot version:
v4.0.beta4.official [e6751549c]
OS including version:
all
Describe the bug
When try to run a test with "run" (no debug) it stucks and no test execution is shown.
Run Tests
Run Tests
A window pops up but nothing happend.
After closing this window the GdUnitInspector shows as tests running state.
Pressing the stop button results in an console error:
platform/windows/os_windows.cpp:686 - Condition "!process_map->has(p_pid)" is true. Returning: FAILED
core/variant/variant_utility.cpp:829 - ERROR checked stopping GdUnit Test Runner. error code: 1
Steps to Reproduce
Run Tests
stucksMinimal reproduction project:
Describe What
I want to cleanup the GdUnitInspector and move all FileSystemDock relevant stuff into an new tools class.
Describe Why
I have already set it up for the ScriptEditor context menu and want it to be consistent
The used Godot version:
v4.0.beta8.official [45cac42c0]
OS including version:
all
Describe the bug
After a new installation, the GdUnit console has no original height and must be resized manually.
Steps to Reproduce
** AC **
The console should have a minimum height.
Minimal reproduction project:
Possible Duplicate of #14 or #12 not sure which.
The used Godot version:
v4.0.beta4.official [e6751549c] Vulkan AKA Forward+
OS including version:
OS: Linux Mint 20.3 Cinnamon 5.2.7
Kernel: 5.4.0-131-generic
CPU: AMD Ryzen 9 3900X 12-Core Processor × 12
GPU: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5700 XT]
Describe the bug
When using spy the spy instance returns null, where as a none spy version of the test returns the correct value as expected.
This error occurs on functions without return type
func get_(data_name):
Steps to Reproduce
use return typed function:
func get_(data_name) -> Variant:
Minimal reproduction project:
The used Godot version:
v4.0.beta8.official [45cac42c0]
OS including version:
all
Describe the bug
I want to install the latest version GdUnit4 v4.0.1-beta
After success install the plugin is failing on activate.
Steps to Reproduce
Minimal reproduction project:
The used Godot version:
v4.0.beta2.official [f8745f2f7]
OS including version:
all
This warnings occuers since we need to set explecit the resource_path to reload a GdScript
Steps to Reproduce
Run test res://addons/gdUnit4/test/GdUnitTestCaseTimeoutTest.gd
Minimal reproduction project:
The used Godot version:
v4.0.beta8.official
OS including version:
macOS 12.5.1
Describe the bug
Unable to enable gdUnit4 4.0.0-alpha, after downloading it via AssetLib. When trying to enable it, an error is displayed instead.
See screenshot with error, also the errors in the Output log:
Transient parent has another exclusive child.
core/config/project_settings.cpp:348 - Property not found: editor_plugins/enabled
Not sure if this is already fixed in the upcoming release, so filing this bug here just in case.
Steps to Reproduce
Minimal reproduction project:
just create a new project
The used Godot version:
v4.0.beta4.official [e6751549c] Vulkan AKA Forward+
OS including version:
OS: Linux Mint 20.3 Cinnamon 5.2.7
Kernel: 5.4.0-131-generic
CPU: AMD Ryzen 9 3900X 12-Core Processor × 12
GPU: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5700 XT]
Describe the bug
The data that comes from the comparison by assert_dict is a series of numbers. It has worked in the past, but this seems to trigger the error and then it does not work from then on. I am not sure what exactly is going on here.
From GDUnit4 Mini Console
line 17: Expecting:
123
10
34
68
15
65
15
84
15
65
15
95
15
86
15
69
15
82
15
83
15
73
15
79
15
78
14
97
14
116
14
97
34
58
32
91
15
48
15
46
48
44
32
34
83
14
116
14
114
105
14
110
103
15
48
15
48
34
93
44
10
34
84
101
115
116
48
34
58
32
91
15
48
15
46
48
44
32
34
83
105
103
15
49
15
53
14
110
14
97
14
108
34
93
10
125
but was
123
10
34
68
14
65
14
84
14
65
14
95
14
86
14
69
14
82
14
83
14
73
14
79
14
78
15
97
15
116
15
97
34
58
32
91
14
48
14
46
48
44
32
34
83
15
116
15
114
105
15
110
103
14
48
14
48
34
93
44
10
34
84
101
115
116
48
34
58
32
91
14
48
14
46
48
44
32
34
83
105
103
14
49
14
53
15
110
15
97
15
108
34
93
10
125
From Output
Godot Engine v4.0.beta4.official.e6751549c - https://godotengine.org
Vulkan API 1.2.131 - Using Vulkan Device #0: AMD - AMD RADV NAVI10
TCP Client: wait to connect ..
TCP Client: Connected to Server: -9223369970589574144
Scan for test suites.
Scanning of 1 test suites took 50ms
tmp = { "DATA_VERSION": [0, "Sig00"], "Test0": [0, "Sig15"] }
tmp is Dictionary? true
tmp = { "DATA_VERSION": [0, "Sig00"], "Test0": [0, "Sig15"] }
tmp is Dictionary? true
tmp = { "DATA_VERSION": [0, "Sig00"], "Test0": [0, "Sig15"] }
tmp is Dictionary? true
Steps to Reproduce
func test_assert_dict_error() ->void:
var dict = {
"DATA_VERSION":[0,"Sig00"],
"Test0":[0,"Sig15"]
}
assert_dict(dict).is_equal({"Data": [0, "String"], "Test0": [0, "Signal"]})
Minimal reproduction project:
GDUnit4AssertDictErrors.zip
Describe What
On Godot3 i use OS
time functions where are replaced by
https://docs.godotengine.org/en/latest/classes/class_time.html?highlight=Time
Describe Why
It must adapt to a new class of time that offers new functions.
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
All
Describe the bug
the test res://addons/gdUnit4/test/scenes/NetworkSceneTest.gd
is broken in Godot4 and needs to be addaped to the new MultiplayerAPIExtension
Steps to Reproduce
uncomment ``res://addons/gdUnit4/test/scenes/NetworkSceneTest.gd` and run
Minimal reproduction project:
Minimal reproduction project:
Describe What
Based on issue godotengine/godot#66999 i had wo workaround by using if/else
Describe Why
Roll back to use match:
func _process_values(left: Token, token_stack: Array, operator: Token) -> Token:
# precheck
if left.is_variable() and operator.is_operator():
var lvalue = left.value()
var value = null
var next_token = token_stack.pop_front() as Token
match operator:
OPERATOR_ADD:
value = lvalue + next_token.value()
OPERATOR_SUB:
value = lvalue - next_token.value()
OPERATOR_MUL:
value = lvalue * next_token.value()
OPERATOR_DIV:
value = lvalue / next_token.value()
OPERATOR_REMAINDER:
value = lvalue & next_token.value()
_:
assert(false) #,"Unsupported operator %s" % operator)
return Variable.new( str(value))
return operator
while current_index < len(input):
token = next_token(input, current_index)
current_index += token._consumed
match token:
TOKEN_ARGUMENT_TYPE:
token = next_token(input, current_index)
arg_type = token._token
TOKEN_ARGUMENT_TYPE_ASIGNMENT:
arg_value = _parse_end_function(input.substr(current_index), true)
current_index += arg_value.length()
TOKEN_ARGUMENT_ASIGNMENT:
arg_value = _parse_end_function(input.substr(current_index), true)
current_index += arg_value.length()
TOKEN_BRACKET_OPEN:
bracket += 1
# if value a function?
if bracket > 1:
# complete the argument value
var func_begin = input.substr(current_index-TOKEN_BRACKET_OPEN._consumed)
var func_body = _parse_end_function(func_begin)
arg_value += func_body
# fix parse index to end of value
current_index += func_body.length() - TOKEN_BRACKET_OPEN._consumed - TOKEN_BRACKET_CLOSE._consumed
TOKEN_BRACKET_CLOSE:
bracket -= 1
# end of function
if bracket == 0:
break
TOKEN_ARGUMENT_SEPARATOR:
if bracket <= 1:
break
Dev hints
see (MikeSchulze/gdUnit3#337)
Describe What
GdUnit4 no longer works to mock/spy on core functions.
Describe Why
With Godot 4 it is no longer allowed to override core functions which breaks the current doubler implementation.
Dev hints
Follow the new double prototype to allow double core functions.
@warning_ignore("native_method_override")
Godot Issues:
godotengine/godot#55024
godotengine/godot#67461
Minimal reproduction project:
Using a dictionary parameter in parametrised tests results into a runtime error
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
All
Describe the bug
When clicking the plus button on Szene tools if takes around 15s before the node class overview is shown.
The problem could be the listing included GdUnit classes e.i. GdUnitTestSuite
Steps to Reproduce
The used Godot version:
v4.0.beta14.official [28a24639c]
[OS including version:
ALL
Describe the bug
Test test_is_public_script_class
is broken since the custom classes are not stored in the godot project file anymore.
ProjectSettings.get_setting("_global_script_classes")
is broken and will be replaced respectively in the next Godot version by
ProjectSettings.get_global_class_list()
Minimal reproduction project:
The used Godot version:
v4.0.beta3.official [01ae26d31]
OS including version:
All
Describe the bug
Using the ProjectSettings._property_get_revert
is broken and result in a runtime error
Steps to Reproduce
Run res://addons/gdUnit4/test/core/GdUnitSettingsTest.gd
Using temporary this workaround and should be replaced by engine function
Engine.set_meta(as_key(name), default)
static func as_key(property_name :String) -> String:
return property_name.replacen("/", "")
static func property_get_revert(property_name :String) -> Variant:
var key := as_key(property_name)
if Engine.has_meta(key):
return Engine.get_meta(key)
return null
The used Godot version:
v4.0.beta4.official [e6751549c]
OS including version:
all
Describe the bug
I want to use the context menu to create a new test case.
It ends up in an error dialog
Steps to Reproduce
Create Test
An error dilalog pops up
A empty testsuite is created.
Minimal reproduction project:
Describe What
With Godot4 the parsing slows down and need to rework on the entire script parser.
check also the fix of MikeSchulze/gdUnit3#359
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.