2016-08-10 3 views
0

このコードで単体テストを行うための作業コードを表示できますか?ローカルユニットテストAndroid

@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> 

明らかにテストがチェックされます。

+0

すべてのドキュメントをお読みになりましたか? https://developer.android.com/training/testing/start/index.html http://www.vogella.com/tutorials/Robotium/article.html –

答えて

0

使用Expresso:ここ

if(onView(withText("Login")).exists()){ 
    doSomething(); 
} else { 
    doSomethingElse(); 
} 

はどのようにエスプレッソを使用してセットアップするにdetailsです。

+0

上記のフレームワークにjunitとmockitoを統合する方法を学ぶには –

関連する問題