意式浓缩咖啡测试不更新
问题描述:
我与Espresso有问题。意式浓缩咖啡测试不更新
测试工作正常,但每当我在测试中更改某些东西并运行它们时:测试未更新。
基本上测试的“旧”版本运行。 要强制测试更新我用的摇篮任务:uninstallAll
这里是我的配置:
-
测试
package com.shockn745.moovin5.main; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.LargeTest; import com.shockn745.moovin5.R; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard; import static android.support.test.espresso.action.ViewActions.typeText; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.core.AllOf.allOf; /** * UI Test for the Main Screen */ @RunWith(AndroidJUnit4.class) @LargeTest public class MainScreenTest { private final static String WRONG_DURATION = "asdssssssssf"; private final static String RIGHT_DURATION = "40"; @Rule public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class); @Before public void initTest() { // Do nothing for now } @Test public void enterDuration_success() { // Type text and then press the button. onView(withId(R.id.main_edit_text)) .perform(typeText(RIGHT_DURATION), closeSoftKeyboard()); onView(withId(R.id.main_button)).perform(click()); // Check that Motivation Activity is displayed onView(withId(R.id.motivation_toolbar)).check(matches(isDisplayed())); } @Test public void enterDuration_parse_error() { // Type text and then press the button. onView(withId(R.id.main_edit_text)) .perform(typeText(WRONG_DURATION), closeSoftKeyboard()); onView(withId(R.id.main_button)).perform(click()); // Check that the text was changed. onView(allOf( withId(android.support.design.R.id.snackbar_text), withText(R.string.main_error_snackbar) )).check(matches(isDisplayed())); } @Test public void enterDuration_empty_error() { // Press the button. with no text onView(withId(R.id.main_button)).perform(click()); // Check that the text was changed. onView(allOf( withId(android.support.design.R.id.snackbar_text), withText(R.string.main_error_snackbar) )).check(matches(isDisplayed())); } }
-
摇篮
apply plugin: 'com.android.application' android { compileSdkVersion 'Google Inc.:Google APIs:23' buildToolsVersion "23.0.2" defaultConfig { applicationId "com.shockn745.moovin5" minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } /* Resolves dependency versions across test and production APKs, specifically, transitive dependencies. This is required since Espresso internally has a dependency on support-annotations. */ configurations.all { resolutionStrategy { force 'com.android.support:support-annotations:23.0.1' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) // Android libraries compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' // Google libraries compile 'com.google.guava:guava:19.0' // Network operations compile 'com.mcxiaoke.volley:library:1.0.19' // Unit testing testCompile 'junit:junit:4.12' testCompile "org.mockito:mockito-core:1.9.5" testCompile "org.hamcrest:hamcrest-all:1.3" // UI testing androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' androidTestCompile "com.android.support.test:runner:0.4.1" androidTestCompile "com.android.support.test:rules:0.4.1" // External libraries compile 'com.jakewharton:butterknife:7.0.1' }
个
运行配置
任何想法?
太感谢你了,如果你能找到一个解决方案:)
答
请到Edit Configurations
- >Main Screen Test
- >Miscellaneous
- >和禁用Skip installation if apk has not changed