Solved

Writing Test Cases

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

Accepted Solution

by:
sachinwadhwa earned 84 total points
Comment Utility
0
 
LVL 4

Assisted Solution

by:v_karthik
v_karthik earned 83 total points
Comment Utility
>> 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
Comment Utility

>>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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Learn more about the importance of email disclaimers with our top 10 email disclaimer DOs and DON’Ts.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Articles on a wide range of technology and professional topics are available on Experts Exchange. These resources are written by members, for members, and can be written about any topic you feel passionate about. Learn how to best write an article t…
Where to go on the main page to find the job listings. How to apply to a job that you are interested in from the list that is featured on our Careers page.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now