Solved

Writing Test Cases

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

EE introduced a new rating method known as Level, which displays in your avatar as LVL. The new Level is a numeric ranking that is based on your Points. This article discusses the rationale behind the new method and provides the mathematical formula…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
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.

863 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

21 Experts available now in Live!

Get 1:1 Help Now