How is unit testing fun?

How is unit testing fun?

Postby Jastiv » 02 Sep 2012, 21:26

I tried today to do some unit testing with c code using the check frame work. I could not get it to work. Honestly, I don't see why people who are doing programming for fun, and for free decide to do something so unfun like unit testing. Also people go on and on about how important it is, but as a developer, I don't really find the check framework or explanation to be much fun.

The irony is I've known some professional programmers who never had to do any unit testing at work, yet why do people do unit testing when they come home when it doesn't seem to be a great joy. Can some one explain the unit test fun, particularly the make check framework for c unit tests?
User avatar
Jastiv
 
Posts: 285
Joined: 14 Mar 2011, 02:18
Location: Unitied States of America - East Coast

Re: How is unit testing fun?

Postby sireus » 02 Sep 2012, 22:59

Unit testing is overrated. It's useful for many libraries, APIs and stuff like that, which actually provide a "modular" functionality, but for many other things (e.g. a game), unit tests are probably a waste of time. IMHO.
And fun? Yeah, about as much fun as writing documentation ;P
sireus
 
Posts: 109
Joined: 24 May 2011, 20:10

Re: How is unit testing fun?

Postby charlie » 03 Sep 2012, 00:00

It's not a waste of time, but you have to be smart about what you write unit tests for.

Unit testing is a great way of testing out a plethora of features without having to manually load up a program and go through each feature to check it. Done the right way, it saves you a large amount of both development time (reduced manual checking) and debugging time (catch issues early whilst you're working on the code that affected it).

How to decide what to unit test? Well a popular way is, when you implement a significant new feature, create a test that shows that feature working (programmatically ofc). Or when you find something broken, create a test so that it does not re-break in the future. Should you write a unit test for every object/function you define? Probably not.
Free Gamer - it's the dogz
Vexi - web UI platform
User avatar
charlie
Global Moderator
 
Posts: 2131
Joined: 02 Dec 2009, 11:56
Location: Manchester, UK

Re: How is unit testing fun?

Postby Knitter » 03 Sep 2012, 10:07

Not everything in programming is fun :)

I never used that framework, don't really know how hard is it (or simple), but I do think unit testing (and other types of tests) are important to get better software. But it is like charlie said, you need to find the right balance and not everything in your code needs to be tested. If you take the "traditional" approach of writing the test before you write the code, for every function, method, class, whatever you implement then it's going to be a long and boring thing to do, but if learn how to write proper tests and choose those areas of you code that benefit from it, the all project will go smother.

Personally, I don't write the tests first, but writing test has both the benefit of allowing me to click a button and see if any of the latest patches caused errors, or if the git merge caused some side effects that I did not find while merging (when you have several programmers it's easy to miss a rouge line of code).

As for professional programmers, well I see professional programmers do a lot of mistakes, I develop software for a living and I can say that I have made my share of mistakes and just because I do this for quite some time doesn't make me all knowing (nor anyone else) :). I never used or have found the need to use any JavaScript framework other than the usual jQuery + plugins combo yet, this month as a requirement I was forced to use Backbone.js, if you'd asked me last month I would say I had been developing for 4 years without ever needing such thing, now I can't really understand how I could develop without the framework :)

If you're new to unit testing I suggest you start small, add unit testing to the functions or method where you find a bug so that the bug doesn't return and go from there, once you start using you'll see if it is something you need or if you can live without it.
Knitter
 
Posts: 237
Joined: 03 Jul 2011, 22:52
Location: Portugal

Who is online

Users browsing this forum: No registered users and 1 guest

cron