Skip to content

Commit

Permalink
Convert tests to XCTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Blues committed May 27, 2014
1 parent c44f105 commit f809b08
Show file tree
Hide file tree
Showing 51 changed files with 3,284 additions and 3,276 deletions.
2 changes: 1 addition & 1 deletion .scripts/pod-update-checksum.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6216ba3646e03f4f2a4d8c07d03472b68f9062de
2d254c61cf52318852682057c71b35376e1bdce3
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
//
//

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import <XCTest/XCTest.h>
#import "AssemblyWithDefinitionConfiguration.h"
#import "TyphoonBlockComponentFactory.h"

@interface DefinitionConfigurationTest : SenTestCase
@interface DefinitionConfigurationTest : XCTestCase

@end

Expand All @@ -27,65 +28,65 @@ - (void)setUp

- (void)test_macros_defined_definition
{
STAssertEqualObjects([assembly definitionMatchedTrueValue], @"TRUE", nil);
XCTAssertEqualObjects([assembly definitionMatchedTrueValue], @"TRUE");
}

- (void)test_runtime_defined_definition
{
STAssertEqualObjects([assembly definitionMatchedRuntimeValue:@YES], @"TRUE", nil);
XCTAssertEqualObjects([assembly definitionMatchedRuntimeValue:@YES], @"TRUE");
}

- (void)test_string_defined_definition
{
STAssertEqualObjects([assembly definitionMatchedFalseAsString], @"FALSE", nil);
XCTAssertEqualObjects([assembly definitionMatchedFalseAsString], @"FALSE");
}

- (void)test_number_defined_definition
{
STAssertEqualObjects([assembly definitionMatchedOneAsNumber], @"TRUE", nil);
XCTAssertEqualObjects([assembly definitionMatchedOneAsNumber], @"TRUE");
}

- (void)test_string_number_defined_definition
{
STAssertEqualObjects([assembly definitionMatchedOneAsString], @"TRUE", nil);
XCTAssertEqualObjects([assembly definitionMatchedOneAsString], @"TRUE");
}

- (void)test_definition_defined_by_another_as_option
{
STAssertEqualObjects([assembly definitionMatchedByAnotherDefinitionWithFalse], @"FALSE", nil);
XCTAssertEqualObjects([assembly definitionMatchedByAnotherDefinitionWithFalse], @"FALSE");
}

- (void)test_definition_matched_by_name
{
STAssertEqualObjects([assembly definitionMatchedDefinitionName:@"trueString"], @"TRUE", nil);
STAssertEqualObjects([assembly definitionMatchedDefinitionName:@"falseString"], @"FALSE", nil);
XCTAssertEqualObjects([assembly definitionMatchedDefinitionName:@"trueString"], @"TRUE");
XCTAssertEqualObjects([assembly definitionMatchedDefinitionName:@"falseString"], @"FALSE");
}

- (void)test_definition_with_custom_matcher
{
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherFromOption:@"positive"], @"TRUE", nil);
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherFromOption:@"negative"], @"FALSE", nil);
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherFromOption:@"nothing"], @"ZERO", nil);
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherFromOption:@"positive"], @"TRUE");
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherFromOption:@"negative"], @"FALSE");
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherFromOption:@"nothing"], @"ZERO");
}

- (void)test_definition_cant_match
{
STAssertThrows([assembly definitionMatchedByCustomMatcherFromOption:@"unknown"], nil);
STAssertThrows([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"unknown"], nil);
XCTAssertThrows([assembly definitionMatchedByCustomMatcherFromOption:@"unknown"]);
XCTAssertThrows([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"unknown"]);
}

- (void)test_definition_with_custom_matcher_and_name
{
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"positive"], @"TRUE", nil);
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"negative"], @"FALSE", nil);
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"nothing"], @"ZERO", nil);
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"trueString"], @"TRUE", nil);
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"falseString"], @"FALSE", nil);
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"positive"], @"TRUE");
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"negative"], @"FALSE");
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"nothing"], @"ZERO");
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"trueString"], @"TRUE");
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherOrNameFromOption:@"falseString"], @"FALSE");
}

- (void)test_definition_cant_match_useDefault
{
STAssertEqualObjects([assembly definitionMatchedByCustomMatcherWithDefaultFromOption:@"unknown"], @"ZERO", nil);
XCTAssertEqualObjects([assembly definitionMatchedByCustomMatcherWithDefaultFromOption:@"unknown"], @"ZERO");
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
//
////////////////////////////////////////////////////////////////////////////////

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "Typhoon.h"
#import "Knight.h"
#import "OCLogTemplate.h"

@interface TyphoonPropertyPlaceholderConfigurerTests : SenTestCase
@interface TyphoonPropertyPlaceholderConfigurerTests : XCTestCase
@end

@implementation TyphoonPropertyPlaceholderConfigurerTests
Expand Down Expand Up @@ -84,8 +84,8 @@ - (void)test_json_values
[_configurer postProcessComponentFactory:factory];

Knight *knight = [factory componentForType:[Knight class]];
STAssertEquals(knight.damselsRescued, (NSUInteger)42, nil);
STAssertEquals(knight.hasHorseWillTravel, (BOOL)YES, nil);
XCTAssertEqual(knight.damselsRescued, (NSUInteger)42);
XCTAssertEqual(knight.hasHorseWillTravel, (BOOL)YES);
}

