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.

My team follows the Scrum development cycle. We have received feedback that our unit testing coverage is not very good.

A team member is suggesting the addition of an external testing team to assist the core team, but I feel this will backfire in a bad way.

I am thinking of suggesting pair programming approach. I have a feeling that this should help the code be more "test-worthy" and soon the team can move to test driven development!

What are the potential problems that might arise out of pair programming??

share|improve this question
7  
One potential problem with pair programming is that most managers don't like it. They think they are paying two people to do the work of one. –  user61852 Oct 17 '12 at 14:16
1  
@user1598390, Managers are my last concern. For the moment let us assume the ideal scenario where everyone supports the "best" solution with out any ego issues. –  TheSilverBullet Oct 17 '12 at 14:30
    
Pair programming can be good for spreading knowledge about the code, but can slow down development (especially of experienced programmers) by focusing too much on irrelevant details. –  Giorgio Oct 17 '12 at 14:34
2  
what do you currently do for code reviews? (pair programming is code reviews @11) –  jk. Oct 17 '12 at 14:38
    
@Jk, As far as I know, there is no code review happening... –  TheSilverBullet Oct 17 '12 at 18:22
show 3 more comments

6 Answers

up vote 9 down vote accepted

Your question is orthogonal to your problem. Sticking two programmers that don't want to or can't write good unit tests together isn't going to get you more/better unit tests.

Sticking a programmer who is poor at writing unit tests with one that is good might propogate good habits, but might not be a good pair for other reasons (unit testing is only a part of the entire development process after all). There are other questions/posts that deal with pair programming's benefits and problems.

Your goal should be to change the culture that caused the problem in the first place. Well done pair programming can help that, but it will usually require a combination of things all pushing towards that end goal. There is no silver bullet (pun intended) for making people write good unit tests.

share|improve this answer
    
Well, I am suggesting pair programming as opposed to an independent unit test team... –  TheSilverBullet Oct 17 '12 at 16:50
2  
@TheSilverBullet - anything is better than assigning developers dedicated to writing unit tests... –  Telastyn Oct 17 '12 at 17:25
    
Why would you say that? What are the potential hazards of dedicated unit test team? This will help me in presenting my case... –  TheSilverBullet Oct 17 '12 at 18:20
2  
@TheSilverBullet - Even if developers see the usefulness in unit tests, or are good at writing them... they don't want to do that as a full time job. If they did, they'd be in QA. Removing all of the creativity from the job is a quick and easy way to push your developers into finding new jobs. –  Telastyn Oct 17 '12 at 18:29
    
Thank you for your perspective. This discussion really helped. I am sorry for the delay in accepting your answer. –  TheSilverBullet Nov 12 '12 at 8:37
add comment

From my personal experience as a team member which has gone through a similar process, the choice of pair-programming and TDD was very successful and useful. Our coverage has increased significantly.

What we did was:

  • force pairs for production code. No code was allowed to be committed if not created in pairs.
  • force TDD, no code was allowed to be committed if not TDDed.

It was hard and slow at first (a few weeks, about a month and a half), but than it became very practical and natural.

EDIT: Naturally we had very high code coverage an new code, and we refactored old code and added test to it slowly. When an old class / module had to be modified, we added tests and modifications. Gradually coverage became pretty good at the level of the whole project.

Finally, after we were used to both processes, the mandatory nature of the 2 processes was removed and now we pare naturally most of the time (about 90%) but we also commit simple stuff made single or without TDD.

share|improve this answer
add comment

There's easier way to achieve higher coverage. Simply make a rule that no code is allowed to be committed unless it is covered by sufficient amount of tests (what sufficient means is another story though). Of course pair programming might help, but there's no guarantee that when your pair consists of two test-reluctant people, they will suddenly produce test-heavy code (I'd even say it's highly likely they'll stick to their test-reluctance together).

For the record, forcing people to write tests might result in very poor tests, which is opposite to what you want to achieve. I think it might be good idea to pre-assign pairs, ie. test-aware person with test-reluctant person, so the former can help out and explain why things are being dealt with in a certain way to the later.

share|improve this answer
    
Yes... Instead of having a separate testing team, my suggestion was to pair a tester with a developer... As suggested by you. –  TheSilverBullet Oct 17 '12 at 16:53
add comment

If your projects are big, a separate test team is the way to go. Most big software firms have separate test teams.

Pair programming does improve the quality of the code, but it has one big potential problem: most managers don't like it and will try no prevent it. They think they are paying two people to do the work of one.

Edit after reading @Giorgio 's comment:

"You should not test your own code", that's true. Working knowing that other people will test, means you have to programm according to accepted standards. No "I understand my own mess" kind of logic.

share|improve this answer
    
But separate test teams will never converge in implementation of TDD which I what I aim for... –  TheSilverBullet Oct 17 '12 at 14:31
1  
+1. I would add that (1) pair programming does not always work and can in some cases decrease productivity instead of increasing it and (2) as you stated, unit tests cannot replace a test team that is disjoint from the development team (you should not test your own code) and that verifies the application according to a well-structured protocol. –  Giorgio Oct 17 '12 at 14:33
3  
Most large software houses have manual testers and automated tests teams. But I have never seen separate team for unit tests, as those are programmer-only tests, wrote by the very same guys who write code. –  jimmy_keen Oct 17 '12 at 14:44
    
@user1598390 I am specifically talking about unit tests... There is already an independent testing team for the other purposes –  TheSilverBullet Oct 17 '12 at 16:51
1  
"... means you have to programm according to accepted standards": In my experience there is more to it: someone who's not implemented the program is going to use it in many ways you hadn't thought of: each developer will spontaneously use his / her software the way they think it should work. On the other hand, someone else might come up with weird ways of using the program making it easier to expose bugs. –  Giorgio Oct 17 '12 at 18:17
show 1 more comment

In fact, Pair Programming will not help you. The main benefit of pair programming is to spread or combine knowledge to solve some problems.

The test "discipline" is a huge new universe. We have a lot of approaches to do testing, and it is a long time process. If your company does not have time, money, and employers to implement a good test process, an external testing team can be the viable solution.

share|improve this answer
add comment

If you know your unit test coverage is low you must be be using a coverage tool in the first place. Why don't you just target the pieces of code it hightlights and write unit tests for them?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.