I have seen a lot of ***unit: JUnit, PHPUnit et al.
Bu what on earth are they for in practical? Why do we need it?


Short version: It's testing individual pieces of a (large) system one at a time to get them working as specified before putting them all together to test the complete system. Building and testing a complete sytem is a horribly inefficient way of finding a bug in one small component.

So is it necessary to successful software engineering or just option?

Okay, how do I get started then?
I have tried to llok for newbee tutorials but I cannot find it. Can you give overview on how to do it on Netbeans?

Sorry - don't have time to write a training course for you! You will definitely find loads of stuff on Unit Testing on the web if you look. Google: java unit test netbeans

I didn't mean you write training course. Just ABC of where do I go about. Google isn't any good unless you know ABC

> So is it necessary to successful software engineering or just option?

Absolutely necessary if you are working with a dynamically typed language like Python, Ruby etc. where values have types, variables don't. In the absence of unit tests, aggressive re-factoring becomes risky due to the lack of compile time checks and you end up with breaking existing code if you are not careful.

Not really necessary when working with statically typed languages like Java which offer decent compile time type safety. Changing method signature, class name, method name etc. results in compile time errors. Changing logic still requires proper verification but there's nothing which a decent testing round can't uncover. Though I must admit the turnaround time for testing a new/changed functionality is pretty short when it comes to unit testing.

The greatest pitfall when advocating unit tests is that it ends up giving developers/managers a false sense of security. Unit tests are not magic; they end up testing code the way you have "written" it to be tested. Countless times I have seen code bases littered with "unit tests" which did nothing more then instantiating the class to be tested and invoking random methods here and there.

Discipline is of prime importance when it comes to writing unit tests. I strongly recommend junior team members/programmers/unit testers being mentored by someone who *knows* his stuff to avoid turning the entire application unit test code base into a big pile of useless ****. :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.