Skip to content
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

Swift 3+ runForever example #17

Open
PeaceKeeperOrg opened this issue Feb 28, 2017 · 2 comments
Open

Swift 3+ runForever example #17

PeaceKeeperOrg opened this issue Feb 28, 2017 · 2 comments

Comments

@PeaceKeeperOrg
Copy link

Do you have an example of running your DefaultHTTPServer asynchronously in the background using Swift 3.0 or greater? I would like to use Ambassador in an XCTest ( i.e. NOT XCUITest) to build a lightweight mock REST server for unit testing an API that I'm building.

Thanks in advance,
Rowland

@fangpenlin
Copy link
Contributor

Hi @PeaceKeeperOrg,

You can see our UITestBase example in our blog post

https://envoy.engineering/embedded-web-server-for-ios-ui-testing-8ff3cef513df#.jf4nit18p

You can also see the gist here

https://gist.github.com/fangpenlin/b180cc4a3c7bbe123ee298b03067b6ab

Although it's for UI testing, it won't be any different to just inherit from XCTest instead in your case.

@JordiGamez
Copy link

Hi @fangpenlin, I tried to follow those guidelines but I cannot make it work properly.

I have create the files you said in the article but still not working as I expected. I have created the "DefaultRouter" file, UITestBase file and MyUITests file in my UI Test folder. Also I have created an Alamofire requets in my ViewController with is the endpoint I want to mock with Ambassador, but the localhost from Ambassador is always "http://[::1]:8080/api/v2/users" and it never returns the correct information.

What can I do to make it work? Do you have a really working example? Because I never found a real working example mocking an endpoint from a ViewController.

Thanks in advance,

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants