Unit testing 无法加载源'';。在golang执行测试用例时

Unit testing 无法加载源'';。在golang执行测试用例时,unit-testing,go,testcase,gomock,Unit Testing,Go,Testcase,Gomock,我正在使用gomock编写测试用例,尝试使用gomock的EXPECT()行为设置函数的参数 这就是我要做的。 我试图模拟一个函数的行为,该函数的签名如下: func Post(arg1 interface{}, arg2 interface{}, arg3 interface{}, arg4 interface{}, response *ResultResponse) error { //This function does the following 1. Do

我正在使用gomock编写测试用例,尝试使用gomock的EXPECT()行为设置函数的参数

这就是我要做的。 我试图模拟一个函数的行为,该函数的签名如下:

func Post(arg1 interface{}, arg2 interface{}, arg3 interface{}, arg4 interface{}, response *ResultResponse) error {
       //This function does the following
       1. Do a http post call and and receive the response
       2. Parse the data received and store the result in response as json.Unmarshal('data received by post call', response)
       3. Return if any error occurred during the whole process.
}
我已经使用gomock实现了此函数的mock。我想实现动态返回行为。下面是我想做的

mockBehavior := mockClient.EXPECT().Post(gomock.Any(), gomock.Any(),
        gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()

    mockBehavior.Do(func(arg1 interface{}, arg2 interface{}, arg3 interface{},
        arg4 interface{}, response *ResultResponse){

        mockBehavior.SetArg(4, getResultResponse()).Return(nil)

})


func getResultResponse() ResultResponse {
    nextPage = nextPageMap[nextPage]
    var resultResponse ResultResponse
        resultResponse = ResultResponse{
            Result: getResponse(nextPage),
            }

    return resultResponse
}

func getResponse(nextPage string) Response {
    return Response{
        Blocks:        getBlocks(),
        NextPageToken: nextPage,
    }
}


func getBlocks() []Blocks {
    blocks := []Blocks{
        {
            Block:       "Block1",
        },
        {
            Block:       "Block2",
        },
    }
    return blocks
}

var nextPage string = "Some initial constant value"

var nextPageMap = map[string]string{
//Map of some string values
}
我想在这里实现一个动态行为。根据nextPage的值,我希望每次调用post函数时设置不同的值

我正在使用VisualStudio代码运行测试用例。但是,在执行SetArg(4,getResultResponse())语句后运行测试用例时,我看到消息无法加载源“”。该参数的值未按预期设置。因此,我无法正确执行测试用例。无法理解这是什么原因造成的