【问题标题】:Test running failed: Unable to find instrumentation info for: ComponentInfo{com.view.asim.mixuntong.test/android.test.InstrumentationTestRunner}测试运行失败:找不到仪器信息:ComponentInfo{com.view.asim.mixuntong.test/android.test.InstrumentationTestRunner}
【发布时间】:2017-04-28 10:29:43
【问题描述】:

我用的是Android studio verison 2.3.1,我想用espresso做测试,但是遇到了如下图Test running failed

我的测试 java 文件

package com.view.asim;

import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.view.asim.activity.MainActivity;
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.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * Created by OF on 2017/4/28.
 */

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MakeSureLogin {
    private String mStringToBetyped;
    @Rule
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(
            MainActivity.class);

    @Before
    public void initValidString() {
        // Specify a valid string.
    }

    @Test
    public void changeText_sameActivity() {

        // Check that the text was changed.
        onView(withId(R.id.account_txt)).perform().check(matches(withText(mStringToBetyped)));

    }
}

我知道在 stackoverflow 中也有人问过类似的问题,也有人回答过,但那些解决方案(如 this)无法解决我的问题。 有人说可以specific instrumentation runner,但是在Android Studio 2.3版中没有这个动作。我认为这可能与multildex有关,真的希望有人能帮助我,任何建议都会非常感激。这是我的build.gralde文件

    defaultConfig {
       //...
       multiDexEnabled true
       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
       //...
    }
    productFlavors {
           zixuntong{
                applicationIdSuffix ".mixuntong"
                manifestPlaceholders = otherHolderMap
                manifestPlaceholders.put("PACKAGE_NAME",ASIM_PKG_NAME+applicationIdSuffix)
                buildConfigField "boolean", "isAddShare", "false"
                buildConfigField "boolean", "isZXT", "true"
            }
    }
        //.....
        androidTestZixuntongCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
                exclude group: 'com.android.support', module: 'support-annotations'
            })




   //    compile 'com.android.support:support-annotations:22.2.0'
        androidTestZixuntongCompile 'com.android.support.test:runner:0.5'
        testCompile 'junit:junit:4.12'
        androidTestZixuntongCompile('com.android.support:multidex-instrumentation:1.0.1') {
            exclude group: 'com.android.support', module: 'multidex'
        }
        configurations.all {
            resolutionStrategy.force 'com.android.support:support-annotations:23.1.0'
        }
    //...
//had trying follow script,but still doesn't work
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',

{ 排除组:'com.android.support',模块:'support-annotations' })

【问题讨论】:

    标签: android android-espresso android-multidex


    【解决方案1】:

    我发现在将 Android Studio 从 2.3.1 升级到 2.3.2 后我已经解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      • 2015-11-18
      • 1970-01-01
      • 2016-08-13
      • 1970-01-01
      相关资源
      最近更新 更多