```import XCTest import PactSwift class SampleTes...
# pact-swift
h
Copy code
import 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()
        })
    }
}