具有Espresso和JUnit4的AWS设备场

时间:2015-09-29 14:44:03

标签: android unit-testing amazon-web-services

我想使用

在AWS场中测试我的应用
androidTestCompile 'com.android.support.test:runner:0.4'
androidTestCompile 'com.android.support.test:rules:0.4'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude module: 'recyclerview-v7'
}
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.retrofit:retrofit-mock:1.9.0'
androidTestCompile 'com.squareup.assertj:assertj-android:1.1.0'
androidTestCompile 'com.squareup.spoon:spoon-client:1.2.0'

样品测试:

@RunWith(AndroidJUnit4.class) and run with AndroidJUnitRunner, I have my tests starting like:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class EstimationActivityTests {

@Rule
public ActivityTestRule<LoginActivity> mActivityRule = new ActivityTestRule(LoginActivity.class);

@Before
public void setup() {
}

@Test
public void showsRightDataOnCreate() {
org.junit.Assert.assertEquals("asd", "asd");
}
}

但它只是测试拆解和设置套件测试......看起来它不认识测试......

另一件事是我正在创建apk并使用gradlew测试apk。

#./gradlew assembleMockAndroidTest

我将文件上传到app-mock-androidTest-unaligned.apkapp-mock-unaligned.apk

我的流程出了什么问题?

案例:https://forums.aws.amazon.com/thread.jspa?messageID=647198&#647198

1 个答案:

答案 0 :(得分:4)

所有测试的clases名称应以“Tests”结束,测试函数应以“test”开头,然后才能生效。

在这里回答http://makingiants.com/blog/run-espresso-tests-on-amazon-aws-farm-test-center/