首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Intellij 16 -单元测试不被识别为android模块项目的一部分

Intellij 16 -单元测试不被识别为android模块项目的一部分
EN

Stack Overflow用户
提问于 2016-01-06 17:32:48
回答 2查看 686关注 0票数 2

我正在尝试IntelliJ16EAP,我无法正确地导入android项目。不承认频域测试是项目的一部分。

我正在导入的项目是一个示例项目,可以在github上找到:

https://github.com/robolectric/deckard

这是build.gradle文件:

代码语言:javascript
复制
buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

repositories {
    jcenter()
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 2
        versionName "1.0.0-SNAPSHOT"
        applicationId "com.example"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    packagingOptions {
        exclude 'LICENSE.txt'
    }
}

dependencies {
    // Support v4
    compile 'com.android.support:support-v4:23.1.1'

    // Espresso
    androidTestCompile 'com.android.support:support-annotations:23.1.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'

    // Robolectric
    testCompile 'junit:junit:4.12'
    testCompile 'org.hamcrest:hamcrest-library:1.3'
    testCompile 'org.apache.maven:maven-ant-tasks:2.1.3' // fixes issue on linux/mac
    testCompile 'org.robolectric:robolectric:3.0'
}

有线索知道为什么会发生这种事吗?

编辑: 1)如果我从gradle中删除所有android插件,然后添加java插件,立即识别单元测试并将它们添加到项目中。然后,一旦我切换回android插件,intellij再次删除它。2)我尝试了Intellij 15和AndroidStudio2.0,并且得到了相同的结果

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-07 15:26:57

经过一番挖掘,我发现这似乎是一种预期的做事方式。您只能在任何时候在项目中导入插装测试或单元测试。您可以在“构建变体”窗口中的2之间切换。

我还发现了https://www.youtube.com/watch?v=vdasFFfXKOY&index=3&list=LLM9iluZir-2dWQTQ-WfJdbw的视频,在15:30中,描述了这种奇怪的行为。他还说,它将在AndroidStudio2.0中修复,但通过测试,情况正好相反。

票数 1
EN

Stack Overflow用户

发布于 2016-01-06 18:46:02

您可能必须在模块设置中将测试文件夹标记为“测试文件夹”。Ctrl+alt+shift+S

另外,最好从金丝雀频道使用AndroidStudio2.0。它以Intellij 15为基础。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34639166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档