The problem is:
Here the code of my task:
task showReportInBrowser << {
String resultsPath = projectDir.toString().replaceAll("\\\\", '/')
resultsPath = resultsPath + '/build/reports/androidTests/connected/index.html'
java.awt.Desktop.desktop.browse resultsPath.toURI()
}
I have tried this:
connectedCheck.finalizedBy showReportInBrowser
If the connectedCheck executes normally I get what I want. But if the connectedCheck fail, my showReportInBrowser doesn't execute.
I think this is because the connectedCheck task depends on the connectedDebugAndroidTest task, which is failed while execution, therefore the connectedCheck even doesn't start, and my showReportInBrowser does't start too.
So I tried this:
connectedDebugAndroidTest.finalizedBy showReportInBrowser
But gradle said: Error:(75, 0) Could not find property 'connectedDebugAndroidTest' on project ':app'. Open File
I don't understant: why the connectedCheck and connectedDebugAndroidTest are shown both in gradle verification group, but I can use in my buildscript only connectedCheck ?
How can I reach my goal?
In my case the fail was in connectedDebugAndroidTest
task. So, to ignore all fails in particular subtask just use something similar:
connectedDebugAndroidTest {
ignoreFailures = true
}
But in this case it causes
Error:(66, 0) Gradle DSL method not found: 'connectedDebugAndroidTest()'
As shown here you can use the following bypass:
project.gradle.taskGraph.whenReady {
connectedDebugAndroidTest {
ignoreFailures = true
}
}
I'll provide more generic way in case you change your build types / flavors names and/or add more of them
project.gradle.taskGraph.whenReady {
-> project.tasks.findAll { it.name =~ /connected.+AndroidTest/ }.each {
it.ignoreFailures = true
}
}
With this it doesn't matter what are you testing, no FAIL status will be given for any instrumentation test
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.