- (void)test_plist_values
Expand All @@ -102,8 +102,8 @@ - (void)test_plist_values
[_configurer postProcessComponentFactory:factory];

Knight *knight = [factory componentForType:[Knight class]];
STAssertEquals(knight.damselsRescued, (NSUInteger)28, nil);
STAssertEquals(knight.hasHorseWillTravel, (BOOL)YES, nil);
XCTAssertEqual(knight.damselsRescued, (NSUInteger)28);
XCTAssertEqual(knight.hasHorseWillTravel, (BOOL)YES);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//
////////////////////////////////////////////////////////////////////////////////

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import <TyphoonViewControllerNibResolver.h>
#import <UIKit/UIKit.h>
#import <TyphoonDefinition.h>
Expand All @@ -18,7 +18,7 @@
#import <TyphoonMethod.h>
#import <TyphoonMethod+InstanceBuilder.h>

@interface TyphoonViewControllerNibResolverTests : SenTestCase
@interface TyphoonViewControllerNibResolverTests : XCTestCase
{
TyphoonViewControllerNibResolver *_nibResolver;
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Configuration/TyphoonBundleResourceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
//
////////////////////////////////////////////////////////////////////////////////

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "TyphoonResource.h"
#import "TyphoonBundleResource.h"

@interface TyphoonBundleResourceTests : SenTestCase
@interface TyphoonBundleResourceTests : XCTestCase
@end

@implementation TyphoonBundleResourceTests
Expand Down Expand Up @@ -44,7 +44,7 @@ - (void)test_raises_exception_for_invalid_resource_name
@try {
id <TyphoonResource> resource = [TyphoonBundleResource withName:@"SomeResourceThatDoesNotExist.txt"];
NSLog(@"Resource: %@", resource);
STFail(@"Should have thrown exception");
XCTFail(@"Should have thrown exception");
}
@catch (NSException *e) {
assertThat([e description], equalTo(@"Resource named 'SomeResourceThatDoesNotExist.txt' not in bundle."));
Expand Down
9 changes: 5 additions & 4 deletions Tests/CoverageFixer.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
////////////////////////////////////////////////////////////////////////////////


#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>

@interface CoverageFixer : SenTestLog
@interface CoverageFixer : XCTestLog
@end

@implementation CoverageFixer


+ (void)testSuiteDidStop:(NSNotification *)aNotification
- (void)testSuiteDidStop:(XCTestRun *)testRun
{
extern void __gcov_flush(void);
__gcov_flush();
[super testSuiteDidStop:aNotification];
[super testSuiteDidStop:testRun];
}


@end

14 changes: 7 additions & 7 deletions Tests/Definition/Initializer/TyphoonInitializerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@


#import <Typhoon/TyphoonMethod.h>
#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "MiddleAgesAssembly.h"
#import "Typhoon.h"
#import "Knight.h"

@interface TyphoonInitializerTests : SenTestCase
@interface TyphoonInitializerTests : XCTestCase
@end


Expand All @@ -38,7 +38,7 @@ - (void)test_single_parameter_method_incorrect_parameter_name_warns
@try {
_initializer = [self newInitializerWithSelector:@selector(initWithString:)];
[_initializer injectParameter:@"strnig" with:@"a string"];
STFail(@"Should've thrown exception");
XCTFail(@"Should've thrown exception");
}
@catch (NSException *e) {
assertThat([e description], equalTo(@"Unrecognized parameter name: 'strnig' for method 'initWithString:'. Did you mean 'string'?"));
Expand All @@ -51,7 +51,7 @@ - (void)test_two_parameter_method_incorrect_parameter_name_warns
@try {
_initializer = [self newInitializerWithSelector:@selector(initWithClass:key:)];
[_initializer injectParameter:@"keyy" with:@"a key"];
STFail(@"Should've thrown exception");
XCTFail(@"Should've thrown exception");
}
@catch (NSException *e) {
assertThat([e description], equalTo(@"Unrecognized parameter name: 'keyy' for method 'initWithClass:key:'. Valid parameter names are 'class' or 'key'."));
Expand All @@ -64,7 +64,7 @@ - (void)test_multiple_parameter_method_incorrect_parameter_name_warns
@try {
_initializer = [self newInitializerWithSelector:@selector(initWithContentsOfURL:options:error:)];
[_initializer injectParameter:@"path" with:@"a parameter that isn't there"];
STFail(@"Should've thrown exception");
XCTFail(@"Should've thrown exception");
}
@catch (NSException *e) {
assertThat([e description], equalTo(@"Unrecognized parameter name: 'path' for method 'initWithContentsOfURL:options:error:'. Valid parameter names are 'contentsOfURL', 'options', or 'error'."));
Expand All @@ -78,7 +78,7 @@ - (void)test_no_parameter_method_parameter_name_specified
@try {
_initializer = [self newInitializerWithSelector:@selector(init)];
[_initializer injectParameter:@"aParameter" with:@"anObject"];
STFail(@"Should've thrown exception");
XCTFail(@"Should've thrown exception");
}
@catch (NSException *e) {
assertThat([e description], equalTo(@"Specified a parameter named 'aParameter', but method 'init' takes no parameters."));
Expand All @@ -89,7 +89,7 @@ - (void)test_no_parameter_method_parameter_name_specified
- (void)test_knight_init_by_class_method
{
Knight *knight = [_factory componentForKey:@"knightClassMethodInit"];
STAssertTrue(knight.damselsRescued == 13, @"");
XCTAssertTrue(knight.damselsRescued == 13, @"");
}

/* ====================================================================================================================================== */
Expand Down
20 changes: 10 additions & 10 deletions Tests/Definition/Initializer/TyphoonMethodInjectionsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
//
//

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "MethodInjectinosAssembly.h"
#import "Typhoon.h"
#import "MiddleAgesAssembly.h"
#import "Knight.h"
#import "Quest.h"

@interface TyphoonMethodInjectionsTests : SenTestCase
@interface TyphoonMethodInjectionsTests : XCTestCase

@end

Expand All @@ -31,8 +31,8 @@ - (void)setUp
- (void)test_method_injection
{
Knight *knight = [factory knightInjectedByMethod];
STAssertNotNil(knight.quest, nil);
STAssertEquals((int)knight.damselsRescued, 3, nil);
XCTAssertNotNil(knight.quest);
XCTAssertEqual((int)knight.damselsRescued, 3);
}

- (void)test_method_circular_injection_with_array
Expand All @@ -43,23 +43,23 @@ - (void)test_method_circular_injection_with_array

Knight *another = damsels[0];

STAssertTrue(knight == another.foobar, @"knight=%@, another=%@",knight, another);
STAssertTrue(damsels.count == 2, nil);
XCTAssertTrue(knight == another.foobar, @"knight=%@, another=%@",knight, another);
XCTAssertTrue(damsels.count == 2);
}

- (void)test_method_three_argument
{
Knight *knight = [factory knightWithMethodRuntimeFoo:@"foo"];
STAssertEqualObjects(knight.foobar, @"foo", nil);
XCTAssertEqualObjects(knight.foobar, @"foo");
}

- (void)test_method_nil_argument
{
Knight *knight = [factory knightWithMethodFoo:nil];

STAssertTrue([knight.friends count] == 2, nil);
STAssertTrue(knight.hasHorseWillTravel, nil);
STAssertTrue(knight.foobar == nil, nil);
XCTAssertTrue([knight.friends count] == 2);
XCTAssertTrue(knight.hasHorseWillTravel);
XCTAssertTrue(knight.foobar == nil);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
//
////////////////////////////////////////////////////////////////////////////////

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "ComponentFactoryAwareObject.h"
#import <TyphoonBlockComponentFactory.h>
#import "ComponentFactoryAwareAssembly.h"

@interface TyphoonComponentFactoryAwareTests : SenTestCase
@interface TyphoonComponentFactoryAwareTests : XCTestCase

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
//
////////////////////////////////////////////////////////////////////////////////

#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
#import "ClassWithCollectionProperties.h"
#import "TyphoonInjectionByCollection.h"

@interface TyphoonPropertyInjectedAsCollectionTests : SenTestCase
@interface TyphoonPropertyInjectedAsCollectionTests : XCTestCase
{
ClassWithCollectionProperties *_classWithCollectionProperties;
}
Expand All @@ -30,16 +30,16 @@ - (void)setUp

- (void)test_collection_class_checking_not_collection
{
STAssertFalse([TyphoonInjectionByCollection isCollectionClass:[NSObject class]], nil);
STAssertFalse([TyphoonInjectionByCollection isCollectionClass:[NSDictionary class]], nil);
XCTAssertFalse([TyphoonInjectionByCollection isCollectionClass:[NSObject class]]);
XCTAssertFalse([TyphoonInjectionByCollection isCollectionClass:[NSDictionary class]]);
}

/* ====================================================================================================================================== */
#pragma mark - Arrays
- (void)test_collection_class_checking_array
{
STAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSArray class]], nil);
STAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSMutableArray class]], nil);
XCTAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSArray class]]);
XCTAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSMutableArray class]]);
}

- (void)test_collection_mutable_class_from_array
Expand All @@ -56,10 +56,10 @@ - (void)test_collection_mutable_class_from_array

- (void)test_collection_class_checking_set
{
STAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSSet class]], nil);
STAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSMutableSet class]], nil);
STAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSOrderedSet class]], nil);
STAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSMutableOrderedSet class]], nil);
XCTAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSSet class]]);
XCTAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSMutableSet class]]);
XCTAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSOrderedSet class]]);
XCTAssertTrue([TyphoonInjectionByCollection isCollectionClass:[NSMutableOrderedSet class]]);
}

- (void)test_collection_mutable_class_from_set
Expand Down
Loading

0 comments on commit f809b08

Please sign in to comment.