我們如何模擬應用上下文?我有一個主持人,我打算爲其寫一個測試。它收到的參數是vie
w和Context
。我如何創建一個模擬上下文的工作?如何模擬應用上下文
public TutorProfilePresenter(TutorProfileScreenView view, Context context){
this.view = view;
this.context = context
}
public void setPrice(float price,int selectedTopics){
int topicsPrice = 0;
if(selectedTopics>2)
{
topicsPrice = (int) ((price/5.0)*(selectedTopics-2));
}
view.setBasePrice(price,topicsPrice,selectedTopics,
price+topicsPrice);
}
添加您要測試的impl並讓我們看到 –
我已更新我的問題。請檢查它 –
我只是想編寫一個示例片段來測試是否調用演示者在視圖中(這是一個接口)的方法來更新活動內容。 –