Code Monkey home page Code Monkey logo

pactobjectivecexample's Introduction

Example Pact ObjectiveC project using Git Submodules

Build Status

See the Pact Swift library for more details. PactConsumerSwift library

Installation with CocoaPods

Install the pact-mock_service

gem install pact-mock_service -v 0.5.5

Add to your Test target in your Podfile

target 'MyProjectTests' do
  pod 'PactConsumerSwift'
end

Setup your Test Target to run the pact server before the tests are run

Modify the Test Target's scheme to add scripts to start and stop the pact server when tests are run.

  • From the menu Product -> Scheme -> Edit Scheme

  • Under Test, Pre-actions add a Run Script Action Add a Run Script Action with the following NB: the PATH variable should be set to the location of the pact-mock-service binary - you can find the path using which pact-mock-service

    PATH=/path/to/pact-mock-service/binary:$PATH
    "$SRCROOT"/Pods/PactConsumerSwift/scripts/start_server.sh
    • Make sure you select your project under Provide the build settings from, otherwise SRCROOT will not be set which the scripts depend on

  • Under Test, Post-actions add a Run Script Action to stop the pact service.

    PATH=/path/to/pact-mock-service/binary:$PATH
    "$SRCROOT"/Pods/PactConsumerSwift/scripts/stop_server.sh
    • Make sure you select your project under Provide the build settings from, otherwise SRCROOT will not be set which the scripts depend on

Objective-C Caveat: Your Test Target Must Include At Least One Swift File

The Swift stdlib will not be linked into your test target, and thus PactConsumerSwift will fail to execute properly, if you test target does not contain at least one Swift file. If it does not, your tests will exit prematurely with the following error:

*** Test session exited(82) without checking in. Executable cannot be
loaded for some other reason, such as a problem with a library it
depends on or a code signature/entitlements mismatch.

To fix the problem, add a blank file called BlankClass.swift to your test target:

// BlankClass.swift

import PactConsumerSwift

Writing tests

See PactTests.m for examples of writing Pact tests in Objective C. For Swift see Pact Swift Example

pactobjectivecexample's People

Contributors

andrewspinks avatar

Watchers

Kohki Miki avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.