Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
Colleague unwilling to use unit tests “as it's more to code”

I've been trying in the last couple of months to convince one of my colleagues to start unit testing his code and drop the old "print, run, debug" way of doing things. I need clear and elaborated proofs that unit testing increases your productivity - this guy has a decent amount of experience and can give a counter-argument for all of the arguments I gave him until now.

Unit testing is not a policy that's being enforced in the team, but is something that most of us do and it definitely worked for us, and we can see how print, run and debug isn't working for him - it's taking way too long to implement something and it's taking even longer to manually test his code.

share|improve this question

migrated from stackoverflow.com Nov 7 '11 at 19:54

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Anna Lear Nov 7 '11 at 20:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6  
Unit-testing and debugging are not mutually exclusive. –  Oli Charlesworth Nov 7 '11 at 19:49
    
@AnnaLear potentially. the question was migrated, perhaps a merge is in order? –  Woot4Moo Nov 7 '11 at 20:20
    
@Woot4Moo A merge can only happen on a closed question. I've closed this one as a duplicate for now and will have to review answers to see if it's worth merging later. –  Anna Lear Nov 7 '11 at 20:39

4 Answers 4

This situation is very strange. I have never heard of anyone skipping unit testing. Unless you make it a policy, there is no way to 'convince' some one to do that. You project manager must establish a policy and a process for this to take place, otherwise, frankly, you should not consider your job done at all. If a programmer can't understand the value of unit testing, he/she probably get some education. The practice of throwing code into systems is harmful, unprofessional and can't be justified as a common practice in a team.

Edit:

Due to the comments below, I need to clarify that what the 'unit tests' I am referring to is 'any type of unit test', that is it is not necessarily automated unit tests, it may be manually performed.

share|improve this answer
2  
You have never worked with anyone who skipped unit testing?! At least in my city over half of all developers I have worked with don't unit test willingly or have never even tried to learn. –  maple_shaft Nov 7 '11 at 20:33
2  
Just six months ago I met my first developer who did write unit tests, that's how uncommon a practice it is, in my experience –  Carson63000 Nov 7 '11 at 20:58
    
A lack of unit testing doesn't necessarily imply that the developer is "throwing code into systems". –  Oli Charlesworth Nov 7 '11 at 22:01

It seems like the proof you need, you already have. Your own performance improvement should be prove enough that in your environment, unit testing is more efficient.

If you have the time and oportunity, you might try something I did with a collegue of mine on a similar matter. We were trying to figure out which language/framework combo was more efficient in small projects (We are both similarly proficient programmers). A project came along which needed to be done really fast, so we argued about which one to use to develop the product. Since we couldn't come to an agreement, we decided each one would do it the way they though (we both were available) and see who finished first (delivered a verified and validate product first). I am not going to say who won (guess why) but trust me that the non-winner (looser) admitted to the affeciency of the competing selected combo.

No counter-argument can be given in that situation.

share|improve this answer

It sounds to me that in your case the best way to convince your co-worker is to write unit tests for his code, or to write tests for the implementation he is doing, and just show him how it's so much faster than his method.

For some people, any theoretical argument can be refuted by some other theoretical statement, however few people will outright reject "cold hard facts."

share|improve this answer

Unit testing only takes you so far in the grand scheme of things, and TDD is harmful to large projects. I find that using a sys out to see what is going on is far more beneficial than a unit test. The issue you have is that there is not a policy in place to force a developer to do "the norm", if it continues to be a problem you should bring it up to management and have a meeting about the benefits. The thing to realize here is that you need to write unit tests against his code and prove that this actually will make it easier for the team to progress. However, if you fail to do so and you wasted time writing unit tests your management team will be less than pleased.

share|improve this answer
7  
Could you substantiate "TDD is harmful to large projects"? –  Oli Charlesworth Nov 7 '11 at 19:57
    
@OliCharlesworth one second, I will find the link to the podcast from the phd researcher –  Woot4Moo Nov 7 '11 at 20:03
    
I can't recall ever seeing strict TDD adherence with 100% code coverage on a medium to large size project. It may be challenging to do but I think it is debatable that it is "harmful". I think that in measurements of productivity improvements over the lifespan of the application it is just hard to measure and thus is naturally resisted by non-technical application managers and project managers. –  maple_shaft Nov 7 '11 at 20:25