Skip to content

Instantly share code, notes, and snippets.

@eakurnikov
Last active March 5, 2021 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eakurnikov/2ead814a9eb74b755f9146c86e0f6961 to your computer and use it in GitHub Desktop.
Save eakurnikov/2ead814a9eb74b755f9146c86e0f6961 to your computer and use it in GitHub Desktop.
Pull allure results
//buildSrc
class PullResultsFromDevicesTask extends DefaultTask {
private Property<TestsRunConfig> config = project.objects.property(TestsRunConfig.class)
private DirectoryProperty testCasesDir = project.objects.directoryProperty()
@Input
Property<TestsRunConfig> getTestsRunConfig() {
return config
}
@InputDirectory
DirectoryProperty getTestCasesDirectory() {
return testCasesDir
}
@TaskAction
def execute() {
final String testCasesDirPath = testCasesDir.get().asFile.absolutePath
final File allureResultsDir = new File("${testCasesDirPath}/allure-results")
allureResultsDir.mkdir()
config.get().devices.each { String device ->
project.exec {
commandLine('adb', '-s', device, 'pull', '/sdcard/allure-results', testCasesDirPath)
}
}
allureResultsDir.renameTo(new File("${testCasesDirPath}/results"))
println("Allure results pulled from ${config.get().devices} devices successfully")
}
}
//build.gradle
final File baseReportDir = project.file(
project.properties['reportsOutputDir'] ?: new File(rootProject.buildDir, 'reports')
)
final File testCasesDir = new File(baseReportDir, 'json')
final TaskProvider pullResultsFromDevices = tasks.register('pullResultsFromDevices', PullResultsFromDevicesTask) {
description = 'Pulls allure results from all devices and puts them together in results file'
group = 'TestsRun'
testsRunConfig = config
testCasesDirectory = testCasesDir
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment