-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOException: socket not created when running with Roboelectric Test #440
Comments
Experiencing this, too. Were you able to solve this issue? |
This is still allowing the tests to run, but I just want to suppress it! It's very annoying! |
Have the same issue, too. |
Same here, any fix for this? |
I have the same issue here and use custom RobolectricTestRunner (which defines test version of my application class) to avoid such errors, which seems a little bit hacky solution. Extending Application class:
Then extending MyApplication and overriding isUnitTesting() method:
And then extending RobolectricTestRunner:
Or you can just define it in Config section in test:
|
This looks like it's actually a Robolectric issue. While the workarounds mentioned in this issue do seem like the right strategy short term, long term it would be beneficial to file this bug against Robolectric. Specifically the issue appears to be that LocalSocket simply doesn't work properly on Robolectric and needs to be emulated. My best guess as to why this would be would be that LocalSocket is a Linux-specific concept that Robolectric would need to port to run on other types of systems (OS X, Windows, etc) and that even for Linux it's possible Robolectric lacks the underlying C/C++ implementation to make LocalSocket work properly. Stetho could probably detect this but it would be better and more consistent with Robolectric's long term vision to support this Android API properly so that tests can be written against it. |
If using Robolectric on local unit test, thrown IOException. see facebook/stetho#440
this is the solution I came up with. Works with robolectric 3 if (!isRoboUnitTest()) { public static boolean isRoboUnitTest() { |
it's works perfect |
@kakopappa good works |
Getting this error:
java.io.IOException: socket not created at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:303) at android.net.LocalServerSocket.__constructor__(LocalServerSocket.java:48) at android.net.LocalServerSocket.<init>(LocalServerSocket.java) at com.facebook.stetho.server.LocalSocketServer.bindToSocket(LocalSocketServer.java:142) at com.facebook.stetho.server.LocalSocketServer.listenOnAddress(LocalSocketServer.java:78) at com.facebook.stetho.server.LocalSocketServer.run(LocalSocketServer.java:74) at com.facebook.stetho.server.ServerManager$1.run(ServerManager.java:40)
I have roboelectric test RobolectricTestRunner calls Application's onCreate, and it initialize stetho.
@RunWith(RobolectricTestRunner.class) @Config(constants = BuildConfig.class, sdk = 23)
The text was updated successfully, but these errors were encountered: