gpt4 book ai didi

android espresso 测试 : empty test suite. 未找到测试

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:54 25 4
gpt4 key购买 nike

我在 Windows 上运行 intelliJ idea 14.0.2 android 开发环境,并尝试使用 espresso UI 测试框架来测试我的应用程序。但是,当我按 run 进行 androidTest 配置时,我遇到以下问题:

Testing started at 12:09 PM ...
Waiting for device.
Target device: lge-nexus_5-05b1bd8af0ddba12
Uploading file
local path: C:\Users\AsiAnSeNsAtIoN\Documents\note\ECSE428\AssB_2\build\classes\main\AssB_2.apk
remote path: /data/local/tmp/com.cyc115.VectorCalculator
Installing com.cyc115.VectorCalculator
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.cyc115.VectorCalculator"
pkg: /data/local/tmp/com.cyc115.VectorCalculator
Success

Running tests
Test running startedFinish
Empty test suite.

这是截图: enter image description here

我的测试类是这样的:

package com.cyc115.VectorCalculator.test;

import android.support.test.espresso.assertion.ViewAssertions;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
import com.cyc115.VectorCalculator.MyActivity;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

@LargeTest
public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity> {

public MyActivityTest(){
super (MyActivity.class);
}

@Override
public void setUp() throws Exception {
super.setUp();
getActivity();
fail();
}
@SmallTest
public void testListGoesOverTheFold() {
onView(withText("Hello world")).check(ViewAssertions.matches(isDisplayed()));
}
}

为了以防万一,这是我的项目结构: enter image description here

我的测试配置: enter image description here

和我的androidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cyc115.VectorCalculator"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="21"/>

<instrumentation
android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.cyc115.VectorCalculator"
/>

<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity android:name="com.cyc115.VectorCalculator.MyActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

最佳答案

我找到了一个解决方法:使用基于intelliji idea社区版的android-studio,而不是intelliji idea的高级版。创建一个新项目并从那里设置 Espresso 。更多详细信息请参阅 sample project 中的 gradle 文件:

希望对您有所帮助。

http://developer.android.com/sdk/index.html

关于android espresso 测试 : empty test suite. 未找到测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28484139/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com