All Projects → specta → Specta

specta / Specta

Licence: mit
A light-weight TDD / BDD framework for Objective-C & Cocoa

Programming Languages

objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Specta

Satin
A 3D Graphics Framework built on Apple's Metal
Stars: ✭ 182 (-92.14%)
Mutual labels:  xcode
Traceutility
Extract data from .trace documents generated by Instruments
Stars: ✭ 188 (-91.88%)
Mutual labels:  xcode
Xchammer
XCHammer generates Xcode projects from a Bazel Workspace.
Stars: ✭ 195 (-91.58%)
Mutual labels:  xcode
Macos Cookbook
A Chef cookbook used to provision macOS
Stars: ✭ 183 (-92.1%)
Mutual labels:  xcode
Faimagecropper
Image Cropper like Instagram
Stars: ✭ 188 (-91.88%)
Mutual labels:  xcode
Todaynews
Swift4 - 今日头条
Stars: ✭ 2,187 (-5.57%)
Mutual labels:  xcode
Environmentoverrides
QA assistant for a SwiftUI app: change the color scheme, accessibility settings, and localization on the fly!
Stars: ✭ 181 (-92.18%)
Mutual labels:  xcode
Nocturnal
A Dimness and Night Shift menu bar app for macOS 🌙
Stars: ✭ 199 (-91.41%)
Mutual labels:  xcode
Xcodeequatablegenerator
Xcode 8 Source Code Extension will generate conformance to Swift Equatable protocol based on type and fields selection.
Stars: ✭ 188 (-91.88%)
Mutual labels:  xcode
Pixelsdk
The modern photo and video editor for your iPhone / iPad app. A fully customizable image & video editing iOS Swift framework.
Stars: ✭ 192 (-91.71%)
Mutual labels:  xcode
Openssl For Iphone
A script for compiling OpenSSL for iOS Devices (iPhone, iPad, iPod Touch, AppleTV, MacCatalyst)
Stars: ✭ 2,190 (-5.44%)
Mutual labels:  xcode
Cleanclosurexcode
An Xcode Source Editor extension to clean the closure syntax.
Stars: ✭ 186 (-91.97%)
Mutual labels:  xcode
Xvim2
Vim key-bindings for Xcode 9
Stars: ✭ 2,297 (-0.82%)
Mutual labels:  xcode
Carting
🚘 A simple tool for updating Carthage script phase
Stars: ✭ 182 (-92.14%)
Mutual labels:  xcode
Pdfxkit
A drop-in replacement for Apple PDFKit powered by our PSPDFKit framework under the hood.
Stars: ✭ 195 (-91.58%)
Mutual labels:  xcode
Lgbutton
A fully customisable subclass of the native UIControl which allows you to create beautiful buttons without writing any line of code.
Stars: ✭ 2,216 (-4.32%)
Mutual labels:  xcode
Injectioniii
Re-write of Injection for Xcode in (mostly) Swift
Stars: ✭ 2,680 (+15.72%)
Mutual labels:  xcode
Keyboardavoidanceswiftui
How to move SwiftUI view up when keyboard appears https://www.vadimbulavin.com/how-to-move-swiftui-view-when-keyboard-covers-text-field/
Stars: ✭ 198 (-91.45%)
Mutual labels:  xcode
Iosdevicesupport
存放iOS镜像文件、iOSDeviceSupport、真机调试包、DeviceSupport、iOS-DeviceSupport,供大家参考,目前收录iOS8.0~iOS14.5,持续更新中
Stars: ✭ 197 (-91.49%)
Mutual labels:  xcode
Youtag
iOS music player app that downloads music from the internet, even YouTube
Stars: ✭ 193 (-91.67%)
Mutual labels:  xcode

Specta Build Status Coverage Status

A light-weight TDD / BDD framework for Objective-C.

FEATURES

  • An Objective-C RSpec-like BDD DSL
  • Quick and easy set up
  • Built on top of XCTest
  • Excellent Xcode integration

SCREENSHOT

EXAMPLE

#import <Specta/Specta.h> // #import "Specta.h" if you're using libSpecta.a

SharedExamplesBegin(MySharedExamples)
// Global shared examples are shared across all spec files.

sharedExamplesFor(@"foo", ^(NSDictionary *data) {
    __block id bar = nil;
    beforeEach(^{
        bar = data[@"bar"];
    });
    it(@"should not be nil", ^{
        XCTAssertNotNil(bar);
    });
});

SharedExamplesEnd

SpecBegin(Thing)

