Page 1 of 1

i don't understand unit testing-and/or Busted

Posted: Mon Jun 23, 2014 1:22 pm
by DarthGrover
Ive been finding myself more and more bogged down with troubleshooting as my game gets bigger. I have made great strides in writing cleaner code but started thinking that busted or something like that could help too. Unfortunately I just cant wrap my mind around how unit testing libraries work. or the general workflow of using busted with love2d. I read the documentation but I think I need a more basic understanding. can anyone point me in the right direction?

Re: i don't understand unit testing-and/or Busted

Posted: Wed Jun 25, 2014 6:28 am
by bdjnk
Although I'm no expert on unit testing, I can give you some small insights.

Unit testing is, exactly as it sounds, a method for testing 'units' of code. A unit just being a small testable portion, often a function or method. Relevent to this is the concept of good modularization (at least on the function level).

Unit testing does not require a framework, and how they work might be clouding the essence of unit testing. What I want when I test a unit of my code, is to check all the edge cases. If I have a function that takes a number and a string, I want to know how that function will respond when the number is zero or near zero or negative or tiny or huge, and when the string is empty or huge or contains bizarre symbols, and when either or both of them are nil, etc. I want to examine the output of all those scenarios. This is an extraordinarily tedious proposition.

A framework, like Busted, can be amazing because it allows you do this testing in a more efficient, uniform, and effective fashion. It will still be tedious, but it will make your code less buggy.

Re: i don't understand unit testing-and/or Busted

Posted: Wed Jun 25, 2014 7:26 am
by Roland_Yonaba
bdjnk wrote:It will still be tedious, but it will make your code less buggy.
So true.