Question

I am trying to put a minimal BLE test harness together where the test controls both ends of the BLE connection. The code under test runs On-Device (iOS7 simulator doesn't support BLE) and uses CBCentralManager. The peripheral end of the connection will be on a MacBook Pro.

The iOS XCTestCase is running on the same Mac under Xcode.

I want my test code, running in XCTestCase, to be able to control the peripheral end of the BLE connection.

Thus a typical test might be:

1) XCTestCase calling code under test to cause it to connect to the peripheral (Mac). 2) When the connection is achieved the XCTestCase causes the peripheral (mac) to close the connection. 3) XCTestCase checks the result generated by the code under test in iOS.

So my problem is how can iOS XCTestCase communicate/control to code running in OS X (The Mac's environment) Everything is running on the same mac under Xcode supervision except the code behaving as the peripheral end.

I hope I have explained the scenario well enough and this the right place for this type of question.

One idea I had was to have an web server running on the Mac to which both the XCTestCase code and the peripheral code would pass messages to each other. More direct comms would be better.

Thanks.

Was it helpful?

Solution

The iOS XCTestCase is running on the same Mac under Xcode.

That's not true. The iOS test cases don't run on the mac. They are injected into the application and they are running on the iOS device. Xcode is only listening to some device events.

Let's simplify the question - you want iOS and Mac to communicate. Whether this is in a production application or while running tests doesn't matter. The XCTests work the same as any other part of an iOS application and can access the same classes.

Creating a socket from the iOS device to the mac (or sending HTTP requests from the device to the mac) is the most simple solution. Raw TCP sockets should be a better solution if you want the communication channel to work in both directions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top