5

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?

Onizuka
  • 431
  • 1
  • 4
  • 14

2 Answers2

3

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.

Dan Bradbury
  • 2,071
  • 2
  • 21
  • 27
  • I've been working on a unit test kind of setup whereas yours looks like a Gherkin style acceptance test. Maybe nice to start working on a more complete testing suite? YAL's GMLive might be a nice addition as well as Rubber. – Rob Jan 22 '19 at 08:56
  • @RobQuist been playing around with GMLive recently :D will checkout Rubber as well.. apparently I can't DM you here.. but if you can link your github repo I'd love to see the project you are working on.. Just got back into working on hobo_test and figure more idea sharing is always good – Dan Bradbury Jan 25 '19 at 16:17
0

You can unit test anything that can be called in isolation with a verifiable outcome.

I don't know GML, but what I can glimpse from wikipedia it is a special purpose scripting language. If you manage to call such a script from the outside of wherever this is usually running in and you manage to check on the result that you can test it.

However,

"GML is heavily integrated with the Game Maker environment."

could mean that you can not call any scripts or functions in isolation.

EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
  • Unfortunately the GML won't really run without a runner, and importing / running seperate GML files in a seperate environment is kind of a pain. You're going to have to integrate testing scripts and boot the game in a special way, so that you run the testsuite instead of the game. – Rob Jan 22 '19 at 08:54