Solved

Writing Test Cases

Posted on 2006-07-13
6
2,015 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Since 2008, the stock markets have been in a haphazard state of fluctuation. At times it has been a steep decline (2008) and at others, a steady incline full of promise (2010). Just weeks ago, in August 2011, together we saw the stock markets plunge…
Digital marketing agencies have encountered both the opportunities and difficulties that emerge from working with a wide-ranging organizations.
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.

735 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