how to write unit test for android method and class?
for example :
public int dpToPx (Context context, int dp) {
float density = context.getResources().getDisplayMetrics().density;
return Math.round((float) dp * density);
}
You can not write Unit test if you are using Android classes. For Android related stuff you need to write instrumented unit tests
Reference: https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.