Carlos López Sánchez
02/14/2023, 9:16 PMTomer Ghelber
02/15/2023, 12:45 PMHarsh
03/02/2023, 7:03 AMHarsh
03/02/2023, 7:13 AMimport XCTest
import PactSwift
class SampleTests: XCTestCase {
static var mockService: MockService = MockService(consumer: "sample-consumer", provider: "sample-provider", merge: false)
func testGetHelloWorld() {
// Define the interaction
SampleTests.mockService.uponReceiving("a request for hello world greetings")
.given("I am new to this world")
.withRequest(method: .GET, path: "/hello/world")
.willRespondWith(status: 200, headers: nil, body: "")
// Make the request to the mock service
SampleTests.mockService.run (timeout: 1, testFunction: { baseURL, testComplete in
let requestUrl = URL(string: "\(baseURL)/hello/world")
let urlRequest = URLRequest(url: requestUrl!)
print("Request url is \(urlRequest.url!)")
let task = URLSession.shared.dataTask(with: urlRequest) {data, response, error in
if let httpResponse = response as? HTTPURLResponse {
print("My statusCode is: \(httpResponse.statusCode)")
XCTAssertEqual(httpResponse.statusCode, 200 )
print ("Response url is: \(String(describing: httpResponse.url))")
}
}
task.resume()
testComplete()
})
}
}
Harsh
03/02/2023, 7:15 AMRequest url is <http://127.0.0.1:5093/hello/world>
My statusCode is: 200
Response url is: Optional(<http://127.0.0.1:5093/hello/world>)
Harsh
03/02/2023, 7:16 AMMarko (IttyBittyApps / pact-swift)
03/02/2023, 7:40 AMFacu Conejero
03/08/2023, 9:31 AMKripa Kurian
03/16/2023, 7:31 PMMark Ingram
03/20/2023, 11:57 AMUlises Cervino
03/22/2023, 9:01 PMomri e
04/13/2023, 1:23 PMPravesh
04/20/2023, 12:23 AMPravesh
04/20/2023, 12:24 AMYousaf Nabi (pactflow.io)
Calum Maciver-Whyte
05/19/2023, 4:34 PMRohit Krishnan
06/07/2023, 6:44 PMYousaf Nabi (pactflow.io)
Tõnis Ojandu
07/05/2023, 6:51 AMJoris van Eijden
07/14/2023, 10:58 AMLotem Dagan
07/20/2023, 10:49 AMStan Amsellem
08/22/2023, 9:36 AMTeea Alarto
08/25/2023, 1:26 PMEytan Hanig
09/01/2023, 3:07 AMTigran Davtyan
09/12/2023, 3:13 AMGeorg Duemlein
09/18/2023, 4:10 AMJamie Weatherby
10/02/2023, 1:11 PMCorey Maynard
10/03/2023, 8:24 PMRuth
10/30/2023, 8:56 PMCody Jenkins
11/01/2023, 2:38 AM