Hi All,
 
  I am new to JUnit-devel list. and this is my first quetion.
 
I have a class with a constructor, the constructor takes a file name as an agriment and assignes it to a instance variable of the type String.
 
This file name is later used in another method which when called will open the file name as in the instance variable.
 
The class code looks like this
 
class  ExClass
{
 
  private String FILENAME = null;
 
 public ExClass(String FILENAME)
{
    this.FILENAME = FILENAME;
}
 
// Other methods ....
}   
   
 
Can any one please give suggestions to test this constructor.
 
   What I have right now is a test case which trys to instantiate this class and verifies that an Object is created.
I can think of the following cases.
 
     ExClass ExObj = new ExClass("somefile.txt");
     assertNotNull(ExObj);
 
                      [OR]
    boolean flah = false;
    try{
 
           ExClass ExObj = new ExClass("somefile.txt");
       }
    catch (Exception e) { flag = true; }
    assertFalse(flag);
 
thanks
Hari
 
       


Sponsored Link


Mortgage rates near 39yr lows. $510,000 Mortgage for $1,698/mo - Calculate new house payment