Solved

Writing Test Cases

Posted on 2006-07-13
6
2,018 Views
Last Modified: 2008-03-10

Can you please give me a practical example of how to go about writing a test case?
0
Comment
Question by:Neesh75
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Accepted Solution

by:
sachinwadhwa earned 84 total points
ID: 17098266
0
 
LVL 4

Assisted Solution

by:v_karthik
v_karthik earned 83 total points
ID: 17100789
>> Can you please give me a practical example of how to go about writing a test case?

For example, if you have a class (assuming you are using an object oriented language) that adds  divides 2 numbers and returns the result.. like

public float divide(int a, int b)
{
 return a/b;
}

Your test case should try to USE this method in all possible ways and see if it behaves abnormally...  like

class TestCases
{
public bool testDivide()
{
   a = 10; b = 2;  
   if( divide(a,b) == 5.0)  return true;    // test case for the normal operation of the method
   
   a = 10; b = 0;
   try {
    divide(a,b);
    // take an action
   } catch(Exception x) { // take an action }   // this case is to make sure your method acts properly when there is an illegal divide. "properly" depends on what you want it to do.

}


If you are using Java, try out JUnit. It generates a lot of cases automatically for you, and also makes neat html reports on the number of passed / failed cases.

}
}
0
 
LVL 8

Expert Comment

by:hiteshgupta1
ID: 17107239

>>Can you please give me a practical example of how to go about writing a test case?

from which perspective u r talking?
as a developer or as a tester?
test case for a white boix etsting or  black box
Functional or Performance?
0
 

Assisted Solution

by:jon1b
jon1b earned 83 total points
ID: 17206480
a test case should include one specific procedure for verifing one small and specific piece of functionality.  

So basically if you have a requirment for a wordprocessor to have the ability to save a document.  

You will want to test that if you press the save button it saves
or if you press alt +f +s it saves
or if you go to the file menu and scroll down to save it saves.  

Further more you will want to test that the document has changed  and if after you save if it comes back up with out a bunch of garbage

So Your test case should include the procedure on how to save all three ways and how to verify if the document did in fact save and didnt have a bunch of garbage in it.  
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
multiple reboots in a pc.. (event id 6006) 5 89
QQ problem 22 90
How to calculate the height of a bookstand at 20 degrees. 4 43
Need definitions 2 17
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Gift cards are not a new concept - it's been around for a very long time.  Undoubtedly, over the past you have received such a card or purchased one for a friend or relative.  Are you aware that you've been feeding the machine?  If not, read on :)
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…
Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question