Adam's Lair Forum

game development and casual madness
It is currently 2017/04/28, 02:26

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Unit Testing
PostPosted: 2014/01/27, 20:17 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1949
Location: Germany
Role: Professional


Blog entry:
Unit Testing
So you might have heard of this development trick called Unit Testing – most likely in the context of some business application or software engineering talk, but probably not related to games. It’s something that large, bulky projects have, with a ton of different programmers working on the same stuff, but it doesn’t make sense to do something like this yourself, right?



[ Read more ]

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: Unit Testing
PostPosted: 2014/01/30, 16:37 
Member
Member

Joined: 2013/05/20, 17:19
Posts: 77
Role: Professional
Hey Adam

It's great to see that you're embracing testing. Duality is an amazingly stable piece of code for it's size, but as it grows and hopefully becomes more of a community driven effort, tests will make a huge difference in the quality.

I just wanted to bring up one of your guidelines for when to write tests. You said

Quote:
When writing a new game component or engine feature you’re still experimenting with: Don’t Unit-Test that.


I just wanted to mention Test Driven Development and see if that's something you're familiar with. TDD actually helps to improve the design of your APIs because the tests become basically like any other client of your code, and help to show you where your code is too coupled by being difficult to write. In TDD, you write a small test first, then write the code to make the test pass. If you're looking for a good example of TDD tests, check out scriptcs. They're very nicely written in that (and also it's a project we're investigating to add scripting support to Duality. Early tests are promising:) ).

That said, I'm all for hacking some code together to explore an idea first, so long as that code is thrown away and re-written with tests.


Top
 Profile  
 
 Post subject: Re: Unit Testing
PostPosted: 2014/01/30, 17:04 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1949
Location: Germany
Role: Professional
Hey Andrew,

yeah well, I was almost expecting someone to bring up TDD when I wrote that one guideline. :D It's probably worded poorly. I have applied the TDD kind of workflow once, when I wrote Duality's RawList<T> class. It worked remarkably well and I would definitely do it again! Thumbs up for TDD in general, that is.

My point is just, that I can't seem to apply TDD very often. Something like a custom dynamic array wrapper has an obvious design and straightforward use cases, is easy to test and I pretty much know how the class design will look like before I even begin to start writing code. But in 90% of the time, this is not how it works for me. Instead, I sketch a systems design roughly in my head, and start programming shortly after, altering overall structure, API and functionality frequently. It is not practical for me to write tests at this stage, because it will all change anyway before I've even done my first commit - and not because I'm really bad at designing stuff, but simply because, to me, programming and design is a very dynamic, fluid process.

So, you can of course unit-test new things directly, and write tests up-front or while you're at it. I guess what I'm trying to say in this personal guideline is just: Don't do it until you have an idea of what you're dealing with.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group