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.

In my job all developers that resolve a bug have to add a new unit test that warns about this type of bugs (in the case it occours again). If a unit test is not possible (for example, a webpage design issue), then QA department has to create a test case to manually check it.

The idea behind this is that if a defect has not been detected before the product release is because there isn't an appropriate unit test to detect it. So the developer has to add it.

The question is: is this common in any software development methodology? This technique has a name? I would like to learn more about it, but I need some information to start with it.

share|improve this question
4  
It's called regression testing and is quite common. I can only link a wikipedia article but it's far from perfect. –  devmiles.com Feb 29 '12 at 16:32
14  
It is best practice to do this and therefore quiet rare to see it in actuality. –  Sardathrion Feb 29 '12 at 17:08
add comment

3 Answers 3

up vote 17 down vote accepted

This is quite common. We use this in our team. For Every production defect, the developer must add a note on the root cause of the problem , add a failing unit test and add a test impact analysis before the ticket can be pushed to dev state to check in the code.

I don't think this has a specific name except that general "regression testing". This is very useful and we have started seeing the quality of the product after we started following this process.

share|improve this answer
add comment

Absolutely!

If you can agree that unit tests are a good thing, then you will realise that if there is a bug then there is a missing unit test covering that code path.

So what should happen is, you write a unit test that shows the bug exists, fix the actual bug, then the unit test will pass.

If you have no unit tests at all, then this can be a good way of starting to introduce unit tests to a project.

share|improve this answer
2  
+1 for a good way to introduce unit tests –  Schleis Feb 29 '12 at 20:52
add comment

The technique is test-driven development. It's not really about being able to spot a similar bug next time, although the suite of repeatable tests is always helpful. The point is that you can demonstrate that you've isolated what is wrong with the code, proved that it is wrong, fixed it, proved that the fix is correct.

There's a quote that I can't quite recall or find, but roughly it is: "Every bug is a test not yet written."

Trying to sell it as a regression test is a lost battle, IMHO. Given how infrequently these things catch a repeated bug, most developers will just say, "Why bother, when I can simply fix it?"

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.