如何在runFabric()方法的帮助下编写junit案例并想要模拟.getFabric()方法

时间:2018-06-04 20:55:18

标签: powermock easymock

我尝试了以下不同的方式为下一课写Junit。有一段时间它是真正的调用调用或另一个异常来了。我想写一下Junit for Fabric类 - > runFabric方法。

     // Resposible for Rest connection
        class RestConnection{

        //Return JSON  Objecct
        String getJSONResponse(){

        }

      //Method which returns Object of particular JSON 
         List<SomePojo> getFabrics(String url ){
            String jsonRes=  getJSONResponse(url);
    //it retrun 
     // convert jsonRes into arrayList  of Somepojo
         return new ArrayList<SomePojo>();
           }
        } 
        //this class provide Configuration ,Restconnection object to it's extending class
        class GenricHelper{

            RestConnection res= null;
            GenricHelper(RestConnection rc,SomeConfig config ,String xx){
            // set Value in construtor 
            this.res =rc;
        }

            SomeMethod x();
            SomeMethod y();
        }

        class RESTHelper {
            GenricHelper gen=null;
            RESTHelper(GenricHelper gen ){
                this.gen=gen;
            }

        }

        Class Fabric extends RESTHelper
        {

        public Fabric(EMCViperSRMGenericHelper helper) {
                super(helper);
            }
        public void runFabric(){

         List<SomePojo> list=rc.getFabrics("");
         //Wan to Mock rc.getFabrics("");
            //Doing Some bussiness
            }
        }

        }

0 个答案:

没有答案