如何为android方法和类编写单元测试?

问题描述 投票:1回答:1

如何为android方法和类编写单元测试?

例如 :

public int dpToPx (Context context, int dp) {

float density = context.getResources().getDisplayMetrics().density;

return Math.round((float) dp * density);

}

https://developer.android.com/training/testing/unit-testing

android unit-testing
1个回答
1
投票

如果您使用的是Android类,则无法编写单元测试。对于Android相关的东西,你需要写instrumented unit tests

参考:https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests

© www.soinside.com 2019 - 2024. All rights reserved.