Rama asks: "What is the difference between verification and validation and how are they related with software testing?"
Vikash asks: "In Software Development Life Cycle (SDLC), what is V&V (Verification and Validation)? Are they same? If not, how do they differ?"
These are few testing FAQs that came to my mind before I could start writing this very post – Testing Lessons from Kitchen! I am frequently asked questions similar to the above by some of my readers through email/chat/Orkut scrap. Also I have seen such questions flooding the testing forums/communities. So I thought, it was time to write a post about it. But I wanted to explain the answer in a non-traditional way so that it could be easily understood. Hence, I was looking for an easy to understand example and luckily I got the clue from my own kitchen!
My younger brother [who is a BE (EEE) 3rd year student in a reputed Engineering College in Chennai] is trying to learn cooking now-a-days! Isn’t it a funny thing? Well, the reason behind his newly found passion for cooking is still funnier! He actually wants to beat me in cooking! LOL
[Note - My friends say that I am a great cook. However, to *validate* this claim, one day you have to come and taste (test!) my food. :)]
Coming back to my story, yesterday I was watching my brother preparing egg omelette. And suddenly, I got the idea for this post. Have you ever prepared egg omelette? If you have ever prepared, then you might already know that you need ingredients like eggs, cooking oil, onion, salt, spices, green coriander leaves, finely chopped green chillies etc to prepare an omelette. [I am talking about Indian egg omelette here.] However, this list of ingredients is not exhaustive! I might have missed few ingredients; but still with these, one can prepare a delicious enough egg omelette. Apart from the ingredients, we would need a frying pan, a spatula, a gas stove, a matchbox, a kitchen knife etc. as support items for our “project egg omelette”!
Now the question is “Assuming that you already know how to prepare an omelette, can you prepare an omelette, if I provide you with the above stuffs”? Oh wait did you say YES? Well, I would urge you to think again. What if I provide you with a dozen of eggs, a teaspoon of oil, a small onion, 1-kilo salt, unlimited supply of spices and so on. And I ask you to prepare a 12-egg omelette for me using the above ingredients. Will you still say YES? I guess not! The ingredients that I have provided you are terribly disproportionate. A teaspoon of oil might be sufficient for an omelette of 2-3 eggs, but clearly not for a dozen of eggs. The other ingredients are also obviously out of proportion. So it is quite unfair to ask someone to prepare me a 12-egg omelette with the supplied ingredients.
Lesson 1: *Verify* whether your ingredients are in correct amount/quantity.
Now if I provide you with the ingredients in correct quantity, can you prepare me a nice 12-egg omelette? Well, don’t say YES so quickly without giving it a second thought. What if I provide you with oil that is stinking and a dozen of rotten eggs? Will you be still able to prepare nice omelette out of it?
Lesson 2: *Verify* whether your ingredients are of good enough quality.
Now let me assume that, you have got all the ingredients in appropriate quantity and expected quality and you have finally prepared the long awaited 12-egg omelette. But would you not care to taste (test!) a piece from it before serving it to your honourable guest? Just to see if it is actually delicious. To see if any of the ingredients was overused (e.g. too oily, too spicy ...). To see if any of the ingredients was used in less quantity than it should have been (e.g. less salt, hard-to-find onion pieces ...). To see if it has been fried just enough and is not raw inside. To see if it is not burnt while cooking...
Lesson 3: *Validate* whether your final product (here the omelette) has been prepared correctly.
Now let us see how the preparation of an omelette makes sense to software development verification and validation process. The verification of the correct quantity and correct quality of the ingredients, while preparing the omelette (Lesson 1 & 2) can be compared with the verification process in software development. The final validation of whether the omelette has actually been prepared as expected (Lesson 3) can be compared with the validation process in software development. Verification was done when the omelette preparation was underway! But we did not have any actual omelette while doing the verification process. Validation was done once we thought that we had prepared the omelette. So we needed a final product (here the omelette) for validation.
These are few ways in which people like to define verification and validation process:
Am I building the product right? – Verification
Am I building the right product? – Validation
Verification ensures that the final product satisfies or matches the original design (low-level checking) - i.e., you built the product right. This is done through static testing.
Validation checks that the product design satisfies or fits the intended usage (high-level checking) - i.e., you built the right product. This is done through dynamic testing and other forms of review.
Static Testing is a form of software testing where the software isn't actually used. Code reviews, inspections and walkthroughs are used as approaches of Static Testing. From the black box testing point of view, static testing involves review of requirements or specifications. This is done with an eye toward completeness or appropriateness for the task at hand. Defects discovered at this stage of development are less expensive to fix than later in the development cycle. Here we do the verification part.
In contrast, in Dynamic Testing the software must actually be compiled and run. So it is done after an executable portion of the project is ready to run. Actual testing (unit testing, integration testing, system testing and acceptance testing) of the product comes under dynamic testing. Here we do the validation part.