2015-02-12 42 views
9

Tôi đang chạy intelliJ ý tưởng 14.0.2 môi trường phát triển android trên cửa sổ và đang cố gắng sử dụng khung kiểm tra giao diện người dùng espresso để kiểm tra ứng dụng của tôi. Tuy nhiên, khi tôi nhấn chạy cho cấu hình androidTest, tôi gặp phải:thử nghiệm cà phê espresso android: bộ kiểm tra trống. không có bài kiểm tra nào được tìm thấy

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. 

đây là ảnh chụp màn hình: enter image description here

lớp thử nghiệm của tôi trông như thế này:

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())); 
    } 
} 

đây là dự án của tôi cấu trúc chỉ trong trường hợp: enter image description here

cấu hình thử nghiệm của tôi: enter image description here

và AndroidManifest.xml của tôi

<?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> 

Trả lời

1

Tôi đã tìm thấy một workaround: sử dụng android-studio dựa trên phiên bản cộng đồng của intelliji ý tưởng thay vì phiên bản cao cấp của ý tưởng intelliji. Tạo một dự án mới và thiết lập espresso từ đó. Chi tiết hơn đề cập đến các tệp gradle trong sample project:

Hy vọng điều đó sẽ hữu ích.

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

-1

Sử dụng chú thích @Test trước khi phương pháp, nơi bạn đã viết tất cả các bài kiểm tra UI ESPRESSO. Điều này có thể hoạt động.

Các vấn đề liên quan