Learn how to write test cases based on a scenario. In this article, we will answer two of the interesting questions that were submitted to us in the comments sections of our articles.
At STH, we love questions and always encourage any kind of feedback. It is the only way to promote a healthy discussion and develop a perspective.
We have answered two interesting questions that came up in the comments section of our articles. We have dedicated this post to provide a detailed explanation of the questions and its wide applicability to everyone in similar situations.
Table of Contents:
How to Write Test Cases Based On a Scenario
Also read => 101+ Manual and Automation Software Testing Interview Questions and Answers.
Question #1)
This comes to us from “Bhawana Kumara” in response to this post: 7 Types of Software Errors That Every Tester Should Know
“At one of the interview I got this question, Write as many test cases as you can for this scenario – If you are a new customer and you want to open a credit card account then there are three conditions first you will get a 15% discount on all your purchases today, second if you are an existing customer and you hold a loyalty card, you get a 10% discount and third if you have a coupon, you can get 20% off today (but it can’t be used with the ‘new customer’ discount). Discount amounts are added, if applicable.
Can somebody please help me with it.”
Sure. Happy to help!
Answer: This question is a classic case of different processing happening for different kinds of input. The input here is for the type of customer. The process is the amount of discount that they can avail. Depending on the type of input, if the output differs, a model that can be successfully used to test is “Decision Table Testing”.
Let’s see how you can do this.
Step 1: Partition your input into categories
To create a decision table, you will have to partition your input into categories.
There are 6 categories of users in this situation:
- New customers with coupons
- New customers without a coupon
- Existing customer with a loyalty card and no coupon
- Existing customers without a loyalty card and no coupon
- Existing customers with a Loyalty Card and Coupon
- Existing customers without loyalty and with a coupon
More partitions can be made but from the problem definition itself, it is not clear if the new customers can have a loyalty card or not. So let’s not assume it. Also, this is just to show you how to arrive at a solution.
Step 2: Construct your decision table.
There are many ways to do this. I will use all the input categories as columns and discounts as rows. You end up with the following table:
(Click on the image below for an enlarged view)
Step 3: Pick a user from each input category and test
Now from each category, you can pick one value and test to see if the correct amount of discount is applied.
So now, you will need at least 6 customers or 6 test cases to test the case completely.
I’m sure at this point you are thinking, “This is all good. But how can I answer the question in an interview instantly when I do not have the time to work out the detailed solution as you did?”
This is why it is important to talk about your thoughts in an interview.
As soon as you hear the question, you can say: I think a decision table will help solve this problem. If the interviewer wants you to elaborate, you can ask for a notepad and a pen and work it out. Be sure to explain your solution as you go.
Also, keep in mind that it is not important to get the solution a 100% right. So you might miss an input category or two, because of the pressure in an interview or in haste and that is OK. The interviewer will be appreciative of your strategy and clarity of thought.
With that said, we hope we were able to answer this question to your satisfaction! For more information on decision tables, check out: How to Write Complex Business Logic Test Scenarios Using Decision Table Technique
Also read => How to write effective test cases.
Question #2)
Dhrumil had posted the question: “What is 80:20 rule or the Pareto principle? Please explain through Example.” in response to the All In One Guide On Defect Density – Its Importance and How to Calculate It.
Answer: 80/20 rule is also called the Pareto principle. You can check out the basic definition here at Pareto principle
It says 80% of the results were due to 20% of the causes. It can be applied to many things and in the context of an IT QA project, the following may be observed.
- 80% of your productivity is due to 20% of the activities that you do
- 80% of progress is contributed by 20% of your team
- 80% of the application can be tested by 20% of the test cases
- 80% of the malfunctions can be addressed by fixing 20% of your defects
And, so on..
Therefore, following this rule, we will have to identify what that 20% of the causes.
Pareto analysis is simply a technique that helps you optimize your efforts. Instead of distributing your focus and effort on all 100% causes, it tells us to look for that 20% of the causes which when addressed maximize your returns (80% of the problems).
- This is not an exact science and should not be taken at face value.
- The Pareto Analysis finds its usage in many industries and not just software.
- To know exactly what that 20% of the causes are, you could draw up a Pareto chart. It is a simple combination of both bar and line charts that plot the causes on the X axis and problems on the Y axis. The cumulative frequency line point of 80% is dropped onto the X axis. All the causes that lie between 0 and the line are the 20% causes.
For example: if there are 5 modules in an application that have defects to be fixed and this is the distribution of them:
You will now reorder this table in a descending order of defect count and calculate the cumulative frequency percentage.
When you draw a Pareto Chart for the above tabular data, this is what you will end up with:
(For the exact steps as to how to generate a Pareto Chart in Excel, follow this link: Pareto Chart)
Now, to know what your 20% of the modules are to be fixed in order to target optimum defect fixing, draw a line at the 80% mark on your cumulative frequency percentage axis, like below:
Hence, the 20% modules you should focus on are Module 1, 4 and 2.
This is, of course, a contrived example, but when the number of causes is in a few 10’s this method can do wonders in terms of giving us the clarity on what to pick.
Conclusion
Thanks a lot for your wonderful questions, feedback and participation.
A big thank you Swati S. and STH team members for answering these questions in more detail.
Please do let us know if this article has been helpful to you. We hope we were able to answer your questions. Also, go ahead and submit more questions! We always love to hear from you.
Thank You Swathi for an beautiful explanations for the above Qs.
@Swathi Seela / @Gaurav Khurana
Can we get more explanation for the Shraddha’s Question (Q: What is the most complex thing you have done in your current or previous jobs?) with any real time situations.
I too had the same question in my previous interview, but my interviewer not satisfied my answer, I have explained him that I have spent whole weekend (Fri-Sun) on my desk to complete end-to-end testing for the last minute complicated defects/issues raised after the tested software transported into Pre-Prod Environment, & we were ready for UAT. I said that couple my senior developers and myself were sitting for nights and fixed the issues for a successful UAT. But, I realised later that my interviewer is not happy for the answer and didn’t got that job, though I was in front for job.
Can you please explain me with more examples in real time scenario.
Thanks in advance
Kind Regards,
Krish Reddy
Hi,
Can you please let me know how to write test scenario for to ensure that the stock transactions involved in production processes are consistent: consumed materials should disappear from stock, and created products should appear on stock.
Terminology:
– Item: a physical product that is stored in the warehouse
– Stock quantity: the total quantity of a given item available in the warehouse
– Stock transaction: a transaction that modifies the stock quantity of some items. For example: material consumption, production, receipt, delivery…
– Lot number: an identification number assigned to a particular quantity of an item, for quality control purposes. For example, an orange juice manufacturing company will typically assign a different lot number every day or every shift.
– Serial number: a unique number assigned to each piece of an item. For example, each smartphone has a unique serial number.
Each material and product can have a large variety of possible configurations, which highly affect how the production processes have to be tested. For example, for each materials and product, the following parameters are possible:
– Stock quantity management method (Lot / serial / none)
– Lot number / serial number assignment (automatic / manual)
– Has expiry date (yes / no)
– Material consumption method (automatic / manual)
Please let me know Asap
Thanks in advance
Got this interesting scenario online. Can you help me to solve this?
## Scenarios:
We will have a form with some fields:
– Name:
– Age:
– Date:
– Gender (Male|Female|Others)
– Quantity:
***Condition:***
– Each item has a price of 10$
– Because the owner’s name of the store is `James` so whose name is `James` will receive a discount of 5% of the total.
– Age:
– Children who are from 0 and less than or equal to 6 yrs, will receive a discount of 5% on the first 5 items and 1% for the rest
– The person who is greater than 6 yrs and less than or equal to 18 yrs, will receive a discount of 3% for the first 5 items.
– The adult who is greater than 40 yrs, will only receive a discount of 5% for the first item
– If buy the item before the date 30 Jun, the customer will get discount 20$ on total
– Only Female has a discount of 4% for the second item
– If the customer buy more than 10 items in 1 bill, the price will be 9.5$ for the first 10 items and 9$ from the 11th item
– Require input for all field
***Requirement***: Please write all test cases for this scenarios as much as possible, should provide the expectation for each test case.
Is “the credit card “question for a fresher to the role?
Please, put few test scenarios for the people who are just starting the role
1. You need to write as many test cases as possible for a simple software program which computes the eligible discount for a customer. Try to describe all possible scenarios in a tabular format. Do not worry about ‘login’ kind of test cases, and just focus on how you will validate discount calculation. These are the rules.
If the customer is new, and they are willing to sign up for a new loyalty card, they get a 15% discount on all their purchases on the day. Second if they are an existing customer and hold a loyalty card, they get a 10% discount. Third, if they have a discount coupon, they will get 20% off which cannot be used with the new customer discount but can be used with loyalty card discount. Discount amounts are added, if applicable.
2. The following appeared as part of an article in the business section of a local newspaper:
“Ronnie’s Auto Repair Shop commenced business four months ago at the location formerly occupied by the Jenny’s Beauty Parlour. Ronnie’s Auto must be doing well at this location, because it intends to open a big shop in an adjacent town. Jenny’s, on the other hand, has seen a lower volume of business in its first year at its new location compared to the prior year at its former location. Jenny’s definitely erred in shifting to its new location; its former location is a better site.”
Discuss how well reasoned you find this argument. In your discussion be sure to analyse the line of reasoning and the use of evidence in the argument. For example, you may need to consider what questionable assumptions underlie the thinking and what alternative explanations or counterexamples might weaken the conclusion. You can also discuss what sort of evidence would strengthen or refute the argument, what changes in the argument would make it more logically sound, and what, if anything, would help you better evaluate its conclusion.
Help me to wite test case please
Thank you for this!
Have we also considered purchases on other days? Because the 15% and 20% discounts are only for ‘today’. What about the test cases for purchases other than ‘today’ ?
A recent study was conducted to understand health and longevity of people in urban vs rural areas. A city “C1” and a small town “T1” were considered. It was observed that folks in T1 reported less sick leaves in the shops and establishments there. The average age of T1 was found to be much higher than that of C1.
These findings suggest that smaller communities ensure better health and life expectancy.
Can you help to write test cases for this
did you get the answer?
Did you get any help? Can you help me?
Thanks Swati for such a nice article. @shradha
You can say you are working in X domain. So you created some queries using joins and some other SQL by which you got the data easily by just giving the customer id.
You could talk about some optimisation did which saved some time.
May be if you have not done check in your team, people do add value to the system
Hi. Can you share a tutorial on how to do test cases for date? It’s a bit confusing on how to do it using Equivalence Partition/BVA, since has leap year & February.
What is the most complex thing you have done in your current or previous jobs?) with any real time situations.plz explain it
sir one interview they asked me to write test cases for..they given 2 inputs one is fuel consumption and second one is vehicle speed .given output from model is fuel economy. pls explain me to write write test cases for this
Question #1)
In the decision table, 2nd test case is wrong.
How? Existing customer coupon discount 20% is not applicable to New customer. that is mentioned in the brackets
“At one of the interview I got this question, Write as many test cases as you can for this scenario – If you are a new customer and you want to open a credit card account then there are three conditions first you will get a 15% discount on all your purchases today, second if you are an existing customer and you hold a loyalty card, you get a 10% discount and third if you have a coupon, you can get 20% off today (but it can’t be used with the ‘new customer’ discount). Discount amounts are added, if applicable.
that’s true.. I was about to write the same. I can see first 2 users with a new account with/without coupons is useless. New customers only get 15% of the first condition and the other 2 conditions are for an existing customer. based on this, there will be only 5 category users, isn’t it???
New customer
Existing customers with a loyalty card and no coupon
Existing customers without a loyalty card and no coupon
Existing customers with a loyalty card and Coupon
Existing customers without loyalty and with a coupon
How should one answer this question?
Qn : What is the most complex thing you have done in your current job?
(I have not done any complex thing as such as a manual test engineer so please suggest the answers)
regression testing
Great….Thanks for sharing this.
If there is a form and it has 20 fields on it…what would be the strategy to write test-cases? because with 20 fields there can be infinite number of test-cases. The new entrants encounter this problem.
Good examples & good clarification, Thanks
“Let’s assume that you’ve have been given the task of creating and writing unit test cases
for a function (called Bazinga()) that is found within a system that your company is
developing. In order to develop test cases, you know that you must familiarize yourself
with the internal workings and expectations of the function. So you need to read the SRS
and also read any design documentation that tells us what Bazinga() is supposed to do.
From what you read – you extract the following set of requirements which help you
understand that Bazinga():
? [Requirement : A10] The function takes 2 parameters – bazValue which is a float and
bazModulus which is an integer. The Bazinga() function returns a float
? [Requirement : A16] bazModulus is defined as being a positive value greater than 0 and less
than or equal to 15
o [Requirement : A16.1] if Bazinga() is called with a bazModulus outside of this
range, then the function returns a status value of -2.0 (meaning bazModulus out of
range)
o [Requirement : A16.2] if Bazinga() is called with a bazValue and bazModulus
outside of this range, then the function returns a status value of -3.0
? [Requirement : A17] bazValue is defined as being a value greater than or equal to 0.00 and
less than or equal to 100.00
o [Requirement : A17.1] if Bazinga() is called with a bazValue outside of this
range, then the function returns a status value of -1.0 (meaning bazValue out of
range)
? [Requirement : A34] Bazinga() is supposed to return the floating point modulus value (i.e.
the remainder) of bazValue % bazModulus
NOTE: The Bazinga() function performs this calculation :
answer = bazValue – (float)((int)(bazValue/(float)bazModulus) * bazModulus)
So if bazValue = 12.5 and bazModulus = 2, then the Bazinga function will return a value of 0.5
= 12.5 – ((int)(12.5/(float)2) * 2)
= 12.5 – (6 * 2) // (int)(12.5/(float)2) = (int)(6.25) = 6
= 12.5 – 12.0
= 0.5
1. Review the types of tests from Module-05 (Part 1) in the course content –
specifically looking at the functional, exception and boundary types of tests
2. Review the “IEEE 829 Adaptation” style of documenting your test cases
material from Module 5 –(Part 1)
3. You are required to create 4 functional test cases, 4 exception test cases and
2 boundary test cases for the Bazinga() function (a total of 10 test cases)
REQUIREMENTS”
Please can someone help me with this assignment?
please help me with below question
Referral Module
Test cases needs to be created for executing and giving reward for referral
Referral Module supports generation of unique referral code for each newly registered customer. It
provides flexibility to reward the customer when :
1. Another customer (referee) enrolls by applying his/her (Referrer) referral code .
2. The referee performs a purchase transaction
Definition :
Referrer – Whose referral code is getting used
Referee – who is using the referral code
Rules of execution of Referral offer
? Limit on max number of referral code generation
? Referral Code given to customer via SMS and Email
• Limit Max number of referral by member
• Reward for Enrolment or Reward for Transaction or Reward for Both
• For Transaction based reward – Limit the number of days within which the referee should
transact
• Reward can be Fixed points or a percentage of points accrued/given for the transaction or
Coupon
• Reward can be given to Referrer or Referee or both
• Referral Offer can be applied/restricted based on following
• Stores – List of stores where offer is running
• Tier ( eg. Tier 1, Tier 2, Tier 3 Members) – Member attribute , offer applicable on.
Note: If any point is not clear, make assumption and write your assumptions in the test case document.
Thanks in advance By Chalapathi Rao
You’ve run your test cases and it looks like there is a major bug. Select a test case where the
expected result does not meet the actual result, and file a bug report for this case.
this is the situation..can anybody help me to select test case?
Did you get any help? Can you help me?
What are some testing cases for an automated workflow process? In my case, emails received go through AWS processing such as AWS WorkMail -> SNS -> Lambda -> then we respond back to the original email.
What sort of manual test cases should we have? Thank you
Q: What is the most complex thing you have done in your current or previous jobs?) with any real time situations.plz explain it
@ Shraddha: Most complex thing: Qs like this don’t have to have a politically correct answer. Everyone’s idea of ‘complex’ is different. You can say that you have enjoyed challenges and overcome them and nothing was so big that you felt like it was complex or complicated. It shows your positive attitude and also, it is the truth. 🙂 I hope this helps!
I everyone i sit with this scenario in an assignment:
Sanchez is a learner who said to be shown emotional warning signs that need intervention. He was referred to you for counselling by his register teacher. Your task is to work very closely with him to rescue the situation. To assist him, you need to answer the following questions.
the questions that comes with it is the following:
Explain the possible factors that are likely to impact his school work.
Outline the effect of the problems on Sanchez’s school work.
Very good article. I have no idea about 80-20 rule, now clear with explanation provided with the example.
Thank you Swathi!
Coding is not a necessary skill to create data visualization in Microsoft Excel and Google Sheets in this article, we will show you How to Create Pareto Chart with great graphic to make your visualization sophisticated.
Thanks for explaining in details… Vijay Sir, You are doing a great job
@Gaurav Khurana: Thanks once again for your continued readership and taking the time to comment. Not only that, you have answered a user question- we appreciate your participation. 🙂