Skip to content

Commit

Permalink
Added player test start. Took me forever to find out that I have to s…
Browse files Browse the repository at this point in the history
…et a non 0,0 Player position in order to have it actually receive the input events. This is not documented in the GUT docs and I might create a PR to add it.
  • Loading branch information
ArSn committed Apr 14, 2024
1 parent 428aa89 commit bf310c0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/unit/test_player.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extends GutTest

var Player: PackedScene = load('res://player.tscn')

var _sender = InputSender.new()

func after_each():
_sender.release_all()
_sender.clear()

func test_move_right_adds_positive_x_velocity():
var player = add_child_autofree(Player.instantiate())
# todo: find out why it only works when setting the position here, 0,0 does not work
player.position = Vector2(1, 1)

_sender.action_down("move_right").wait_frames(1)
await(_sender.idle)

assert_gt(player.position.x, 0.0, "Player should move right")

0 comments on commit bf310c0

Please sign in to comment.