Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func testThatNetworkAfterEvent() {
- // Use SBTUITunneledApplication instead of XCUIApplication
- let app = SBTUITunneledApplication()
- app.launchTunnelWithOptions([SBTUITunneledApplicationLaunchOptionResetFilesystem]) {
- // do additional setup before the app launches
- // i.e. prepare stub request, start monitoring requests
- }
- app.monitorRequestsWithRegex("(.*)myserver(.*)") // monitor all requests containing myserver
- // 1. Interact with UI tapping elements that generate your events
- // 2. Wait for events to be sent. This could be determined from the UI (a UIActivitiIndicator somewhere in your app?) or ultimately if you have no other option with an NSThread.sleepfortimeinterval
- // 3. Once ready flush calls and get the list of requests
- let requests: [SBTMonitoredNetworkRequest] = app.monitoredRequestsFlushAll()
- for request in requests {
- let requestBody = request.request!.HTTPBody // HTTP Body in POST request?
- let responseJSON = request.responseJSON
- let requestTime = request.requestTime // How long did the request take?
- }
- }
- SBTUITestTunnelServer.registerCustomCommandNamed("myCustomCommandKey") {
- injectedObject in
- // this block will be invoked from app.performCustomCommandNamed()
- }
- func testThatNetworkAfterEvent() {
- let app = ....
- // at the right time
- app.performCustomCommandNamed("myCustomCommand", object: someObjectToInject)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement