Email Subscription Form

Saturday, March 23, 2019

Three Ways to Test Output Validation

Last week, I wrote about the importance of input validation for the security, appearance, and performance of your application.  An astute reader commented that we should think about output validation as well.  I love it when people give me ideas for blog posts!

There are three main things to think about when testing outputs:

1. How is the output displayed?  

A perfect example of an output that you would want to check the appearance of is a phone number.  Hopefully when a user adds a phone number to your application's data store it is being saved without any parentheses, periods, or dashes.  But when you display that number to the user, you probably won't want to display it as 8008675309, because that's hard to read.  You'll want the number to be formatted in a way that the user would expect; for US users, the number would be displayed as 800-867-5309 or (800) 867-5309.

Another example would be a currency value.  If financial calculations are made and the result is displayed to the user, you wouldn't want the result displayed as $45.655, because no one makes payments in half-pennies.  The calculation should be rounded or truncated so that there are only two decimal places.

2. Will the result of a calculation be saved correctly in the database?

Imagine that you have an application that takes a value for x and a value for y from the user, adds them together, and stores them as z.  The data type for x, y, and z is set to tinyint in the database.  If you're doing a calculation with small numbers, such as when x is 10 and y is 20, this won't be a problem.  But what happens if x is 255- the upper limit of tinyint- and y is 1?  Now your calculated value for z is 256, which is more than can be stored in the tinyint field, and you will get a server error.

Similarly, you'll want to make sure that your calculation results don't go below zero in certain situations, such as an e-commerce app.  If your user has merchandise totaling $20, and a discount coupon for $25, you don't want to have your calculations show that you owe them $5!



3. Are the values being calculated correctly?

This is especially important for complicated financial applications. Let's imagine that we are testing a tax application for the Republic of Jackvonia.  The Jackvonia tax brackets are simple:

IncomeTax Rate
$0 - $25,0001%
$25,001 - $50,0003%
$50,001 - $75,0005%
$75,001 - $100,0007%
$100,001 and over9%

There is only one type of tax deduction in Jackvonia, and that is the dependents deduction:

Number of DependentsDeduction
1$100
2$200
3 or more$300

The online tax calculator for Jackvonia residents has an income field, which can contain any dollar amount from 0 to one million dollars; and a dependents field, which can contain any whole number of dependents from 0 to 10.  The user enters those values and clicks the "Calculate" button, and then the amount of taxes owed appears.

If you were charged with testing the tax calculator, how would you test it?  Here's what I would do:

First, I would verify that a person with $0 income and 0 dependents would owe $0 in taxes.

Next, I would verify that it was not possible to owe a negative amount of taxes: if, for example, a person made $25,000 and had three dependents, they should owe $0 in taxes, not -$50.

Then I would verify that the tax rate was being applied correctly at the boundaries of each tax bracket.  So a person who made $1 and had 0 dependents should owe $.01, and a person who made $25,000 and had 0 dependents should owe $250.  Similarly, a person who made $25,001 and had 0 dependents should owe $750.03 in taxes.  I would continue that pattern through the other tax brackets, and would include a test with one million dollars, which is the upper limit of the income field.

Finally, I would test the dependents calculation. I would test with 1, 2, and 3 dependents in each tax bracket and verify that the $100, $200, or $300 tax deduction was being applied correctly. I would also do a test with 4, 5, and 10 dependents to make sure that the deduction was $300 in each case.

This is a lot of repetitive testing, so it would definitely be a good idea to automate it. Most automation frameworks allow a test to process a grid or table of data, so you could easily test all of the above scenarios and even add more for more thorough testing.

Output validation is so important because if your users can't trust your calculations, they won't use your application!  Remember to always begin with thinking about what you should test, and then design automation that verifies the correct functionality even in boundary cases.

