2016-03-21 10 views
1

、ここで説明したように、私は、いくつかの大画面で、画面を分割している画面が、小さな画面で一つの画面を持っている:http://developer.android.com/training/basics/fragments/fragment-ui.htmlAndroidの計測テストに

私はそのテストケースを書き込もうとしています私のアプリケーションのすべての機能を実行し、私はすべてのネットワークコールを嘲笑しています。

私が知っている唯一の残りの質問は、複数のレイアウトをテストする適切な方法があるかどうかです。

今、私は手動で私がテストしたい構成で様々なAVDのテストケースを実行する必要があるだろう、と私は、この形式でのコールがあります。私はAndroidJUnit4とエスプレッソテストを実行しています

if(uiDevice.getDisplaySizeDp().x < 600) { 
    // we are using the standard layout, so the fragment was opened on top of the stack, instead of side-by-side 
    // press Back to get back to the list of objects 
    pressBack(); 
} 

をし、 android.support.test.runner.AndroidJUnitRunner

質問です:私は別のレイアウト修飾子を処理するために、私のチームと共有することができ、標準/文書化の方法があります:sw600dpw900dplandscape、および等々。

また、修飾子と一致するデバイスに対して実行するテストケースを指定する方法はありますか? drfrag01の回答に基づいて

更新:

私はランナーがデバイス上で起動すると自動的に、場合によっては、実行するテスト選ぶことができるかもしれない何かのために多くを探していると思います。私の最高のシナリオはおそらく、@ SW600または@Normalという注釈を追加して、テストがデバイス上で実行されているときに、@ SW600はすべてのスイートを設定するのではなく、小さな電話のためにスキップされます。

カスタムテストランナーなしでは、これは不可能なようです。

/** 
* Determine if the device is a tablet (i.e. it has a large screen). 
* 
* @param context The calling context. 
*/ 

public static boolean isTablet(Context context) { 
    return (context.getResources().getConfiguration().screenLayout 
      & Configuration.SCREENLAYOUT_SIZE_MASK) 
      >= Configuration.SCREENLAYOUT_SIZE_LARGE; 
} 


/** 
* Determine if the device is in landscape or portrait mode. Returns true for portrait, and false 
* for landscape. 
*/ 
public static boolean isPortrait(Context context) { 
    return context.getResources().getConfiguration().screenHeightDp > context.getResources().getConfiguration().screenWidthDp; 
} 
あなたは例

./gradlew -Pandroidについて

  1. Organizing them in Suites and running the suites.

で実行する必要があるテストケースをフィルタリングすることができ

-

答えて

2

私は、次の使用します.testInstrumentationRunnerArguments.class = com.mycompany.foo.tes t.Suites.PortraitFriendlyTestSuite connectedAndroidTest --info

  • Annotating them with for example "@TabletTest" or "@PortraitOnly" and filtering them in a test run.
  • 例について

    ./gradlew -Pandroid.testInstrumentationRunnerArguments.annotation = com.mycompany.foo .Annotations.PortraitOnly connectedAndroidTest --info

    +0

    お返事いただき、ありがとうございました。時間がある場合は、更新ブロックを参照してください。 –

    関連する問題