How should I write Junit test cases?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   santosh_borse
Posted On:   Monday, June 25, 2007 02:49 AM

Hi!
I am having single class which processes the XML file.

I would like to know how to write test cases in this case.



Regards,
Santosh

Re: How should I write Junit test cases?

Posted By:   Anonymous  
Posted On:   Monday, July 2, 2007 07:49 AM

Also have a look a XmlUnit (http://xmlunit.sourceforge.net/)

Re: How should I write Junit test cases?

Posted By:   shameer_antony  
Posted On:   Monday, July 2, 2007 05:22 AM

Write a class with name Test at the end extend TestCase.
Write methods which start with Test, and call your method from it and write assert* methods from your test method

for eg: you want to write test case for class ABC

class ABCTest extends TestCase {
public setup(){
//Anything which need to call before each of your methods.
}
public tearDown(){
//Anything which need to call after each of your methods.
}

public class testMyMethod(){
ABC abc = new ABC();
Object a = abc.mymethod();
assertNotNull("Expecting a not null object here, but not",a);
}

reply back
}
About | Sitemap | Contact