Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TDD and unit tests, GML Game Maker Language

I'm super n00bs to GML and TDD. I would like to practice test driven development and unit tests to Game Maker Language, GML. Is it possible since the GML is event driven? I've not had the fortune of finding many examples or tutorials on how to implement unit test and test driven development in GML.

How do you write unit tests in game maker language?

like image 328
Onizuka Avatar asked Oct 21 '22 22:10

Onizuka


1 Answers

I have started to write a test framework specifically for GML. Its called hobo_test and you can find it on github. The goal is to provide a set of objects / scripts that you can drag and drop into any project (from the finder) and then start to write some simple tests.

with(o_player)
  {
  before_lives = num_lives
  take_damage();
  it("should decrease the number of lives",  before_lives-1, num_lives);
  }

This will update the counters on the TEST object which will draw the results of all your tests (Green dot for success, and red for failure). Upon a failing test it will print out the should statement that you have written with the expected and actual results.

I have found that the limitations of GML have led me to write a lot of helper methods and fight with the lack of exception handling.

To my knowledge this is the only existing testing framework for GameMaker and still has a long way to go in order to allow for complete TDD when developing a game. (I was able to write minesweeper clone with the current iteration). I plan on continuing the growth of the project and hopefully make it more robust and more effortless to use.

like image 112
Dan Bradbury Avatar answered Jan 02 '23 20:01

Dan Bradbury