Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  3. Unity 2017.2 is now released.
    Dismiss Notice
  4. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  5. We want to see what you will create. Take the Neon Challenge.
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Test Driven Development

Discussion in 'Scripting' started by randyherring, Feb 9, 2008.

  1. randyherring

    randyherring

    Joined:
    Feb 9, 2008
    Posts:
    42
    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
     
  2. randyherring

    randyherring

    Joined:
    Feb 9, 2008
    Posts:
    42
    How about a different question. Would someone recommend a good book on Test Driven Development?
    Thanks
     
  3. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,370
    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.
     
  4. slippyd

    slippyd

    Joined:
    Jun 11, 2005
    Posts:
    129
    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.
     
  5. slippyd

    slippyd

    Joined:
    Jun 11, 2005
    Posts:
    129
  6. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    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
     
  7. slippyd

    slippyd

    Joined:
    Jun 11, 2005
    Posts:
    129
    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
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,596
    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.
     
  9. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    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
     
  10. driggger

    driggger

    Joined:
    Nov 12, 2010
    Posts:
    6
  11. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    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..
     
  12. zbalai

    zbalai

    Joined:
    May 28, 2012
    Posts:
    13
  13. erick_zeppelin

    erick_zeppelin

    Joined:
    Feb 7, 2012
    Posts:
    34
    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.
     
  14. jackie0100

    jackie0100

    Joined:
    Jan 31, 2012
    Posts:
    389
    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! :)