目前分類:Unit Test (10)

瀏覽方式: 標題列表 簡短摘要

android gradle內打開testCoverageEnabled

android {
    buildTypes {
        debug {
            testCoverageEnabled true
        }
    }
}

使用gradle指令跑一輪測試,只要測試沒有錯誤,即會產生coverage report

JBLin 發表在 痞客邦 留言(0) 人氣()

Airtest + poco : https://github.com/AirtestProject/Airtest/blob/master/README_zh.md
Appium : 

JBLin 發表在 痞客邦 留言(0) 人氣()

gradlew <moduleName>:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=<package+class1>,<package+class2>


JBLin 發表在 痞客邦 留言(0) 人氣()

定義@FixMethodOrder於class上

JBLin 發表在 痞客邦 留言(0) 人氣()

@BeforeClass:初始化,只會執行一次(init) 
note:需要使用static

JBLin 發表在 痞客邦 留言(0) 人氣()

使用CountDownLatch來做等待的動作
執行CountDownLatch.await()會讓執行序停止

JBLin 發表在 痞客邦 留言(0) 人氣()

1.gradle新增clearData的task

image

文章標籤

JBLin 發表在 痞客邦 留言(0) 人氣()

1.gradle 新增依賴

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.0.2'
androidTestImplementation 'androidx.test:rules:1.2.0'

2.取得context

JBLin 發表在 痞客邦 留言(0) 人氣()

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.單元測試代碼

JBLin 發表在 痞客邦 留言(0) 人氣()

https://stackoverflow.com/questions/54809410/unresolved-reference-activitytestrule-for-androidx

JBLin 發表在 痞客邦 留言(0) 人氣()