有没有一种方法可以在gradle和pitest的变异下运行仪器化的Android测试?
我有一套在模拟设备上运行的检测Android测试。我可以使用gradlew connectedDebugAndroidTest使用gradle运行它们,我的设置如下:有没有一种方法可以在gradle和pitest的变异下运行仪器化的Android测试?,android,android-studio,gradle,mutation-testing,Android,Android Studio,Gradle,Mutation Testing,我有一套在模拟设备上运行的检测Android测试。我可以使用gradlew connectedDebugAndroidTest使用gradle运行它们,我的设置如下: 当我运行gradlew-pitest或gradlew-pitestDebug时,模拟器不会启动,只有我的单元测试运行。在pitestconfig中指定插入指令的测试类或指定其他测试运行程序没有帮助。我是Android Studio的新手,使用gradle配置变异测试,所以我不确定我是否遗漏了一些简单的东西,或者这绝对是不可能的。更
当我运行
gradlew-pitest
或gradlew-pitestDebug
时,模拟器不会启动,只有我的单元测试运行。在pitest
config中指定插入指令的测试类或指定其他测试运行程序没有帮助。我是Android Studio的新手,使用gradle配置变异测试,所以我不确定我是否遗漏了一些简单的东西,或者这绝对是不可能的。更新:如果没有最简单的插件,这是不可能的,.如果你在测试你的UI时不需要像他们所说的那样添加插入指令的Mecanime:如果你在测试中使用替代的Android框架,比如Robolectric或Unmack Gradle插件,你可能需要将excludeMockableAndroidJar添加到pitest配置中
excludeMockableAndroidJar=true
->适用于Robolectric
pitest {
targetClasses = ['com.myapp.*']
excludeMockableAndroidJar = true
}
apply plugin: 'com.android.application'
apply plugin: 'pl.droidsonroids.pitest'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "my.application.id"
minSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled = true
}
}
useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
// Provides ARCore Session and related resources.
implementation 'com.google.ar:core:1.13.0'
// Provides ArFragment, and other Sceneform UX resources:
implementation "com.google.ar.sceneform.ux:sceneform-ux:1.13.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:+"
// AndroidX Test dependencies
// Core library
androidTestImplementation 'androidx.test:core:1.0.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.0'
// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.0.0'
androidTestImplementation 'androidx.test.ext:truth:1.0.0'
androidTestImplementation 'com.google.truth:truth:0.42'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.0'
// The following Espresso dependency can be either "implementation"
// or "androidTestImplementation", depending on whether you want the
// dependency to appear on your APK's compile classpath or the test APK
// classpath.
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation "org.mockito:mockito-android:+"
implementation 'org.pitest:pitest:1.4.5'
}
pitest {
targetClasses = ['class.to.test.*']
threads = 5
outputFormats = ['HTML']
verbose = true
}
pitest {
targetClasses = ['com.myapp.*']
excludeMockableAndroidJar = true