JanGorman / Hippolyte

HTTP Stubbing in Swift
MIT License
111 stars 18 forks source link

Support for XCUITest ? #2

Open Shashikant86 opened 6 years ago

Shashikant86 commented 6 years ago

This is quick question not an issue.

DO you think this approach will wok to stub the Xcode UI Tests as well ?

@JanGorman Let me know what you think ?

JanGorman commented 6 years ago

Hey,

yes, this will work for any kind of tests since it globally swaps out url handling with its own implementation. Just call Hippolyte.shared.start() at the beginning and you should be good.

Shashikant86 commented 6 years ago

I tried & it doesn't seems to be working.. Do you have any example that worked for UI tests ? Do we need to do specific configuration in order to get that working. I will probably create demo project and send it to you as an example.

JanGorman commented 6 years ago

Interesting… I never tried it with UI tests, a quick sample project would be helpful. But now that I think about it some more it indeed might be an issue because the ui tests launch the app differently. So maybe passing launch arguments and then doing something in the application target to stub might be needed. Not ideal. If you can provide a sample great, I'll further investigate too later today

Shashikant86 commented 6 years ago

Yes UI Tests are designed as black box and there is no access to app code directly. The Swifter framework works with UI Tests but shame its not updated for Swift 4. It launch web server in the UI test process itself on localhost:8080 More info here http://swiftpearls.com/dynamic-ui-testing-http-mocking.html It would be great if we can do something for Hippolyte as well :)

JanGorman commented 6 years ago

Interesting approach that – for those cases we've used a separate small web app written in Sinatra but embedding is pretty clever. Somehow Swifter flew under my radar