【发布时间】:2021-02-07 04:06:26
【问题描述】:
您好,我正在尝试使用 mockito 为以下算法编写一个 junit。你能帮帮我吗?
public void setOrientation(Activity activity) {
Get the DisplayMetrics for the phone;
calculate the screen size;
get configurations;
if (diagonalInches>=6.5 && tablet connected to hard keyboard){
set screen orientation
}
}
【问题讨论】:
-
模拟此方法使用的其他类。在您的测试中调用该方法,然后验证已在模拟类中调用了正确的方法。断言活动变量中的任何值都是应有的值。如果这还不够帮助,请提供实际代码,以便我们更好地了解这里发生的情况。
标签: java android testing junit mockito