projoy/mockito

How to test private function in a puiblic class

GoogleCodeExporter opened this issue · 1 comments

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

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

  • Changed state: Invalid