Skip to content

Instantly share code, notes, and snippets.

@vrunoa
Created January 19, 2016 09:13
Show Gist options
  • Save vrunoa/4a52bbfe28245ff1f274 to your computer and use it in GitHub Desktop.
Save vrunoa/4a52bbfe28245ff1f274 to your computer and use it in GitHub Desktop.
Running appium test from gradle
apply plugin: 'com.android.application'
apply plugin: 'maven'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.urucas.appiumtests"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'io.socket:socket.io-client:0.6.2'
}
ext {
appiumPort = 4723
}
task isAppiumRunning() << {
println "Checking appium is running!"
def request = ["curl", "http://127.0.0.1:$appiumPort/wd/hub/status"].execute()
request.waitFor()
if(request.exitValue() != 0) {
println "Failed to run test, Appium is not running"
System.exit(1)
}
def response = new groovy.json.JsonSlurper().parseText(request.text)
if(response.status != 0) {
println "Failed to run test, Appium is not running"
println "Status Code: $response.status"
System.exit(1)
}
}
task appium(dependsOn: [isAppiumRunning, assembleRelease]) << {
println "Running some tests"
def test1 = ["python", "../../swipe/test.py"].execute()
test1.waitFor()
if(test1.exitValue() != 0) {
println "Test failed, $test1.text"
System.exit(test1.exitValue())
}
def test2 = ["python", "../../request-permission/test.py"].execute()
test2.waitFor()
if(test2.exitValue() != 0) {
println "Test failed, $test2.text"
System.exit(test2.exitValue())
}
println "All test passed"
System.exit(0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment