Unable to run real device -- Pactconsumer
vivekthambikannu opened this issue · 1 comments
Hi, I am using pact consumer in my project, real time device only able to run my project unable to run in simulator.
Initially I use pactswift, after facing this issue i changed pact consumer
my local ip address is = 120.138.12.180, iam getting this error
failed - Error setting up pact: The request timed out.
failed - Verification error (check build log for mismatches): The request timed out.
My code
let verificationService = PactVerificationService(url: "http://120.138.12.180/", port: 1234)
mockService = MockService(provider: "Provider", consumer: "iOS", pactVerificationService: verificationService)
func testConsumerMaintenance() {
let apiService = ApiService()
let urL = mockService.baseUrl
print("localUrl",urL)
guard let url = URL(string: "\(urL)/banner") else {
XCTFail("Failed to prepare url!")
return
}
mockService.given("an alligator exists")
.uponReceiving("a request for all alligators")
.withRequest(method:.GET, path: "/banner",headers: ["Authorization": "Bearer a.b.c"])
.willRespondWith(status: 200,
body: userResponse)
//Run the tests
mockService.run(timeout: 10000) { (testComplete) -> Void in
apiService.apiPostMethod(url: url, withHttpMethod: .GET) { (alligators) in
XCTAssertNotNil(alligators)
XCTAssertEqual(2, alligators?.data?[0].id)
testComplete()
}
}
}
Wrong framework. If you're using pact-consumer-swift
then you should share the environment set up and what you've tried already here.
PactSwift
will not work with an external Pact Mock Service. The PactSwift.MockService.run
's completion block will give you the url String
to point your API client to.