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

Overview

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.

Comments
  • AsyncBlock crashes

    AsyncBlock crashes

    Started using specta, and simply adding the AsyncBlock macro to my tests makes my tests crash. The following code just doesn't work:

    describe(@"Tests", ^{
        it(@"should do some stuff asynchronously", ^AsyncBlock { // Here the debugger throws an EXC_BAD_ACCESS
            // Async example blocks need to invoke done() callback.
            done();
        });
    });
    

    It's crashing on line 11 of this assembly code:

    libobjc.A.dylib`objc_retain:
    0x497ad70:  pushl  %ebp
    0x497ad71:  movl   %esp, %ebp
    0x497ad73:  subl   $8, %esp
    0x497ad76:  calll  0x497ad7b                 ; objc_retain + 11
    0x497ad7b:  popl   %ecx
    0x497ad7c:  movl   8(%ebp), %eax
    0x497ad7f:  testl  %eax, %eax
    0x497ad81:  je     0x497adb7                 ; objc_retain + 71
    0x497ad83:  movl   (%eax), %edx
    0x497ad85:  movl   16(%edx), %edx      CRASHING HERE
    0x497ad88:  andl   $-4, %edx
    0x497ad8b:  testb  $2, 2(%edx)
    0x497ad8f:  je     0x497ada5                 ; objc_retain + 53
    0x497ad91:  movl   1002945(%ecx), %ecx
    0x497ad97:  movl   %ecx, 4(%esp)
    0x497ad9b:  movl   %eax, (%esp)
    0x497ad9e:  calll  0x497a08c                 ; objc_msgSend
    0x497ada3:  jmp    0x497adb9                 ; objc_retain + 73
    0x497ada5:  movl   %eax, (%esp)
    0x497ada8:  movl   $0, 4(%esp)
    0x497adb0:  calll  0x497c8a0                 ; -[NSObject retain]
    0x497adb5:  jmp    0x497adb9                 ; objc_retain + 73
    0x497adb7:  xorl   %eax, %eax
    0x497adb9:  addl   $8, %esp
    0x497adbc:  popl   %ebp
    0x497adbd:  ret    
    

    Any flags or compiler settings I'm missing? I set the -ObjCflag and I have no compiler errors or warnings. :(

    opened by ianmurrays 40
  • XCTest integration

    XCTest integration

    Xcode 5 projects default to using XCTest instead of OCUnit. Specta should support XCTest when Xcode 5 is released.

    I tried to port Specta once, and the changes were pretty intrusive. Perhaps we should create a xcode5-only branch and try it out there?

    opened by nerdyc 34
  • Testing UIViewController presentedViewController returns nil

    Testing UIViewController presentedViewController returns nil

    I am using Specta to create some tests but I don't seem to be able to get this basic one to pass. The app itself works fine but this test won't pass.

    ViewController

    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        [self showLogin];
    }
    
    - (void)showLogin
    {
        [self presentViewController:[ETLoginVC new] animated:NO completion:nil];
        NSLog(@"PresentedVC: %@", [self.presentedViewController class]);
    }
    

    This logs: PresentedVC: ETLoginVC

    Specs

    SpecBegin(ETLoadingVCSpec)
    
    describe(@"ETLoadingVC", ^{
        __block ETLoadingVC *loadingVC;
    
        beforeEach(^{
            loadingVC = [[ETLoadingVC alloc] initWithUserDefaults:nil];
        });
    
        afterEach(^{
            loadingVC = nil;
        });
    
        describe(@"no current user present", ^{
            it(@"should have a login view controller as the presented view controller", ^{
                expect(loadingVC.presentedViewController).to.beKindOf([ETLoginVC class]);
            });
        });
    });
    
    SpecEnd
    

    This fails with: the actual value is nil/null

    I also tried adding:

    [viewController view];
    

    and:

    [viewController viewWillAppear:NO];
    

    But still no success in getting the expected value for the presentedViewController

    Am I doing something wrong here?

    opened by slhodson969 26
  • v0.3  - Xcode6 and Swift support

    v0.3 - Xcode6 and Swift support

    • [x] replace ^AsyncBlock with waitUntil()
    • [x] make it work on xcode6 (still wip)
    • [ ] add support for writing specs in swift
    • [x] shuffle tests

    Branch: https://github.com/specta/specta/tree/0.3-wip

    opened by petejkim 24
  • requiring

    requiring "Generate Test Coverage Files" and/or "Instrument Program Flow" causes Console spam

    I have recently upgraded to Specta 1.0.2 which required that I set the following flags in the Build Settings of the app under test:

    GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES
    GCC_GENERATE_TEST_COVERAGE_FILES=YES
    

    Now my console log is filled with messages like this:

    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000000)
    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000001)
    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000000)
    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000000)
    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000000)
    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000000)
    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous GCDA file: pt arc tag (0x00000000)
    profiling: /Users/moody/Library/Developer/Xcode/DerivedData/sso-authorizations-embfxpdxuvewkmdvtuwwasxnizxk/Build/Intermediates/sso-authorization.build/Release-iphonesimulator/XCTest.build/Objects-normal/i386/CalUserManagerTest.gcda: cannot merge previous run count: corrupt object tag (0x00000000)
    

    Why are these two flags required? And what can be done about the spam? Cleaning the project works for one run, but the next time I run the tests, they are back.

    opened by jmoody 15
  • XCTool support?

    XCTool support?

    I see a recent pull request went out for xctool 0.2.6, but now that xctool is on 0.2.7, I find I'm not able to run my Specta tests. I brought this up on the xctool repo, and it was suggested I open an issue here.

    Here's a quick summary: When I attempt to run my xctool command for running my tests, my Specta tests are run on [SPTSpec initialize]. This initialize happens prior to xctool launching the simulator and test host.

    Here's the command I'm running:

    xctool -scheme QuickNDirty-Portrait-Tests -destination "platform=iOS Simulator,name=iPhone 6" -sdk iphonesimulator test

    The end of my output with my failure looks like this:

    ** BUILD-TESTS SUCCEEDED ** (51563 ms)
    
    === RUN-TESTS ===
    
      [Info] Collecting info for testables... (2273 ms)
      run-test QuickNDirty-Portrait-Tests.xctest (iphonesimulator9.1, iPhone 6, application-test)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    Failed to query the list of test cases in the test bundle: SKZTournamentSummarySpec: An exception has occured outside of tests, aborting.
    
    NSInvalidArgumentException (Invalid store URL: nil) 
    
      Call Stack:
        0   CoreFoundation                      0x0000000112694f45 __exceptionPreprocess + 165
        1   libobjc.A.dylib                     0x0000000111c6fdeb objc_exception_throw + 48
        2   CoreData                            0x00000001102a16cb +[NSPersistentStoreCoordinator _metadataForPersistentStoreOfType:URL:options:error:] + 1595
        3   QuickNDirty-Portrait-Test-Host      0x000000010e009788 -[VICoreDataManagerSKZ fetchModelVersionHashes:forStoreType:] + 120
        4   QuickNDirty-Portrait-Test-Host      0x000000010e009189 -[VICoreDataManagerSKZ initPersistentStoreCoordinator] + 1161
        5   QuickNDirty-Portrait-Test-Host      0x000000010e00860c -[VICoreDataManagerSKZ persistentStoreCoordinator] + 60
        6   QuickNDirty-Portrait-Test-Host      0x000000010e0099f0 -[VICoreDataManagerSKZ initManagedObjectContext] + 416
        7   QuickNDirty-Portrait-Test-Host      0x000000010e00854c -[VICoreDataManagerSKZ managedObjectContext] + 60
        8   QuickNDirty-Portrait-Test-Host      0x000000010e00b7ae -[VICoreDataManagerSKZ safeContext:] + 78
        9   QuickNDirty-Portrait-Test-Host      0x000000010e009d8b -[VICoreDataManagerSKZ importArray:forClass:withContext:] + 155
        10  QuickNDirty-Portrait-Test-Host      0x000000010e3c4bad +[NSManagedObject(VIManagedObjectAdditions) addWithDictionarySKZ:forManagedObjectContext:] + 413
        11  QuickNDirty-Portrait-Test-Host      0x000000010e03eec1 +[SKZTournamentSummary addMatchCodeTournament:forContext:] + 113
        12  QuickNDirty-Portrait-Tests          0x0000000123fa660e __32-[SKZTournamentSummarySpec spec]_block_invoke_2997 + 4638
        13  QuickNDirty-Portrait-Tests          0x0000000123ffa74c spt_defineDescribeBlock + 430
        14  QuickNDirty-Portrait-Tests          0x0000000123ffa875 context + 46
        15  QuickNDirty-Portrait-Tests          0x0000000123fa533e __32-[SKZTournamentSummarySpec spec]_block_invoke994 + 270
        16  QuickNDirty-Portrait-Tests          0x0000000123ffa74c spt_defineDescribeBlock + 430
        17  QuickNDirty-Portrait-Tests          0x0000000123ff9e66 describe + 32
        18  QuickNDirty-Portrait-Tests          0x0000000123f8db0f -[SKZTournamentSummarySpec spec] + 3103
        19  QuickNDirty-Portrait-Tests          0x0000000123ff4ebc +[SPTSpec initialize] + 205
        20  libobjc.A.dylib                     0x0000000111c70bff _class_initialize + 679
        21  libobjc.A.dylib                     0x0000000111c76d23 lookUpImpOrForward + 176
        22  libobjc.A.dylib                     0x0000000111c858bb objc_msgSend + 187
        23  CoreFoundation                      0x00000001125c206d -[__NSSetM member:] + 77
        24  CoreFoundation                      0x00000001125b0806 -[NSSet containsObject:] + 22
        25  XCTest                              0x000000012150e343 +[XCTestCase(RuntimeUtilities) allSubclasses] + 159
        26  QuickNDirty-Portrait-Tests          0x0000000123ff498a +[XCTestCase(Specta) spt_allSubclasses_swizzle] + 51
        27  XCTest                              0x00000001214d7cf6 +[XCTestSuite _suiteForBundleCache] + 180
        28  XCTest                              0x00000001214d7ece +[XCTestSuite suiteForBundleCache] + 34
        29  XCTest                              0x00000001214d82f2 +[XCTestSuite allTests] + 56
        30  otest-query-lib-ios.dylib           0x000000010f0f0cc9 TestSuite_allTests + 92
        31  otest-query-lib-ios.dylib           0x000000010f0f1f8b +[OtestQuery queryTestBundlePath:] + 603
        32  ???                                 0x000000010f094477 0x0 + 4547232887
        33  ???                                 0x000000010f0945f0 0x0 + 4547233264
        34  ???                                 0x000000010f0907a8 0x0 + 4547217320
        35  ???                                 0x000000010f08faba 0x0 + 4547214010
        36  ???                                 0x000000010f08fb4f 0x0 + 4547214159
        37  ???                                 0x000000010f085d33 0x0 + 4547173683
        38  ???                                 0x000000010f088fed 0x0 + 4547186669
        39  ???                                 0x000000010f085251 0x0 + 4547170897
        40  ???                                 0x00007fff6e4e5656 0x0 + 140735044015702
        41  ???                                 0x00007fff6e4e405c 0x0 + 140735044010076
        42  ???                                 0x00007fff6e4e0276 0x0 + 140735043994230
        43  ???                                 0x00007fff6e4e0036 0x0 + 140735043993654
        44  ???                                 0x0000000000000001 0x0 + 1
    

    The exception being thrown here is in my code, but only occurs because the app itself is never booted up. If it were, the exception would not be thrown.

    A nearly identical command with xcodebuild succeeds:

    xcodebuild -scheme QuickNDirty-Portrait-Tests -destination "platform=iOS Simulator,name=iPhone 6" -sdk iphonesimulator test

    I'm going to proceed with using xcodebuild for now, but I'd really love it if xctool and Specta worked nicely together!

    opened by MattFoley 14
  • Make itShouldBehaveLike evaluate lazily

    Make itShouldBehaveLike evaluate lazily

    I noticed that itShouldBehaveLike evaluates immediately. This required you to supply the data up front instead of via something like a beforeEach/BeforeAll. Adding the shared evaluation to the current group seems to fix it, but I'm not sure what other effects that may have.

    opened by blackgold9 14
  • Failure with runGlobalBeforeEachHooks and external class

    Failure with runGlobalBeforeEachHooks and external class

    First, thanks for all your work on Specta. Great library!

    I'm getting intermittent failures when running my spec suite with version 0.4 via CocoaPods. The failures involve an external library that isn't involved in the specs, but is part of the app. Error log here.

    This external library, AVYPhotoEditorCustomization seems to be getting picked up by [SPTExampleGroup runGlobalBeforeEachHooks:]. Might it be possible in this method to filter for only Specta-related classes?

    I have tried to work around this issue by adding this code to my spec helper (included by all of my spec files), but it doesn't seem to help:

    @interface AVYPhotoEditorCustomization(SPTExclude) <SPTExcludeGlobalBeforeAfterEach>
    @end
    
    @implementation AVYPhotoEditorCustomization(SPTExclude)
    @end
    

    Any guidance for eliminating this failure? Happy to help however I can. Thanks!

    opened by wasnotrice 13
  • Cocoapods does not install '0.3.0.beta1'

    Cocoapods does not install '0.3.0.beta1'

    I written Podfile

        pod 'Specta', '~> 0.3.0.beta1'
        pod 'OCMock', '~> 3.1.1'
        pod 'Expecta', '~> 0.3.1'
    

    and run 'pod install'

    $ pod install
    Update all pods
    Analyzing dependencies
    
    [!] Unable to satisfy the following requirements:
    
    - `Specta (~> 0.3.0.beta1)` required by `Podfile`
    

    I can't install specta '0.3.0.beta1'

    opened by hoiogi 13
  • Specta / Expecta tests running in addition to our app

    Specta / Expecta tests running in addition to our app

    We have an app based on the 0.3 WIP branch of Specta, iOS 8 only and running the GM Xcode 6 build. Specta/Expecta are integrated via CocoaPods. When we run tests (with Command-U) in our app, Specta / Expecta tests run as well. This appears to happen both on the Xcode 6 GM and earlier beta builds.

    Logging includes lines like:

    Test Case '-[_SharedExamplesTest3Spec test_overriding_global_shared_examples_with_local_shared_examples_overridden_shared_example_1_adds_foo_to_items_2]' passed (0.000 seconds).
    
    opened by mgorbach 13
  • Integration with test navigator broken in latest version of Xcode

    Integration with test navigator broken in latest version of Xcode

    After merging PR #83, you may realize that Specta does not correctly report spec success/failure in the Xcode test navigator.

    As of Xcode 6, each test invocation's selector is used to determine the name displayed in the test navigator. Specta uses the same instance method to run each example. As a result, all tests in the same spec had the same name, causing each example to "overwrite" each previous one in the navigator. This caused several issues, including red lines to indicate test failure in Xcode suddenly disappearing when the next example finished running.

    This can be fixed by dynamically defining a new instance method for each example, then creating an invocation to execute that instance method.

    You can find more details here: https://github.com/modocache/Quick/issues/1

    A working implementation of dynamic method definition is here: https://github.com/modocache/Quick/blob/606d77ab12faac00386f24872e33a0347711f0ec/Quick/Core/QuickSpec.m#L33

    opened by modocache 12
  • ExampleGroups: do not create shared example groups in initialize

    ExampleGroups: do not create shared example groups in initialize

    Motivation

    Brute force fix for:

    • Bad access in SPTSharedExampleGroups #225

    Test

    I don't know if this breaks existing tests because tests do not run.

    • No visible @interface for 'XCTestSuite' declares the selector 'run' #223
    opened by jmoody 0
  • Bad access in SPTSharedExampleGroups

    Bad access in SPTSharedExampleGroups

    Reproduce

    • Xcode 9.2, 9.3, 9.4 beta
    • macOS Sierra, High Sierra
    1. Pull calabash-ios-server develop/ branch
    2. Update code sign settings for the XCTest target to match your signing environment
    3. Run an individual XCTest via the Xcode UI until the crash happens (takes 2 - 3 tries)

    Expected

    Tests to complete.

    Found

    Bad access in SPTShareExampleGroups.m#L28

    Analysis

            if (numClasses > 0) {
                classes = (Class *)malloc(sizeof(Class) * numClasses);
                numClasses = objc_getClassList(classes, numClasses);
    
                Class klass, superClass;
                for(uint i = 0; i < numClasses; i++) {
                    klass = classes[i];
                        superClass = class_getSuperclass(klass);
                        if (superClass == SPTSharedExampleGroupsClass) {
                                [[[klass alloc] init] sharedExampleGroups];
                            }
                        }
                    }
                }
                free(classes);
            }
    

    I believe classes are being dealloc'd during the loop.

    I am not sure what this code is trying to accomplish. Skipping the loop appears to have no effect on Specta.

    opened by jmoody 0
  • Tests are skipped nondeterministically

    Tests are skipped nondeterministically

    Some test are skipped in a random way. It happens what the editing and undoing operations affects to this behavior even if in the result the code still be the same. Product cleaning doesn't help. Xcode 8.2.1 Gif: spectabug

    Here is the code:

    #import <Specta/Specta.h>
    
    SpecBegin(TEST)
    
    describe(@"TEST", ^{
    
        
        it(@"test1", ^{
            NSLog(@"1111");
        });
        
        it(@"test2", ^{
            NSLog(@"2222");
        });
        
        it(@"test3", ^{
            NSLog(@"3333");
        });
        
        it(@"test4", ^{
            NSLog(@"4444");
        });
        
        it(@"test5", ^{
            NSLog(@"5555");
        });
        
        afterEach(^{
    
        });
        
        afterAll(^{
            
        });
        
    });
    SpecEnd
    
    
    opened by Denages 0
  • Should fit/fdescribe have other tests show up as pending/failing?

    Should fit/fdescribe have other tests show up as pending/failing?

    I recently found an fdescribe checked into a project. Our continuous integration showed all the tests as passing, so it looked like everything was in good order even though only about 2% of tests were being run.

    I'm wondering if it would make sense to, when an fdescribe or fit are in the suite, mark other tests as either failing or pending to make it more obvious that only a subset of the tests were run.

    (Yes, I'll be adding a Danger rule to prevent this in the future...)

    opened by dbgrandi 0
  • Repeating Unit-Tests

    Repeating Unit-Tests

    Sometimes you have unit-tests failing 'randomly' due to dependencies between tests. SPECTA_SHUFFLE as an environment variable is a nice feature to detect issues like these but it would be a nice additional feature to have a second env-variable to set a repeat count similar to encapsulating your context() or fit() in a for-loop.

    opened by blackivory86 0
Owner
Specta / Expecta
Specta / Expecta
BDD Framework and test runner for Swift projects and playgrounds

Spectre Special Executive for Command-line Test Running and Execution. A behavior-driven development (BDD) framework and test runner for Swift project

Kyle Fuller 392 Jan 1, 2023
BDD-style framework for Swift

Sleipnir Sleipnir is a BDD-style framework for Swift. Sleipnir is highly inspired by Cedar. Also In Norse mythology, Sleipnir is Odin's steed, is the

Railsware 846 Nov 22, 2022
Simple BDD for iOS

Kiwi: Simple BDD for iOS Kiwi is a Behavior Driven Development library for iOS development. The goal is to provide a BDD library that is exquisitely s

Kiwi 4.1k Dec 22, 2022
TestKit has been upgraded to a full solution for implementing Behavior-Driven Development (BDD) in Swift iOS apps.

The easiest way to implement full BDD in your Swift iOS projects! Use plain English specs (Gherkin) to drive tests that include both UI automation and interacting with application data & state.

Daniel Hall 11 Sep 14, 2022
This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD

Apress Source Code This repository accompanies Test-Driven Development in Swift: Compile Better Code with XCTest and TDD by Gio Lodi (Apress, 2021). D

Apress 57 Jan 1, 2023
I built this application with unit testing and test-driven development to understand TDD theory and practice

TestDrivenDevelopment Description I built this application with unit testing and test-driven development to understand TDD theory and practice, to wri

null 1 Dec 21, 2021
A Matcher Framework for Swift and Objective-C

Nimble Use Nimble to express the expected outcomes of Swift or Objective-C expressions. Inspired by Cedar. // Swift expect(1 + 1).to(equal(2)) expect(

Quick 4.6k Dec 31, 2022
The Swift (and Objective-C) testing framework.

Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec, Specta, and Ginkgo. // Swift import Quick import Nimbl

Quick 9.6k Dec 31, 2022
Code coverage for Xcode projects (Objective-C only)

XcodeCoverage provides a simple way to generate reports of the Objective-C code coverage of your Xcode project. Generated reports include HTML and Cob

Jon Reid 854 Dec 19, 2022
AutoMocker is a Swift framework that leverages the type system to let you easily create mocked instances of your data types.

AutoMocker Context AutoMocker is a Swift framework that leverages the type system to let you easily create mocked instances of your data types. Here's

Vincent Pradeilles 39 May 19, 2022
Boilerplate-free mocking framework for Swift!

Cuckoo Mock your Swift objects! Introduction Cuckoo was created due to lack of a proper Swift mocking framework. We built the DSL to be very similar t

Brightify 1.5k Dec 27, 2022
Mockit is a Tasty mocking framework for unit tests in Swift 5.0

Mockit Introduction Mockit is a Tasty mocking framework for unit tests in Swift 5.0. It's at an early stage of development, but its current features a

Syed Sabir Salman-Al-Musawi 118 Oct 17, 2022
A convenient mocking framework for Swift

// Mocking let bird = mock(Bird.self) // Stubbing given(bird.getName()).willReturn("Ryan") // Verification verify(bird.fly()).wasCalled() What is Mo

Bird Rides, Inc 545 Jan 5, 2023
A mocking framework for Swift

SwiftMock SwiftMock is a mocking framework for Swift 5.2. Notes on the history of this repo September 2015: first version of this framework November 2

Matthew Flint 257 Dec 14, 2022
Swift Framework for TestRail's API

QuizTrain ?? ?? QuizTrain is a framework created at Venmo allowing you to interact with TestRail's API using Swift. It supports iOS, macOS, tvOS, and

Venmo 18 Mar 17, 2022
A simple and lightweight matching library for XCTest framework.

Match A simple and lightweight matching library for XCTest framework. Getting started Swift Package Manager You can add Match to your project by addin

Michał Tynior 6 Oct 23, 2022
Genything is a framework for random testing of a program properties.

Genything is a framework for random testing of a program properties. It provides way to random data based on simple and complex types.

Just Eat Takeaway.com 25 Jun 13, 2022
Remote configuration and A/B Testing framework for iOS

MSActiveConfig v1.0.1 Remote configuration and A/B Testing framework for iOS. Documentation available online. MSActiveConfig at a glance One of the bi

Elevate 78 Jan 13, 2021
AB testing framework for iOS

ABKit Split Testing for Swift. ABKit is a library for implementing a simple Split Test that: Doesn't require an HTTP client written in Pure Swift Inst

Recruit Marketing Partners Co.,Ltd 113 Nov 11, 2022