unit test on Inheritence Class..plz help
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   nagesh_Hasan
Posted On:   Thursday, September 8, 2005 01:39 PM

package dgds; public class FirstClass { int x; String papa; public int getInt(){ return x; } public String getString() { return papa; } public void setInt(int y) { x=y; } public void setString(String aa) { papa = aa; } } ____________________________________ public class SecondClass extends FristClass { FirstClass fc; public void setFC(FirstClass fc1){ fc = fc1; } public FirstClass getFC() {    More>>

package dgds;


public class FirstClass {

int x;

String papa;

public int getInt(){

return x;

}


public String getString()

{

return papa;

}

public void setInt(int y)

{

x=y;

}

public void setString(String aa)

{

papa = aa;

}

}

____________________________________

public class SecondClass extends FristClass {

FirstClass fc;

public void setFC(FirstClass fc1){

fc = fc1;

}



public FirstClass getFC()

{

return fc;

}





}

__________________________________________________







public class Third extends SecondClass {









SecondClass sc;

public void setSC(SecondClass sc1){

sc = sc1;

}


public SecondClass getSC()

{

return sc;

}





}

}

I need unit test for

third and second class


i really appreciate if some one helps me out..
thanks a lot
nagesh    <<Less

Re: unit test on Inheritence Class..plz help

Posted By:   vimal_gupta  
Posted On:   Thursday, September 15, 2005 09:38 AM

For each class you create, you should include JUnit tests for that class.



* Write a testcase for FirstClass , SecondClass and ThirdClass for getters and setters on following line



TestFirstClass-->



testGetSetInt(){

firstClass.setInt(12);

assertEquals(12,firstClass.getInt();

}





TestSecondClass-->

testGetSetFC(){

//can move this to setUp()

FirstClass fc= new FirstClass();

fc.setInt(12);

fc.setString("test");

secondClass.setFC(12);

assertEquals(fc,secondClass.getFC();

}


On the same lines , test for third class.
About | Sitemap | Contact