【发布时间】:2016-08-10 09:05:52
【问题描述】:
有人可以给我看一个工作代码来对此代码进行单元测试吗?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
}
请告诉我使用本地单元测试(roboelectric.. 等,如果可能的话)和仪器测试。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/login"
android:text="Login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
显然,测试将检查是否有一个带有文本的按钮 Login 创建。
【问题讨论】:
标签: android unit-testing android-instrumentation