Cucumber-jvm
- Android Module build.gradle:
android {
defaultConfig {
applicationId com.packagename
...
testApplicationId applicationId + ".test"
testInstrumentationRunner "cucumber.api.android.CucumberInstrumentation"
}
sourceSets {
androidTest {
assets.srcDirs = ['src/androidTest/assets']
}
}
...
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'info.cukes:cucumber-android:1.2.0@jar'
androidTestCompile 'info.cukes:cucumber-picocontainer:1.2.0'
androidTestCompile 'info.cukes:cucumber-core:1.2.0'
androidTestCompile 'info.cukes:cucumber-html:0.2.3'
androidTestCompile 'info.cukes:cucumber-java:1.2.0'
androidTestCompile 'info.cukes:cucumber-junit:1.2.0'
androidTestCompile 'info.cukes:cucumber-jvm-deps:1.0.3'
androidTestCompile 'info.cukes:gherkin:2.12.2'
androidTestCompile 'junit:junit:4.12'
}
- 在 Android Studio Module 中建立以下兩種資料夾路徑
src/androidTest/assets/
src/androidTest/com/packagename/test
Troubleshooting:
使用 info.cukes:cucumber-android:1.2.4 執行 gradle Task preDebugAndroidTest 時出現:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
---
此訊息指出使用 Java 1.8 版本(0034.0000)。
且要是 Java 編譯(cafebabe)而非 Android,所以 info.cukes:cucumber-android:1.2.4 項目需用@jar先包成jar檔案。