task 'connectedAndroidTest' fails with --continue option

1,006 views
Skip to first unread message

Andrii Bogachenko

unread,
Aug 19, 2014, 7:14:05 AM8/19/14
to adt...@googlegroups.com
Hello, Guys, guys need your help.

I am having a multiproject, which, we may say, consist of two android projects with configured android plugin.
from the root project I configured that I am testing them one by one with robotium tests. 
so that launching one task, executes both project with task 'connectedAndroidTest'.
If everything is ok, and no one robotium test fails, both applications work good, I am having SUCCESS.
If in first application something fails, than second application is not even launching.

Even if I am starting execution with '--continue' option. It fails and stops.

Andrii Bogachenko

unread,
Aug 19, 2014, 7:17:59 AM8/19/14
to adt...@googlegroups.com
root build.gradle code
<code>
configure(getSubProjectList()) 
{
task testApp(type: GradleBuild) {
buildFile =  'build.gradle'
tasks = ['connectedAndroidTest']
startParameter.setContinueOnFailure(true)   // this also passes '--continue' explicitly but it is not helping anyway
}
}

def getSubProjectList() {
if (properties.containsKey('app')){
subprojects.findAll {
app.contains(it.name)
}
} else {
return []
}
}
</code>

Xavier Ducrohet

unread,
Aug 19, 2014, 11:58:58 AM8/19/14
to adt...@googlegroups.com
It looks like you are creating a task that is meant to run a separate Gradle call, per subproject. so each project is called with --continue, but the first call isn't.

--continue is used very specifically by task of type Test so that they do not throw an exception if a test fail in order to not stop the execution of Gradle. The GradleBuild task likely doesn't do that.

I would find a different solution. For instance create a simple empty task, then figure out which projects you want to run (since it seems to be dynamic), and simply make you empty task depend on the project task using the "fully-qualified" task name (:mysubproject:connectedAndroidTest').






--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Andrii Bogachenko

unread,
Aug 20, 2014, 10:16:40 AM8/20/14
to adt...@googlegroups.com
Well I`ll now try to use your advise, and I didin`t know that --continue has influence only on test type tasks.
But actually my gradle script is a little more complex. 
Each of my android projects are having two build.gradle files. I want to run each application twice, with differneces in number of tasks. 
That`s why I am using GradleBuild task types, because it is impossible to run a task twice during the gradle script execution.

Maybe there is a way to make a try-catch block, as it is made in gradle`s test task? 
But then it is probably necessary to write a task in buildSrc foler and create something like my own plugin? 


Вівторок, 19 серпня 2014 р. 18:58:58 UTC+3 користувач Xavier Ducrohet написав:
It looks like you are creating a task that is meant to run a separate Gradle call, per subproject. so each project is called with --continue, but the first call isn't.

--continue is used very specifically by task of type Test so that they do not throw an exception if a test fail in order to not stop the execution of Gradle. The GradleBuild task likely doesn't do that.

I would find a different solution. For instance create a simple empty task, then figure out which projects you want to run (since it seems to be dynamic), and simply make you empty task depend on the project task using the "fully-qualified" task name (:mysubproject:connectedAndroidTest').

Xavier Ducrohet

unread,
Aug 20, 2014, 11:22:44 AM8/20/14
to adt...@googlegroups.com
I think you can do this:

- Create your own task type, make it implement org.gradle.api.tasks.VerificationTask
- In that task, call your other Gradle projects, maybe through the tooling API.
- In your task, check the result and the getIgnoreFailures() and only throw if the result is failure and getIgnoreFailures() return false.

I *think* that gradle will look for all task withType VerificationTask and call setIgnoreFailures if --continue is passed.

You may want to also pass --continue to your secondary build.gradle project when you call it.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrii Bogachenko

unread,
Aug 21, 2014, 7:13:22 AM8/21/14
to adt...@googlegroups.com
during experiments it occured that if I am implementing my own task which implements VerificationTask, it is not saying that launching my implemented task with --continue will work for some fails.
I am saying that just for instance.
 
In my case I will just implement a code in the way that it will be working by configuring a flag, and ignoring failures by default.

Thanks for your help, now seems I know how to solve my problem. =)

But sadly it hasn`t worked so simply =))

Середа, 20 серпня 2014 р. 18:22:44 UTC+3 користувач Xavier Ducrohet написав:

Виталий Попов

unread,
Mar 5, 2017, 11:24:04 AM3/5/17
to adt-dev

Hello, if found another solution, add these lines in the root build.gradle:

//if in start command "--continue" was added, then apply ignoring for android test fails
gradle.taskGraph.whenReady { graph ->
if (gradle.startParameter.continueOnFailure) {
graph.allTasks.findAll { it.name ==~ /connected.*AndroidTest/ }*.ignoreFailures = true
}
}
Reply all
Reply to author
Forward
0 new messages