我正在研究CircleCI,我正在尝试使用Firebase Test Lab为Android库执行插桩测试(因为CircleCI不支持Android虚拟设备(。
我的检测测试在 Android Studio 下就像一个魅力,但在 Firebase 测试实验室下执行时,它却在挣扎!
实际上,主要问题是,当我编译库时,输出中没有APK文件,而是AAR文件!
$ ./gradlew assembleDebug
$ ./gradlew assembleDebugAndroidTest
那么,您是否建议使用Firebase测试实验室为Android库运行插桩测试?
在这里,我的命令不起作用(由快速通道生成(:
$ gcloud firebase test android run
--type instrumentation
--app lib/build/outputs/apk/androidTest/debug/lib-debug-androidTest.apk
--test lib/build/outputs/apk/androidTest/debug/lib-debug-androidTest.apk
--device model=walleye,version=28,locale=en_US,orientation=portrait
--timeout 30m
$ gcloud firebase test android run
--type instrumentation
--test lib/build/outputs/apk/androidTest/debug/lib-debug-androidTest.apk
--device model=walleye,version=28,locale=en_US,orientation=portrait
--timeout 30m
多亏了@DougStevenson,我只是在我的库项目中添加一个子项目文件夹testlab/,使用一个非常简单的Android应用程序来实现我的库。下面的build.gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.soclip.library.analytics"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
}
dependencies {
// Include the Android library (aar file)
implementation fileTree(dir: '../../lib/build/outputs/aar/', include: ['*.aar'])
}
然后在我的快车道/快速文件文件中,我在运行我的插桩测试之前编译"测试 APK":
default_platform(:android)
platform :android do
desc "Assemble Library"
lane :assemble_library do
gradle(task: "assembleDebug")
end
desc "Assemble App (for Firebase Test Lab)"
lane :assemble_application do
gradle(task: "assembleDebug", project_dir: "testlab/")
end
desc "Assemble Android Test"
lane :assemble_test_application do
gradle(task: "assembleDebugAndroidTest")
end
desc "Assemble Build and Test Application"
lane :assemble do
assemble_library
assemble_application
assemble_test_application
end
desc "Run instrumentation tests in Firebase Test Lab"
lane :instrumentation_tests_testlab do
assemble
run_tests_firebase_testlab(
project_id: "my-firebase-project-id",
app_apk: "testlab/app/build/outputs/apk/debug/app-debug.apk",
android_test_apk: "lib/build/outputs/apk/androidTest/debug/lib-debug-androidTest.apk",
devices: [
{
model: "walleye",
version: "28"
}
],
delete_firebase_files: true)
end
end