Communicating between app & test runner

My goal is to create a communication mechanism between the UI test runner and my app. That way I can tell the app to display specific data (without laboriously going through the UI steps of getting the app into that state) and also read the values stored as a result of simulated user actions.

So, what are the best options for that kind of IPC? So far I have tried NWListener and friends, but it looks like I'd have to add entitlements to my app, which I'd rather avoid since this is only for testing. Can I have the app listening for some kind of IPC connection without requiring entitlements?

Replies

This is for an iOS app, right? Are primarily concerned with testing in the simulator? Or on a real device? Or do you need both?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Yes, it's iOS and we always run our tests in a simulator.

Add a Comment

The solution I ended up going with is the app opens a socket to listen on, writes out the port it got to a file in SIMULATOR_SHARED_RESOURCES_DIRECTORY, and the test runner reads that file and connects to the port.

I tried using a unix domain socket, but (as the app itself is in C#) the .NET API for that kept throwing PlatformNotSupportedException. I really don't know if there was a real error or if .NET just thinks iOS doesn't support domain sockets.

My approach did still require adding an entitlement, so I'll just have to modify my build script to only include that in the debug build.

Thanks for closing the loop here.

ps I didn't see your earlier reply because I'm not notified if folks reply in the comments. See Quinn’s Top Ten DevForums Tips.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"