Permalink
Browse files

improved spec. Tests for #190

  • Loading branch information...
1 parent b27e40a commit a71381d736d4427b7e40b6213e251bc588d4eacc Marin Usalj committed Jan 24, 2013
Showing with 48 additions and 40 deletions.
  1. +1 −4 Kiwi.xcodeproj/project.pbxproj
  2. +47 −36 Tests/KWFunctionalTests.m
@@ -435,11 +435,8 @@
6B39D95F155C9FCB003C3444 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
6B39D960155C9FCB003C3444 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
832C83C7157263B300F160D5 /* libKiwi-OSX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libKiwi-OSX.a"; sourceTree = BUILT_PRODUCTS_DIR; };
-<<<<<<< HEAD
- 9F4C095816B16A6D00FCCCD3 /* Release.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = Release.txt; sourceTree = "<group>"; };
-=======
89F9CB7B16B1C2C400E87D34 /* KWFunctionalTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWFunctionalTests.m; sourceTree = "<group>"; };
->>>>>>> test_190
+ 9F4C095816B16A6D00FCCCD3 /* Release.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = Release.txt; sourceTree = "<group>"; };
9F982A1616A7FCD00030A0B1 /* Kiwi.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = Kiwi.podspec; sourceTree = "<group>"; };
9F982A1D16A801800030A0B1 /* Carrier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Carrier.h; path = "Test Classes/Carrier.h"; sourceTree = "<group>"; };
9F982A1E16A801800030A0B1 /* Carrier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Carrier.m; path = "Test Classes/Carrier.m"; sourceTree = "<group>"; };
View
@@ -8,49 +8,60 @@
#import "Kiwi.h"
#import "KiwiTestConfiguration.h"
-#import "TestClasses.h"
-#if KW_TESTS_ENABLED
+static BOOL tests_were_run = NO;
-@interface KWFunctionalTests : SenTestCase
-@end
+SPEC_BEGIN(Functional)
-@implementation KWFunctionalTests
+NSMutableArray *calls = @[@"OuterTestCase",
+@"BeforeAll", @"AfterAll", @"BeforeEach", @"AfterEach", @"TestCase",
+@"InnerBeforeAll", @"InnerAfterAll", @"InnerBeforeEach", @"InnerAfterEach", @"InnerTestCase",
+@"DoubleInnerBeforeAll", @"DoubleInnerAfterAll", @"DoubleInnerBeforeEach", @"DoubleInnerAfterEach", @"DoubleInnerTestCase"
+].mutableCopy;
-- (void)testInnerContextsAreExecuted {
- NSMutableArray *calls = @[@"OuterTestCase",
- @"BeforeAll", @"AfterAll", @"BeforeEach", @"AfterEach", @"TestCase",
- @"InnerBeforeAll", @"InnerAfterAll", @"InnerBeforeEach", @"InnerAfterEach", @"InnerTestCase",
- @"DoubleInnerBeforeAll", @"DoubleInnerAfterAll", @"DoubleInnerBeforeEach", @"DoubleInnerAfterEach", @"DoubleInnerTestCase"
- ].mutableCopy;
-
- describe(@"OuterDescribe", ^{
- it(@"OuterTestCase", ^{ [calls removeObject:@"OuterTestCase"]; });
- context(@"OuterContext", ^{
- beforeAll(^{ [calls removeObject:@"BeforeAll"]; });
- afterAll(^{ [calls removeObject:@"AfterAll"]; });
- beforeEach(^{ [calls removeObject:@"BeforeEach"]; });
- afterEach(^{ [calls removeObject:@"AfterEach"]; });
- it(@"TestCase", ^{ [calls removeObject:@"TestCase"]; });
- context(@"Context", ^{
- beforeAll(^{ [calls removeObject:@"InnerBeforeAll"]; });
- afterAll(^{ [calls removeObject:@"InnerAfterAll"]; });
- beforeEach(^{ [calls removeObject:@"InnerBeforeEach"]; });
- afterEach(^{ [calls removeObject:@"InnerAfterEach"]; });
- it(@"InnerTestCase", ^{ [calls removeObject:@"InnerTestCase"]; });
- context(@"InnerContext", ^{
- beforeAll(^{ [calls removeObject:@"DoubleInnerBeforeAll"]; });
- afterAll(^{ [calls removeObject:@"DoubleInnerAfterAll"]; });
- beforeEach(^{ [calls removeObject:@"DoubleInnerBeforeEach"]; });
- afterEach(^{ [calls removeObject:@"DoubleInnerAfterEach"]; });
- it(@"DoubleInnerTestCase", ^{ [calls removeObject:@"DoubleInnerTestCase"]; });
- });
+describe(@"OuterDescribe", ^{
+ it(@"OuterTestCase", ^{ [calls removeObject:@"OuterTestCase"]; });
+ context(@"OuterContext", ^{
+ beforeAll(^{ [calls removeObject:@"BeforeAll"]; });
+ afterAll(^{ [calls removeObject:@"AfterAll"]; });
+ beforeEach(^{ [calls removeObject:@"BeforeEach"]; });
+ afterEach(^{ [calls removeObject:@"AfterEach"]; });
+ it(@"TestCase", ^{ [calls removeObject:@"TestCase"]; });
+ context(@"Context", ^{
+ beforeAll(^{ [calls removeObject:@"InnerBeforeAll"]; });
+ afterAll(^{ [calls removeObject:@"InnerAfterAll"]; });
+ beforeEach(^{ [calls removeObject:@"InnerBeforeEach"]; });
+ afterEach(^{ [calls removeObject:@"InnerAfterEach"]; });
+ it(@"InnerTestCase", ^{ [calls removeObject:@"InnerTestCase"]; });
+ context(@"InnerContext", ^{
+ beforeAll(^{ [calls removeObject:@"DoubleInnerBeforeAll"]; });
+ afterAll(^{ [calls removeObject:@"DoubleInnerAfterAll"]; });
+ beforeEach(^{ [calls removeObject:@"DoubleInnerBeforeEach"]; });
+ afterEach(^{ [calls removeObject:@"DoubleInnerAfterEach"]; });
+ it(@"DoubleInnerTestCase", ^{ [calls removeObject:@"DoubleInnerTestCase"]; });
});
});
});
- STAssertEquals(0, calls.count, @"Not all the blocks were called! Leftovers: %@", calls);
-}
+});
+
+describe(@"Check", ^{
+ it(@"All the blocks were called", ^{
+ [[calls should] haveCountOf:0];
+ tests_were_run = YES;
+ });
+});
+
+SPEC_END
+
+#if KW_TESTS_ENABLED
+@interface KWFunctionalTests : SenTestCase
@end
+@implementation KWFunctionalTests
-#endif // #if KW_TESTS_ENABLED
+- (void)testSuiteWasExecuted {
+ STAssertEquals(YES, tests_were_run, @"Test suite hasn't run!");
+}
+
+@end
+#endif // #if KW_TESTS_ENABLED

0 comments on commit a71381d

Please sign in to comment.