父类:

public class Father {

public void function1(){
   System.out.println("this is father's function 1");
}

public void function2(){
   System.out.println("this is father's function 2");
}

public void function3(){
   System.out.println("this is father's function 3");
}

public void function(){
   function1();
   function2();
   function3();
}
}

子类:

public class Son extends Father {

public void function3(){
   System.out.println("this is son's function 3");
}

}

测试父类:

public class TestFather extends TestCase {
Father f;
@Before
protected void setUp() throws Exception {
   f=new Father();
}

@Test
public void testFunction() {
   f.function();
}
}

输出:

this is father's function 1
this is father's function 2
this is father's function 3

测试子类:

public class TestSon {
Son s;
@Before
public void setUp() throws Exception {
   s=new Son();
}

@Test
public void testFunction() {
   s.function();
}

}

输出:

this is father's function 1
this is father's function 2
this is son's function 3

 

这样的一个结果,对我是有用的~~~