代码之家  ›  专栏  ›  技术社区  ›  loeschg

androidstudio:右键单击并运行测试总是默认为Gradle配置

  •  1
  • loeschg  · 技术社区  · 6 年前

    使用Android Studio 3.2

    enter image description here

    每当我尝试为类或方法运行特定测试时(无论是右键单击文件->运行还是使用编辑器“gutter”中的绿色三角形运行按钮),Android Studio都会自动创建一个构建配置并尝试运行测试。

    enter image description here

    这种自动创建的构建配置始终是一种渐变配置,与“androidjunit”或“Android Instrumented Tests”配置相反。如果要运行特定的测试类或测试方法,则必须始终手动创建生成配置。

    我该怎么改?我快疯了。


    更新-生成.gradle以及其他信息:

    // app/build.gradle
    
    apply plugin: 'com.android.application'
    
    apply plugin: 'kotlin-android'
    
    apply plugin: 'kotlin-android-extensions'
    
    apply plugin: 'kotlin-kapt'
    
    android {
        compileSdkVersion 27
        defaultConfig {
            applicationId "com.example.android.kotlincoroutines"
            minSdkVersion 21
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    

    另外,我刚刚在另一台计算机上打开了同一个项目(因此不同的androidstudio配置),它默认为正确的构建配置。

    0 回复  |  直到 6 年前