views:

38

answers:

2

When a software is developed,various types of testing is done - unit,integration,functional,manual.In my current project(winforms with sql server),which has legacy code(no tests),we do have lot of bugs. We are trying to remove them using combination of manual + tests(mostly integration)

But,still some bugs can escape.

For example(a hypothetical scenario) - if a customer has purchased some worth of goods for last 6 months,he should be given some discount on purchases he makes once 6 months have lapsed.His status should be updated to privilege.

But,for some reason(bug in the code) the system is not doing so.How should we tackle such scenarios? Should we have a script running on the database which looks for scenarios such as described? Another extension of the scenario could be,the customer must be send a gift once he is privileged,but system is missing to do so.

Thoughts?

A: 

You should have an automated test-suite in place. This test-suite will implement all the scenarios that the specification requires. Since one cannot wait for six months to test that the discounting works, the actual implementation is replaced by a mock implementation (the example is in java but the same principles apply in other languages), that for example "simulates" that 6 months have passed. One can use assertions to automate the tests.

Once you have the whole test-suite ready, if all tests pass after (just as before) a refactoring/changing of the code, one can be sure that no feature has broken due to the refactoring.

Amit Kumar
+1  A: 

"Should we have a script running on the database which looks for scenarios such as described?"

Do you mean "put a script in the database to correct the problem", then no.

NO. Never. Under no circumstances. Working around a bug by adding peculiar special-case logic is really a very bad idea.

  1. When that peculiar special-case logic has it's own bugs, you've added buggy code to try and correct buggy code. A net loss.

  2. When you try to enhance the system, you have this peculiar special-case logic that doesn't make any sense.

    a. If you're lucky, you fixed the bug it was supposed to work around, and it will be redundant. What now? Which copy to remove?

    b. Otherwise, it will contradict other code. What now? Which is right?

If you mean "put a script in the database to help find and debug the problem", then yes. For a short time, use every tool at your disposal to find and fix bugs. Once found and fixed, this script is then useless and must be deleted.

If you mean "write a script in the database to test the application", then yes. That's what unit test scripts are for. Use them.

It is far better to create unit tests than it is to create scripts that you put in the database. Unit tests are the best approach.

S.Lott
"put a script in the database to help find and debug the problem" - yes,this is what I meant.But,again such a script should be bug free(needs testing!)
junky_user
@junky_user: No, it does not need to be bug free. You use it for a day to find and fix the bugs, then you delete it.
S.Lott

related questions