如何在Android中编写使用Mockito进行改造的单元测试

时间:2018-08-05 04:32:19

标签: android unit-testing kotlin mockito retrofit2

我有一个简单的演示者,我想为其编写Mockito单元测试。

这是演示者类的代码,我在其中调用api,并使用接口获取响应并将响应发送给活动类(视图):

int main()
{
    image = imread("sample.jpg", 1);
    cv::resize(image, source, Size(), 0.5, 0.5, INTER_LINEAR);
    // Make a dummy image, will be useful to clear the drawing
    Mat dummy = source.clone();
    namedWindow("Window",WINDOW_AUTOSIZE);
    // highgui function called when mouse events occur
    setMouseCallback("Window", drawCircle);
    int k = 0;
    // loop until escape character is pressed
    while (k != 27)
    {
        imshow("Window", source);
        putText(source, "Choose center, and drag, Press ESC to exit and c to clear", Point(10, 30), FONT_HERSHEY_SIMPLEX, 0.7, Scalar(255, 255, 255), 2);
        k = waitKey(20) & 0xFF;
        if (k == 99)
            // Another way of cloning
        dummy.copyTo(source);
    }

    return 0;
}

0 个答案:

没有答案