Latest 0.5.1
Homepage https://github.com/polac24/InjectionTDD
License MIT
Platforms ios 8.0
Frameworks XCTest
Authors

CI Status
Version
Carthage compatible
License
Platform

Swift4
Swift3.1

Synopsis

This library triggers Xcode unit tests using John Holdsworth‘s injectionforxcode tool.

InjectionTDD immediatelly runs your related unit tests, every time you save implemntation file with ⌘+S.

quick

Swift version

InjectionTDD library is written in Objective-C so it works with any Swift version.

Requirements

  • injectionforxcode (version with TDD)
  • implementation and unit test written in Swift (project can be mixed ObjC and Swift)
  • Xcode 8 or Xcode 9
  • valid global Xcode version using xcode-select

Limitations

  • no static libraries (.a or static .framework) used in a target
  • testing target has "Host Application"
  • ⌘+⇧+U (or simple ⌘+U) required when adding new .swift file

requirement_host_application.

Installation

1. Ensure that you have correctly set global Xcode (xcode-select)

  1. Call xcode-select -p
  2. If path does not correspond to your current Xcode version, setup it using command:
sudo xcode-select -s /Applications/PATH_TO_YOUR_XCODE_VERSION/Contents/Developer

2. Integrate InjectionTDD with your Xcode project:

– Integration using CocoaPods

InjectionTDD is available through CocoaPods.

To install it, simply add the following line to your Podfile, into Tests target :warning::

...
  target 'REMTTests' do
    # Your test Pods

    pod 'InjectionTDD', '~> 0.5'
  end

– Integration using Carthage

Add the following line to the Cartfile and link generated .framework library with your test target.

github "polac24/InjectionTDD"

– Integration with compiled .framework

Add binary framework to your test target. You can find compiled framework (InjectionTDD.framework.zip) in releases section.

You can find sample integration on one approach to integrate binary framework.

How to use it?

  1. Run injectionforxcode
  2. After successful InjectionTDD integration with your test target (step 2.), run it (⌘+U) and you will see prompt Ready for InjectionTDD...

prompt

  1. It means that your unit tests wait for injection bundles and will never terminate :white_check_mark:
  2. Using injectionforxcode, inject your implementation (e.g. shortcut ⌃+=)
  3. injectionforxcode automatically finds all related tests for your file and execute them
  4. On output console you will see summary of all actions and summary of your tests :tada:

result

overview

  1. To get feedback immediatelly after each save with ⌘+S, enable "FileWatcher" in injectionforxcode:

file_watcher

  1. You can selectively disable InjectionTDD in your schema but adding INJECTION_TDD_SKIP=TRUE environment variable in a test action:

Skip TDD

Test Summary Notification

To display notification everytime your test finishes, install extra breakpoints that present a summary of your test suite:

Success

Failure

Summary notifications installation:

:warning: Remeber to install breakpoints when Xcode is closed, otherwise new breakpoints may not be added

mkdir -p /tmp/update_breakpoints_tdd && curl https://codeload.github.com/polac24/InjectionTDD/tar.gz/master | tar -xz --strip=3 --directory /tmp/update_breakpoints_tdd InjectionTDD-master/scripts/update_breakpoints/ && cd /tmp/update_breakpoints_tdd/ && ./update_breakpoints.sh && cd -

Best practicies

  1. Keep InjectionTDD integrated all the time (e.g. add it to Podfile) and provide two schemas: (1) used for TDD development only, (2) used for CI with disabled InjectionTDD (see how). This helps to quickly switch between standard and TDD development.

Schemas

Recommendations

  • If you want to speed up your injection, disable code coverage. Just unselect "Gather coverage data" in your test scheme when doing TDD: no_coverage

Author

Bartosz Polaczyk, [email protected]

Credits

This library is an addition to John Holdsworth great tool injectionforxcode. More details about live code injection you will find at Injection, the App and @Orta video post.

License

InjectionTDD is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "InjectionTDD",
    "version": "0.5.1",
    "summary": "TDD test support",
    "platforms": {
        "ios": "8.0"
    },
    "description": "This library allows to freeze Xcode unit tests in order tonlet injectionforxcode tool ability to live update implementation code nand its unit tests.nnThis library has sense to work only with injectionforxcode tongive full TDD experience.",
    "homepage": "https://github.com/polac24/InjectionTDD",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Bartosz Polaczyk": "[email protected]"
    },
    "source": {
        "git": "https://github.com/polac24/InjectionTDD.git",
        "tag": "0.5.1"
    },
    "social_media_url": "https://twitter.com/norapsi",
    "source_files": "InjectionTDD/Classes/**/*",
    "pod_target_xcconfig": {
        "GCC_GENERATE_DEBUGGING_SYMBOLS": "NO"
    },
    "frameworks": "XCTest"
}

Pin It on Pinterest

Share This