20 comments:

  1. Nice examples! Tommy Tutone sends his regards ...

    ReplyDelete
    Replies
    1. LOL! I'm glad you appreciate the phone number! :-)

      Delete
  2. Minor quibble: given the calculation, what you are calling a "deduction" should probably be called a "tax credit." A deduction reduces taxable income, whereas a credit reduces taxes owed. But it's your country, so ...

    ReplyDelete
    Replies
    1. Thank you for this information, Dave- I have never thought about this difference before! I'll have to bring it up with the Finance Minister of Jackvonia. :-)

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. Get Assignment Help from a reliable UK writers at affordable price. Avail Best online assignment help at 25% OFF, Quick Delivery, 24/7 Free Assistance .Get Write nursing essay writing service online by expert writers to secure good grades. Assignment Ace offers finest assignment writing service with unlimited discounts.

    ReplyDelete
  7. HELLO GET OUT OF FINANCIAL MESS WITH THE HELP OF drbenjaminfinance@gmail.com

    I have been in financial mess for the past months, I’m a single mum with kids to look after. My name is REBECCA MICHAELSON, and am from Ridley Park, Pennsylvania. A couple of weeks ago My friend visited me and along our discussion she told me about DR BENJAMIN OWEN FINANCE of (drbenjaminfinance@gmail.com); that he can help me out of my financial situation, I never believed cause I have spend so much money on different loan lenders who did nothing other than running away with my money. She advised, I gave it a try because she and some of her colleagues were rescued too by this Godsent lender with loans to revive their dying businesses and paying off bills. so I mailed him and explain all about my financial situation and therefore took me through the loan process which was very brief and easy. After that my loan application worth $278,000.00USD was granted, all i did was to follow the processing and be cooperative and today I am a proud business owner sharing the testimony of God-sent Lender. You can as well reach him through the Company WhatsApp +19292227023 Email drbenjaminfinance@gmail.com

    THANK YOU VERY MUCH

    ReplyDelete
  8. This tool functions to organize the QuickBooks server folder for multi-user mode. It helps in making the most of multi-user mode, and also without QBDBSM it is not possible for you to access multi-user mode But, sometimes users may face issues using the tool on the system. One of such issues that you can face is the Quickbooks database server manager get stucked and stop working. which should be rectify by using proper steps.

    ReplyDelete
  9. Thanks for such an awesome content. If you work a lot on quickbooks then I think you should go for quickbooks tool hub download which will fix a lot of issues

    ReplyDelete
  10. Thanks for this information if u want to know more about Quickbooks error code h202

    ReplyDelete
  11. Nice Blogs related tech.
    Quickbook databasae server manager if you want to know more about the Quickbook database server manager click here

    ReplyDelete
  12. Nice initiate for tester.
    Quickbook user guide if you really wan to learn more about this Quickbook so click on my page and read the whole content carefully.

    ReplyDelete
  13. I have been a technical specialist providing QuickBooks for the past 6 years. QuickBooks Tool Hub is a program that can fix errors on the QuickBooks desktop. To fix errors, you need to download and install the program. I have a lot of knowledge about QuickBooks. You can call me anytime. I am excited to help you.

    ReplyDelete
  14. Great content! I must say, smilarly have gone through reviews of best essay writing website in uk the easy way to get your assignment done in minimum expenditure by the expert writers.

    ReplyDelete
  15. Nice art work is presented in this post. Creativity at his best in this article. I must share this article with my mates. Now its time to avail limo rental Pleasanton ca for more information.

    ReplyDelete
  16. Thanks for sharing Florida is known for its stunning beaches and vibrant cities, but it also boasts a lesser-known natural wonder—the Florida Mountains. Located in the western part of the state, these ancient, rolling hills offer hikers and nature enthusiasts a unique experience. Explore trails, encounter diverse wildlife, and admire breathtaking views in this unexpected mountain range.

    ReplyDelete
  17. Thanks for Sharing. Unlock the full potential of your online presence with digital marketing services in Delhi. From strategic social media campaigns to search engine optimization and compelling content creation, Delhi's digital marketing experts help businesses thrive in the digital realm, attract targeted audiences, and achieve their marketing goals.

    ReplyDelete
  18. In the vibrant city of our digital marketing services in Cape Town empower businesses to thrive in the digital landscape. From comprehensive strategies to execution, we specialize in driving brand awareness, increasing online visibility, and maximizing conversions. Harness the power of digital marketing and unlock your business's full potential in Cape Town.

    ReplyDelete

New Blog Location!

I've moved!  I've really enjoyed using Blogger for my blog, but it didn't integrate with my website in the way I wanted.  So I&#...