You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio中Journeys测试右键无Test选项问题求助

Android Studio Journeys测试功能问题排查方案

前置依赖检查

Journeys功能依赖Jetpack Compose和Androidx Test框架,需确保模块build.gradle.kts(或build.gradle)中已添加完整依赖并启用Compose:

android {
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.6.8" // 需与Compose依赖版本匹配
    }
}

dependencies {
    // 基础测试依赖
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    // Compose测试核心依赖
    androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.6.8")
    debugImplementation("androidx.compose.ui:ui-test-manifest:1.6.8")
    // Journeys关联测试依赖
    androidTestImplementation("androidx.test:core:1.6.1")
    androidTestImplementation("androidx.test:runner:1.6.2")
}

Android Studio配置验证

  • 启用Journeys实验功能:打开Settings > Experimental,搜索"Journeys",勾选对应复选框(预览版本默认可能关闭该实验项)
  • 刷新模板缓存:执行File > Invalidate Caches... > Invalidate and Restart,重启后重新尝试右键创建流程

手动创建Journey文件的正确操作

若右键选项仍不显示,可手动创建并配置:

  1. 在模块下创建目录src/androidTest/res/journeys(路径必须严格匹配,否则无法被识别)
  2. 创建命名格式为[TestName].journey.xml的文件,基础结构示例:
<Journey xmlns:android="http://schemas.android.com/apk/res/android"
    android:name="LoginFlowJourney">
    <Step name="LaunchMainActivity">
        <Action type="launchActivity" activity="com.example.yourpackage.MainActivity" />
    </Step>
    <Step name="InputCredentials">
        <Action type="setText" target="@id/username" text="test_user" />
        <Action type="setText" target="@id/password" text="test_pass" />
    </Step>
</Journey>
  1. 右键该文件选择Run '[JourneyName]',或通过Run > Edit Configurations添加Journeys类型的运行配置

版本兼容性提示

你使用的Narwal 3 Feature Drop RC 1是预览版本,可能存在功能未完善的bug:

  • 尝试更新至最新的Narwal预览版,或回退到Narwal 2 Feature Drop稳定预览版本
  • 确保Kotlin版本与Compose Compiler版本严格匹配,版本不兼容会导致功能加载失败

内容的提问来源于stack exchange,提问作者Alon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 11:12:34