PasqualeJ / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

How to test private function in a puiblic class #477

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Now I have a class A:
public class A{

    public Service service;

    private String f1(){return service.do();}

    private String f2() {return f1();}

    private String f3() {return f1();}

    public void main(){
       String a = f2();
       String b = f3();
    }

}

How should I do to test main( I have some other public function like main, and 
they have many different behavior in f1\f2\f3). 

Original issue reported on code.google.com by xierui.s...@gmail.com on 24 Mar 2014 at 3:49

GoogleCodeExporter commented 9 years ago
Hi,

You cannot with Mockito the compiler won't allow it. If you need to, just make 
them package visible. Also I strongly advise you to not make partial mocks.

Please could you ask on the mailing list (mockito@googlegroups.com) or on 
stackoverflow, the issue tracker is not meant for consumer support. Plus you'll 
reach more mockito users around the globe ;)

Cheers,

Original comment by brice.du...@gmail.com on 25 Mar 2014 at 2:33