Showing posts with label Data-Driven. Show all posts
Showing posts with label Data-Driven. Show all posts

Monday 1 August 2016

Data Driven Testing And Negative Testing

As a QA, I know what is Data Driven Testing (DDT) and what is Negative Testing refers to from last 5 years. But before today, I had never realized that negative testing is a subset of data-driven testing. With this post, I will try to explain my understanding of data-driven testing & negative testing and why I think of negative testing as a subset of data-driven testing.

      As per Wikipedia, data-driven testing is a term used in the testing of computer software to describe testing done using a table of conditions directly as test inputs and verifiable outputs as well as the process where test environment settings and control are not hard-coded.

This sounds very hard to me, I will try to make it simple but not simpler for you.
“Testing is driven by data.” But what does that exactly means?
Example :- Addition Operation in Calculator

Addition Example of Data-Driven Testing
Addition Example of Data-Driven Testing

So as you can see in above example, Output of operation changes as per the input passed. That means results are driven by data you supply in software.
All this seems very inconvenient to you? Or that example is too vague?
One may ask why we need to pass 3 different set of data even one set of data is enough to show that addition is working. But what if it's working coincidently, only for values passed in that test.[Remember this : QA should never make an assumption.]  I will try to answer your dilemma with another example.

Example :- Multiplication Operation in Calculator

Multiplication Example of Data-Driven Testing
Multiplication Example of Data-Driven Testing

Now, do you think that using a single set of data is OK to test this functionality?
Certainly NOT.
There are applications which have to be tested against multiple sets of data to cover all the functionality of that software. In above example, testing of multiplication needed to be tested against zero, when you use 0 (zero) as a first input and 0 (zero) as a second input. This is part of coverage of multiplication of module functionality testing, without such data-driven test we cannot say that test coverage of module is 100%. [For simplicity we have considered addition & multiplication of a whole number and for single digit.]

To summarise, what I am saying is there would be numerous applications in real life where you need to test the functionality for the different set of data. And for each set of data output would be different.
    This is pretty true for application in capital markets, by changing value of the flag in an application the result would be different. Such type of application MUST be tested with all required set of input data. Consider you have eliminated only one set of data while testing and developer had not taken care of that scenario. Your company may lose millions of dollar due to such mistake and it may cost you a job.  

I hope, by now you have understood what data-driven testing is and why it’s important. Now let’s move to next part and that is Negative Testing.


As per Wikipedia, Negative Testing is a test designed to determine the response of the system outside of normal parameters. It is designed to determine if the system performs error handling with unexpected input.
This concept is very simple to understand. Let’s take an example of Login into the Bank application.

         So as a tester my positive test would be “I should be able to login to into the application with valid credentials”. This is how we start the execution of our end-to-end test cases. But what would happen if we did not execute test for invalid credentials. Do you think your all green end-to-end pass result will make any significance if anyone able to login to bank application even if he does not have credentials?  So what should we do as a tester? We should execute test for error handling[Wrong Password - application should display proper error  message to user] and for unexpected input[Blank username, spacial character in fields where those are not allowed - application should display proper error message.]

Above example is self-explanatory. Now let’s move to last part, Why Negative testing is a part of data driven testing. I will formulate the table which encompasses what I have explained in above examples.



Negative Testing Example
Negative Testing Example



I have not covered all the negative scenarios of Login here, but this clears the idea.

Remember this:- Negative testing is a subset of Data-Driven testing that means all negative tests are basically data driven tests which are written to check error handling of the system with unexpected input but all data-driven tests are not Negative testing.



This is all for now.
Cheers!!
Copyrights held by Amol Chavan. Powered by Blogger.