Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD-15: Add reset function to mock and spy #15

Closed
MikeSchulze opened this issue Mar 18, 2021 · 1 comment · Fixed by #16
Closed

GD-15: Add reset function to mock and spy #15

MikeSchulze opened this issue Mar 18, 2021 · 1 comment · Fixed by #16
Assignees
Labels
enhancement New feature or request
Projects
Milestone

Comments

@MikeSchulze
Copy link
Owner

I need a reset for used spy or mock for continus testing without creating a new one

Describe the solution you'd like

func test_reset():
	var instance :Node = auto_free(Node.new())
	var spy_node = spy(instance)
	
	# call with different arguments
	spy_node.set_process(false) # 1 times
	spy_node.set_process(true) # 1 times
	spy_node.set_process(true) # 2 times
	
	verify(spy_node, 2).set_process(true)
	verify(spy_node, 1).set_process(false)
	
	# now reset the spy
	reset(spy_node)
	# verify all counters are rested
	verify_no_interactions(spy_node)

This will help a very lot to test different use cases on one spy or mock objet in a single test

@MikeSchulze MikeSchulze added the enhancement New feature or request label Mar 18, 2021
@MikeSchulze MikeSchulze self-assigned this Mar 18, 2021
@MikeSchulze MikeSchulze added this to the beta v0.9.1 milestone Mar 18, 2021
@MikeSchulze MikeSchulze linked a pull request Mar 18, 2021 that will close this issue
@MikeSchulze
Copy link
Owner Author

added beta v0.9.1

@MikeSchulze MikeSchulze added this to To Do in GdUnit3 via automation Mar 22, 2021
@MikeSchulze MikeSchulze moved this from To Do to Done in GdUnit3 Mar 22, 2021
@MikeSchulze MikeSchulze changed the title Add reset function to mock and spy GD-15: Add reset function to mock and spy Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
GdUnit3
  
Done
Development

Successfully merging a pull request may close this issue.

1 participant