Is there a way to work around company authenticated proxy issues in Robolectric during Android unit testing?

131 Views Asked by At

I'm writing unit tests in Android using Robolectric but facing an issue because of my company's authenticated proxy. When running tests, Robolectric attempts to download a Jar file during its initial startup, but fails because it can't get through the proxy authentication. Here's the error message I'm receiving:

ERROR: Failed to fetch maven artifact org.robolectric:android-all-instrumented:13-robolectric-9030017-i4
java.util.concurrent.ExecutionException: java.io.IOException: Server returned HTTP response code: 407 for URL

To solve this, I tried to add the proxy settings to build.gradle like so:

systemProperty 'robolectric.dependency.proxy.host', project.findProperty("systemProp.https.proxyHost")
systemProperty 'robolectric.dependency.proxy.port', project.findProperty("systemProp.https.proxyPort")

However, this hasn't resolved the issue. I believe the error occurs because the proxy needs authentication.

Is there a way to make Robolectric aware of the proxy settings including the authentication? Any advice or suggestions would be greatly appreciated.

Thank you.

0

There are 0 best solutions below