describe(@"Thing", ^{
  sharedExamplesFor(@"another shared behavior", ^(NSDictionary *data) {
    // Locally defined shared examples can override global shared examples within its scope.
  });

  beforeAll(^{
    // This is run once and only once before all of the examples
    // in this group and before any beforeEach blocks.
  });

  beforeEach(^{
    // This is run before each example.
  });

  it(@"should do stuff", ^{
    // This is an example block. Place your assertions here.
  });

  it(@"should do some stuff asynchronously", ^{
    waitUntil(^(DoneCallback done) {
      // Async example blocks need to invoke done() callback.
      done();
    });
  });

  itShouldBehaveLike(@"a shared behavior", @{@"key" : @"obj"});

  itShouldBehaveLike(@"another shared behavior", ^{
    // Use a block that returns a dictionary if you need the context to be evaluated lazily,
    // e.g. to use an object prepared in a beforeEach block.
    return @{@"key" : @"obj"};
  });

  describe(@"Nested examples", ^{
    it(@"should do even more stuff", ^{
      // ...
    });
  });

  pending(@"pending example");

  pending(@"another pending example", ^{
    // ...
  });

  afterEach(^{
    // This is run after each example.
  });

  afterAll(^{
    // This is run once and only once after all of the examples
    // in this group and after any afterEach blocks.
  });
});

SpecEnd
  • beforeEach and afterEach are also aliased as before and after respectively.
  • describe is also aliased as context.
  • it is also aliased as example and specify.
  • itShouldBehaveLike is also aliased as itBehavesLike.
  • Use pending or prepend x to describe, context, example, it, and specify to mark examples or groups as pending.
  • Use ^(DoneCallback done) as shown in the example above to make examples wait for completion. done() callback needs to be invoked to let Specta know that your test is complete. The default timeout is 10.0 seconds but this can be changed by calling the function setAsyncSpecTimeout(NSTimeInterval timeout).
  • (before|after)(Each/All) also accept ^(DoneCallback done)s.
  • Do #define SPT_CEDAR_SYNTAX before importing Specta if you prefer to write SPEC_BEGIN and SPEC_END instead of SpecBegin and SpecEnd.
  • Prepend f to your describe, context, example, it, and specify to set focus on examples or groups. When specs are focused, all unfocused specs are skipped.
  • To use original XCTest reporter, set an environment variable named SPECTA_REPORTER_CLASS to SPTXCTestReporter in your test scheme.
  • Set an environment variable SPECTA_SHUFFLE with value 1 to enable test shuffling.
  • Set an environment variable SPECTA_SEED to specify the random seed for test shuffling.

Standard XCTest matchers such as XCTAssertEqualObjects and XCTAssertNil work, but you probably want to add a nicer matcher framework - Expecta to your setup. Or if you really prefer, OCHamcrest works fine too. Also, add a mocking framework: OCMock.

STATUS

Specta is considered a done project, there are no plans for active development on the project at the moment aside from ensuring future Xcode compatability. Therefore it is a stable dependency, but will not be moving into the Swift world. If you are looking for that, we recommend you consider Quick.

RUNNING SPECTA'S TESTS IN COMMAND LINE

  • Run rake test in the cloned folder.

CONTRIBUTION GUIDELINES

  • Please use only spaces and indent 2 spaces at a time.
  • Please prefix instance variable names with a single underscore (_).
  • Please prefix custom classes and functions defined in the global scope with SPT.

Installation

Use CocoaPods, Carthage or Set up manually

CocoaPods

  1. Add Specta to your project's Podfile:
target :MyApp do
# your app dependencies

  target :MyAppTests do
    inherit! :search_paths

    pod 'Specta', '~> 1.0'
    # pod 'Expecta',     '~> 1.0'   # expecta matchers
    # pod 'OCMock',      '~> 2.2'   # OCMock
    # pod 'OCHamcrest',  '~> 3.0'   # hamcrest matchers
    # pod 'OCMockito',   '~> 1.0'   # OCMock
    # pod 'LRMocky',     '~> 0.9'   # LRMocky
  end
end
  1. Run pod install in your project directory.

Carthage

  1. Add Specta to your project's Cartfile.private

    github "specta/specta" ~> 1.0
    
  2. Run carthage update in your project directory

  3. Drag the appropriate Specta.framework for your platform (located in Carthage/Build/) into your application’s Xcode project, and add it to your test target(s).

  4. If you are building for iOS, a new Run Script Phase must be added to copy the framework. The instructions can be found on Carthage's getting started instructions

SETTING UP MANUALLY

  1. Clone from Github.
  2. Run rake in project root to build.
  3. Add a "Cocoa/Cocoa Touch Unit Testing Bundle" target if you don't already have one.
  4. Copy and add all header files in Products folder to the Test target in your Xcode project.
  5. For OS X projects, copy and add Specta.framework in Products/osx folder to the test target in your Xcode project. For iOS projects, copy and add Specta.framework in Products/ios folder to the test target in your Xcode project. You can alternatively use libSpecta.a, if you prefer to add it as a static library for your project. (iOS 7 and below require this)
  6. Add -ObjC and -all_load to the "Other Linker Flags" build setting for the test target in your Xcode project.
  7. If you encounter linking issues with _llvm_* symbols, ensure your target's "Generate Test Coverage Files" and "Instrument Program Flow" build settings are set to Yes.

LICENSE

Copyright (c) 2012-2016 Specta Team. This software is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].