Test Driven Development

I am looking for a book that will help me learn test driven development. I am considering using Uunit. Should I get a book on Nunit or Junit?
Thanks

How about a different question. Would someone recommend a good book on Test Driven Development?
Thanks

Test-driven development is one of the tenets of “Extreme Programming” (a.k.a. “XP … no no not that XP”) and “Agile Development” which are the current vogue buzzwords among the current generation of coders (along with “Getting Things Done” which is a kind of emerging cult which requires its adherents to spend months or years writing a To Do list manager in Cocoa).

So, you might try looking for a “good book” on XP or Agile Development. I hope that helps. I’ve read a couple of books on this subject, including “Extreme Programming”. I don’t recommend it.

Bumping this old thread because I know there’s Unity devs out there using TDD/BDD.

I’m at a point where I need to make sure things don’t fall apart when I add new functionality; would anyone be willing to share their test harness code on the UnifyCommunity wiki?

Thanks in advance.

Maybe I should re-phrase the question: Has anyone had success with UUnit on the UnifyCommunity wiki? (http://www.unifycommunity.com/wiki/index.php?title=UUnit) Is this the best bet right now?

TDD is just a methodology, and the tools used for the actual test are generally irrelevant.

There are some good resources on TDD on the web for free, and once you “get it”, the rest is pretty simple and just requires discipline. We rolled our own unit test harness a while ago, but I am sure the one(s) on the wiki are great.

The minimum features needed are, of course, automated test running (including test discovery), a solid Assert class, and some way to clearly report failures.

-Jeremy

True, it isn’t that complex to write a basic test harness. However, I come from the world of Ruby on Rails where:

  • There’s often little reason to reinvent a common component — there’s almost always a open source module to do what you need or at least provide a base for what you’re trying to accomplish.
  • There’s great Behavior-Driven-Development (BDD) tools (like Cucumber) that I can’t even fathom how they turn any human language (or even LOLCATZspeak) into tests… but I do know that I don’t have think of the exact interface I want in my implementation, just what I want the thing to accomplish.

Basically, I’m not lazy, I just know someone’s already built a better testing system than I could in a weekend, and I’m here to make games, not reinvert tools and libs!!! ;-D

For use within Unity I’ve never heard of any such framework aside from UUnit.

For C# itself there are likely quite a few but you potentiallym can’t use them for Unity components as New is a no go with Unity components.

Unity has not tens of thousands of developers thus there are far less user created tools than for Ruby.
Also, the fact that Unity currently is on mono 1.2.5 and not Mono 2.x doesn’t really make the problem smaller.

Yep, so as long as whatever Unity testing toolset you choose (UUnit or http://www.mrjoy.com/posts/33-Unit-testing-in-Unity) has a solid Assert class, and auto test discovery you’re all set.

Generally any other features are more specific to your personal development process, build pipeline, preferences, and so on.

IIRC UUnit didn’t originally have an Assert class, and I am not sure if it does now. Jon’s (link above) did have one. Any proper Unit testing framework requires a solid collection of Assert methods, so be sure to check that out.

-Jeremy

I like Kent Beck’s book, “Test-Driven Development By Example”: Test Driven Development: By Example: Beck, Kent: 8601400403228: Amazon.com: Books

Lynn Grant
Cross Design Group LTD

I was wondering if there was anyway to do TDD in Unity… I’ve only heard of UUNIT, but is this compatible with .JS? Jasmine / Javascript for instance go together…

I am using TDD framework UUnit. It does both Javascript and C#.
Check out my examples here:
http://wiki.unity3d.com/index.php/UUnit#Test_Examples

Unit testing it’s not actually TDD, cause you have coding the test class first, test, e fix the fail. Basically: Test class → Fix → Refactor and repeat this cycle until your functionality get ready.

Lovely thread, However Unit testing and test driving development may not always be the best way to go, now i’ll just share my personal experience so this is 100% subjective.

As most people know if they have been reading op software engineering there is 2 aspects, Traditional and Agile, I worked in a traditional waterfall based method for about a year at the university and honestly, i didn’t like it at all and our first project was not too good. However the second was good and such but in the work process everyone seemed to be all over the place, code got change without anyone knowing except the one who changed it and it lead to one single person had almost made the whole jeez because he either couldn’t read/understand the code we other had mad, or maybe knew a way to do it with 2 lines of code (LOC) less. So honestly it was a project we other got carried through.

From here on I went away from traditional method and started working more agile and iterative in my groups, and I’ve for the most part been lucky to have a group that worked well under these methods. Now for the first project I was part of we were very test oriented, bit like XP but not really, we was specially focused on user testing, but it fast also get boring to use 1-3 work days to get the result of the user testing, watch the film, and screen cap of the user to see what should be improved.

Project 4 was not too good, but we went through, Project 5 was was great, however I didn’t do good, there was a high lack of communication in the group just as in the 2. project even that we worked agile, I ended in bad grade due to the fact that I was set aside.

For the last project which I’ve just turned in we had tried to combine some aspects of Scrum and some of XP. To make the best environment for everyone we customized both a little, and I most say this may have been the best work form yet. In stead of “wasting” time each morning on a meeting we took on larger task or multiple task at once and about 1 - 3 times we had a “scrum-meeting” to plan the next steps, so we took it week by week. Also we didn’t do much testing even that we used a combo of XP, due to the fact that we had the simple rule “if it doesn’t work or lack performance don’t upload it!” Worked fine, we have never been in troubles but then again it’s no AAA Game we were making. We used much time on refactoring, maybe little longer than wished for but the outcome each time have been wonderful and a huge performance boost, both for “developers” and the program.

A guy I worked together with this year was last year in a “do it wrong” scrum group, he don’t talk much about but apparently it was near slavery, every class got unit tested, scrum meetings took about 1-2 hours (EACH day) and they sat 8+ hours each day even weekends from what I got told.

So my view on it is agile, only because it is more “safe” it seems, but in general you have to build it up so it suits your needs 100% so if you use XP and think unit testing is unnecessary, ignore it then. Projects can work just great without a large guidance of rules as long everyone work under the same few rules.

Now as said this is very subjective, and some may kill me for what I’ve said but this is truly how I feel about it! :slight_smile: