簡體   English   中英

Android Studio 1.3.2 + Espresso - 未找到測試

[英]Android Studio 1.3.2 + Espresso - No Test were found

我通知我的UI測試停止了工作:

每當我嘗試在設備上運行測試時,我收到以下消息:

沒有發現任何測試

額外的控制台輸出說:

Running tests
Test running startedTest running failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'
Empty test suite.

當我試圖在模擬器上運行測試時,我得到以下消息:

Test running started
java.lang.IncompatibleClassChangeError: 
view.activity.SignUpActivity
SignUpActivityTest.<init>(SignUpActivityTest.java:25)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)

Finish

以下是測試類的示例:

import android.app.Activity;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import xxxx.view.activity.SignUpActivity;

@RunWith(AndroidJUnit4.class)
public class SignUpActivityTest extends ActivityInstrumentationTestCase2<SignUpActivity> {

    private Activity mActivity;

    public SignUpActivityTest() {
        super(SignUpActivity.class);
    }

    @Before
    public void setUp() throws Exception {
        super.setUp();
        injectInstrumentation(InstrumentationRegistry.getInstrumentation());
        mActivity = getActivity();
    }

    // Insert scenario methods here
    @Test
    public void processTest() throws InterruptedException {
        TestHelper th = new TestHelper();
        th.insertTextIntoInput(R.id.input_sign_in_username, "test");

    }

}

build.gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "cz.xxx.xxx"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        // Enabling multidex support.
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
    }
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}


repositories {
    jcenter()
    mavenCentral()
    maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile 'com.orhanobut:logger:1.11'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.android.support:design:23.0.0'
    // UI TESTING DEPENDENCIES
    androidTestCompile 'com.android.support:support-annotations:23.0.0'
    androidTestCompile 'com.android.support.test:runner:0.3'
    androidTestCompile 'com.android.support.test:rules:0.3'
    //androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2'
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
    // ORM DATABASE DEPENDENCIES
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
    // STETHO CORE
    compile 'com.facebook.stetho:stetho:1.1.1'
    compile 'com.facebook.stetho:stetho-urlconnection:1.1.1'
    compile 'com.facebook.stetho:stetho-okhttp:1.1.1'
    // GOOGLE ANALYTICS
    compile 'com.google.android.gms:play-services-analytics:7.8.0'
    // JODA TIME FOR ANDROID
    compile 'net.danlew:android.joda:2.8.2'
    // SECURE SHARED PREFERENCES
    compile 'com.scottyab:secure-preferences-lib:0.1.3'
    // MATERIAL DIALOG
    compile 'com.avast:android-styled-dialogs:2.2.0'
    // SQL CIPHER
    compile 'com.commonsware.cwac:sqlcipher-for-android:3.3.1'
    // HTML PARSER
    compile 'org.jsoup:jsoup:1.8.3'
    // MULTIDEX SUPPORT
    compile 'com.android.support:multidex:1.0.0'
}

我幾乎嘗試了一切來解決它,但沒有運氣。 也許有些人給我一個正確的答案。

非常感謝任何建議。

編輯我試圖顯示運行/調試配置,並在“特定儀表運行器”輸入什么都沒有。

所以我插入了以下內容(見下圖),但部分字符串AndroidJUnitRunner為紅色。

在此輸入圖像描述

測試名稱應該以。開頭

test

嘗試將測試重命名為以下內​​容並重新運行

testprocessTest()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM