Skip to content

Instantly share code, notes, and snippets.

@SKART1
Created January 10, 2017 10:16
Show Gist options
  • Save SKART1/d28e175f46feb654af693113e7091090 to your computer and use it in GitHub Desktop.
Save SKART1/d28e175f46feb654af693113e7091090 to your computer and use it in GitHub Desktop.
task testOnPlantation(dependsOn: ['pullInstrumentationApks', 'assembleDebug', 'assembleAndroidTest', 'performTesting']) {
performTesting.mustRunAfter pullInstrumentationApks
performTesting {
def startTime = System.currentTimeMillis();
def shouldLogToWatson = Boolean.parseBoolean((String) System.env.shouldLogToWatson)
def buildType = (String) System.env.buildType
def buildBranch = (String) System.env.buildBranch
def buildVersion = android.defaultConfig.versionName
serverAddress = 'http://172.18.89.85:10800'
testAuthorFilterValue = parseCsv((String) System.env.testAuthorFilterValue)
testNameFilterValue = parseCsv((String) System.env.testNameFilterValue)
pollInterval = 2_000L
//Instrumentaion apks
def butlerFullPath = intrumentationApksPath + File.separator + testButlerFullName + "-" + testButlerAllVersion + ".apk"
def butlerReducedPath = intrumentationApksPath + File.separator + testButlerReducedName + "-" + testButlerAllVersion + ".apk"
instrumentApkListIfEmulator = [new File(butlerFullPath)]
instrumentApkListIfHardwareDevice = [new File(butlerReducedPath)]
////Data
appApkFile = new File('app/build/outputs/apk/app-development-debug.apk')
testApkFile = new File('app/build/outputs/apk/app-development-debug-androidTest.apk')
testListFile = new File(fileWithTestsPath)
//Parameters
testInstrumentationRunner = android.defaultConfig.testInstrumentationRunner
testInstrumentationTimeout = new TimeDuration(0, 4, 0, 0).toMilliseconds()
testExternalTimeout = new TimeDuration(0, 8, 0, 0).toMilliseconds()
outputPath = buildDir.absolutePath
runName = System.env.RUN_NAME;
runMeta = ["Started at" : new SimpleDateFormat("HH:mm:ss dd.MM.yyyy", Locale.US).format(new Date()),
"From machine": InetAddress.getLocalHost().getHostName()]
clearApplicationDataBefore = Boolean.parseBoolean((String) System.env.clearApplicationDataBefore)
clearApplicationDataAfter = Boolean.parseBoolean((String) System.env.clearApplicationDataAfter)
//BeforeRound
beforeRoundPlugins = new ArrayList<PluginBean>()
if (shouldLogToWatson) {
Map<String, String> watsonStartBeforeRoundPluginParameters = new WatsonStartBeforeRoundPlugin.Builder()
.sendToWatson("https", "watson.at.odkl.ru", 443)
.withProperties(buildType, buildBranch, buildVersion)
.build();
beforeRoundPlugins.add(new PluginBean(WatsonStartBeforeRoundPlugin.class.canonicalName, watsonStartBeforeRoundPluginParameters));
}
//AfterRound
afterRoundPlugins = new ArrayList<PluginBean>()
if (shouldLogToWatson) {
Map<String, String> parameters = new WatsonFinishAfterRoundPlugin.Builder()
.sendToWatson("https", "watson.at.odkl.ru", 443)
.build();
afterRoundPlugins.add(new PluginBean(WatsonFinishAfterRoundPlugin.class.canonicalName, parameters));
}
//AfterLaunch
afterLaunchPlugins = new ArrayList<PluginBean>()
afterLaunchPlugins.add(new PluginBean(AfterLaunchStatusPlugin.class.canonicalName, Collections.emptyMap()));
Map<String, String> artifactPublishingAfterLaunchPluginParameters = new ArtifactPublishingAfterLaunchPlugin.Builder()
.withHost("https://testutils.at.odkl.ru/")
.forProject("android-ui-test")
.build();
afterLaunchPlugins.add(new PluginBean(ArtifactPublishingAfterLaunchPlugin.class.canonicalName, artifactPublishingAfterLaunchPluginParameters));
if (shouldLogToWatson) {
Map<String, String> watsonAfterLaunchReporterPluginParameters = new WatsonAfterLaunchReporterPlugin.Builder()
.sendToWatson("https", "watson.at.odkl.ru", 443)
.markers("/marker")
.logs("/uploadLogs", "log_suffix.txt")
.build();
afterLaunchPlugins.add(new PluginBean(WatsonAfterLaunchReporterPlugin.class.canonicalName, watsonAfterLaunchReporterPluginParameters));
}
responseHandler = {
println "END for "+ (System.currentTimeMillis() - startTime)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment