AndroidTest文件夹未显示在AndroidStudio上 [英] AndroidTest folder doesn't show on AndroidStudio

查看:174
本文介绍了AndroidTest文件夹未显示在AndroidStudio上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Gradle和Android Studio以及Espresso UI测试为项目设置Android应用程序结构.

I'm setting up Android app structure with Gradle and Android Studio and Espresso UI testing for a project.

无论我做什么,androidTest文件夹都不会出现在AndroidStudio的项目结构中.

No matter what I try, the androidTest folder never appears in AndroidStudio's project structure.

项目(根)build.gradle:

Project (root) build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

应用程序build.gradle:

App build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2'
    }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "es.unizar.vv.mobile.catmdedit.app"
        minSdkVersion 16
        targetSdkVersion 16
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'

            java {
                srcDir 'src/main/java'
            }
            resources {
                srcDir 'src/main/resources'
            }
            res.srcDirs = ['res']
        }

        test.setRoot("test")

        androidTest.setRoot("androidTest")
    }
}

dependencies {
    androidTestCompile 'com.android.support.test:runner:0.2'
    androidTestCompile 'com.android.support.test:rules:0.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
}

项目结构如何:

项目结构实际上是怎样的:

How project structure actually is:

推荐答案

将您的 Build Variants 中的 Test Artifact 更改为 Android Instrumentation Tests

"Build Variants"标签可以在Android Studio窗口的收藏夹"上方的左下方找到.单击选项卡将打开一个包含您的模块的窗格,并为这些模块构建变体.模块上方是Test Artifact下拉菜单,您应该将其更改为Android Instrumentation Tests.

The Build Variants tab can be found in the bottom left side of the Android Studio window above Favorites. Clicking on the tab should open a pane with your modules and build variants for those modules. Above the modules is a Test Artifact dropdown which you should change to Android Instrumentation Tests.

这篇关于AndroidTest文件夹未显示在AndroidStudio上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