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

查看:51
本文介绍了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()
    }
}

应用构建.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'
}

项目结构的样子:

项目结构的实际情况:

推荐答案

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

Change the Test Artifact within your Build Variants to Android Instrumentation Tests.

构建变体"选项卡位于收藏夹"上方的 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天全站免登陆