android gradle內打開testCoverageEnabled
android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}
使用gradle指令跑一輪測試,只要測試沒有錯誤,即會產生coverage report
android gradle內打開testCoverageEnabled
android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}
使用gradle指令跑一輪測試,只要測試沒有錯誤,即會產生coverage report
Airtest + poco : https://github.com/AirtestProject/Airtest/blob/master/README_zh.md
Appium :
gradlew <moduleName>:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=<package+class1>,<package+class2>
定義@FixMethodOrder於class上
@BeforeClass:初始化,只會執行一次(init)
note:需要使用static
使用CountDownLatch來做等待的動作
執行CountDownLatch.await()會讓執行序停止
1.gradle新增clearData的task
1.gradle 新增依賴
testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.0.2' androidTestImplementation 'androidx.test:rules:1.2.0'
2.取得context
1.gradle加入junit依賴
dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }
android { defaultConfig { testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } }
2.單元測試代碼