-
I'm making some simple integration tests where I'm exercising the inputs, but they fail inconsistently and for no obvious reason. My inputs tested are just the directional movement inputs and I know they work when I run the test scene manually. My test is included below.
Feedback on my test pattern is also welcome.
Note these worked pretty consistently when I was working on them during my previous dev session. Today, I started the editor and found gdunit had an update (was on 4.3.4 originally). When I updated to 4.4, all of my Input-based tests started failing. I rolled the add-on back to 4.3.4 and now I'm in this situation. I'm not sure the update had anything related to this, but though I'd share the details. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
This appears to be similar to #379 but using gdscript instead of C#. |
Beta Was this translation helpful? Give feedback.
-
Hi @placer14 that sounds bad. From the internal test coverage, all tests successfully. From the test, it misses input synchronization after the action release. e.g. func test_player__input_movement__right() -> void:
var _runner = scene_runner("res://tests/integration/player/actions_fixture.tscn")
var _player = _runner.invoke("find_child", _player_class)
var original_position = _player.position
_runner.simulate_action_press(Constants.INPUT_RIGHT)
await _runner.await_input_processed()
_runner.simulate_action_release(Constants.INPUT_RIGHT)
await _runner.await_input_processed()
assert_float(original_position.x).is_less(_player.position.x)
assert_float(original_position.y).is_equal(_player.position.y) When you only want to test an action is pressed, you can simplify your test by:
func test_player__input_movement__right() -> void:
var _runner = scene_runner("res://tests/integration/player/actions_fixture.tscn")
var _player = _runner.find_child(_player_class)
var original_position = _player.position
_runner.simulate_action_pressed(Constants.INPUT_RIGHT)
await _runner.await_input_processed()
assert_float(original_position.x).is_less(_player.position.x)
assert_float(original_position.y).is_equal(_player.position.y) If this not helps, please create a bug issue and append an example project to reproduce. |
Beta Was this translation helpful? Give feedback.
For the benefit of others, my flaky tests were due to my input handling. I had a singleton checking
Input.get_vector
twice... inside_process
and in_process_physics
. Unfortunately, I believe the input was being flushed before either of those hooks were called. As such, those inputs were never seen or acted upon.Here's an overview of the changes applied. Before: