Unit Testing. I just don’t get it.

I have tried and tried. I still don’t understand the use of unit tests.  I have seen a number of examples and tutorials about testing in AS3 and even more using iOS.

In every example its very simple tests so maybe I am just not seeing examples used in more complex code.

In almost every example its shown to test very basic values.   Every time I am thinking to my self  “No shit”.   Of course  “AssertTrue (5+5==10) * “.  If it didnt then we have a bigger issue with the computer.

Or things like   –   name = “bob”.   AssertTrue (name isEqualTo “frank”) *

I must be missing something. It seems like writing so much code to build mock objects and run these tests just to see “Tests Pass” pop up is a waste of time.

I am constantly checking to make sure the app or site works as I am building it. Is that the wrong way?  Do programmers sit and write 100s of lines of code and then publish and test? That just seems silly to me.

Maybe if you are working on a huge project with many team members it might be useful to know that someone else’s code works. And maybe thats where I am missing it. I have not worked on super large multi team programmer jobs. Everything I have done is either solo or with a few team members.  Some projects have been large but I always was testing along the way to make sure each method call was returning what I expected.

I am open to the idea of Unit tests. Like I said before I have tried many times to see where it would help out. I just have never seen or heard of any tutorials saying that its not worth it for small projects to do tests to make sure 1 + 1 == 2;

 

* yes I know these are not valid or even correct wording of the tests. I am using the idea of what it is to show an example.

2 thoughts on “Unit Testing. I just don’t get it.”

  1. I’m still trying to get into it myself, but the basic idea is that the tests exist to ensure that you haven’t broken anything later on. 1+1 == 2 is definitely silly, but imagine that you need to replace an algorithm with a more efficient one. You’d want to verify that the results are exactly the same as the old algorithm as soon as possible. Automatically running a bunch of test cases through it and ensuring they all come out as expected would eliminate the need for your tester to run those cases manually.

  2. I see your point. Just a sanity test that any future changes are not breaking old code. I am sure I just need to use it more. But I can’t bring myself to double the time I spend coding on writing tests to verify what I know wont work. Ha. The idea is sound. I wish there was some way to write code just once and have the tests built at the same time.

Leave a Reply

Your email address will not be published. Required fields are marked *