Skip to content

Commit a03c8cd

Browse files
committed
Switch from deprecated SenTestingKit to XCTest
1 parent 469bbe6 commit a03c8cd

File tree

4 files changed

+31
-35
lines changed

4 files changed

+31
-35
lines changed

tests/TMCache.xcodeproj/project.pbxproj

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
D07F1EC2171AFB7A001DBA02 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D07F1EC1171AFB7A001DBA02 /* main.m */; };
1414
D07F1EC6171AFB7A001DBA02 /* TMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D07F1EC5171AFB7A001DBA02 /* TMAppDelegate.m */; };
1515
D07F1ECC171AFB7A001DBA02 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = D07F1ECB171AFB7A001DBA02 /* [email protected] */; };
16-
D07F1ED4171AFB7A001DBA02 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D07F1ED3171AFB7A001DBA02 /* SenTestingKit.framework */; };
1716
D07F1ED5171AFB7A001DBA02 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D07F1EB5171AFB7A001DBA02 /* UIKit.framework */; };
1817
D07F1ED6171AFB7A001DBA02 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D07F1EB7171AFB7A001DBA02 /* Foundation.framework */; };
1918
D07F1EE1171AFB7A001DBA02 /* TMCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D07F1EE0171AFB7A001DBA02 /* TMCacheTests.m */; };
@@ -48,7 +47,6 @@
4847
D07F1EC5171AFB7A001DBA02 /* TMAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TMAppDelegate.m; sourceTree = "<group>"; };
4948
D07F1ECB171AFB7A001DBA02 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
5049
D07F1ED2171AFB7A001DBA02 /* TMCacheTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TMCacheTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
51-
D07F1ED3171AFB7A001DBA02 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
5250
D07F1EDB171AFB7A001DBA02 /* TMCacheTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TMCacheTests-Info.plist"; sourceTree = "<group>"; };
5351
D07F1EDF171AFB7A001DBA02 /* TMCacheTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TMCacheTests.h; sourceTree = "<group>"; };
5452
D07F1EE0171AFB7A001DBA02 /* TMCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TMCacheTests.m; sourceTree = "<group>"; };
@@ -77,7 +75,6 @@
7775
isa = PBXFrameworksBuildPhase;
7876
buildActionMask = 2147483647;
7977
files = (
80-
D07F1ED4171AFB7A001DBA02 /* SenTestingKit.framework in Frameworks */,
8178
D07F1ED5171AFB7A001DBA02 /* UIKit.framework in Frameworks */,
8279
D07F1ED6171AFB7A001DBA02 /* Foundation.framework in Frameworks */,
8380
);
@@ -113,7 +110,6 @@
113110
D07F1EB5171AFB7A001DBA02 /* UIKit.framework */,
114111
D07F1EB7171AFB7A001DBA02 /* Foundation.framework */,
115112
D07F1EB9171AFB7A001DBA02 /* CoreGraphics.framework */,
116-
D07F1ED3171AFB7A001DBA02 /* SenTestingKit.framework */,
117113
);
118114
name = Frameworks;
119115
sourceTree = "<group>";
@@ -202,7 +198,7 @@
202198
name = TMCacheTests;
203199
productName = TMCacheTests;
204200
productReference = D07F1ED2171AFB7A001DBA02 /* TMCacheTests.octest */;
205-
productType = "com.apple.product-type.bundle.ocunit-test";
201+
productType = "com.apple.product-type.bundle.unit-test";
206202
};
207203
/* End PBXNativeTarget section */
208204

@@ -396,14 +392,14 @@
396392
FRAMEWORK_SEARCH_PATHS = (
397393
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
398394
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
395+
"$(inherited)",
399396
);
400397
GCC_PRECOMPILE_PREFIX_HEADER = YES;
401398
GCC_PREFIX_HEADER = "TMCache/TMCache-Prefix.pch";
402399
INFOPLIST_FILE = "TMCacheTests/TMCacheTests-Info.plist";
403400
PRODUCT_NAME = "$(TARGET_NAME)";
404401
TEST_HOST = "$(BUNDLE_LOADER)";
405402
VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64";
406-
WRAPPER_EXTENSION = octest;
407403
};
408404
name = Debug;
409405
};
@@ -414,14 +410,14 @@
414410
FRAMEWORK_SEARCH_PATHS = (
415411
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
416412
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
413+
"$(inherited)",
417414
);
418415
GCC_PRECOMPILE_PREFIX_HEADER = YES;
419416
GCC_PREFIX_HEADER = "TMCache/TMCache-Prefix.pch";
420417
INFOPLIST_FILE = "TMCacheTests/TMCacheTests-Info.plist";
421418
PRODUCT_NAME = "$(TARGET_NAME)";
422419
TEST_HOST = "$(BUNDLE_LOADER)";
423420
VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64";
424-
WRAPPER_EXTENSION = octest;
425421
};
426422
name = Release;
427423
};

tests/TMCache.xcodeproj/xcshareddata/xcschemes/TMCacheTests.xcscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<BuildableReference
1616
BuildableIdentifier = "primary"
1717
BlueprintIdentifier = "D07F1ED1171AFB7A001DBA02"
18-
BuildableName = "TMCacheTests.octest"
18+
BuildableName = "TMCacheTests.xctest"
1919
BlueprintName = "TMCacheTests"
2020
ReferencedContainer = "container:TMCache.xcodeproj">
2121
</BuildableReference>
@@ -47,7 +47,7 @@
4747
<BuildableReference
4848
BuildableIdentifier = "primary"
4949
BlueprintIdentifier = "D07F1ED1171AFB7A001DBA02"
50-
BuildableName = "TMCacheTests.octest"
50+
BuildableName = "TMCacheTests.xctest"
5151
BlueprintName = "TMCacheTests"
5252
ReferencedContainer = "container:TMCache.xcodeproj">
5353
</BuildableReference>

tests/TMCacheTests/TMCacheTests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#import <SenTestingKit/SenTestingKit.h>
1+
#import <XCTest/XCTest.h>
22

3-
@interface TMCacheTests : SenTestCase
3+
@interface TMCacheTests : XCTestCase
44

55
@end

tests/TMCacheTests/TMCacheTests.m

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ - (void)setUp
1818

1919
self.cache = [[TMCache alloc] initWithName:TMCacheTestName];
2020

21-
STAssertNotNil(self.cache, @"test cache does not exist");
21+
XCTAssertNotNil(self.cache, @"test cache does not exist");
2222
}
2323

2424
- (void)tearDown
@@ -27,7 +27,7 @@ - (void)tearDown
2727

2828
self.cache = nil;
2929

30-
STAssertNil(self.cache, @"test cache did not deallocate");
30+
XCTAssertNil(self.cache, @"test cache did not deallocate");
3131

3232
[super tearDown];
3333
}
@@ -61,18 +61,18 @@ - (dispatch_time_t)timeout
6161

6262
- (void)testCoreProperties
6363
{
64-
STAssertTrue([self.cache.name isEqualToString:TMCacheTestName], @"wrong name");
65-
STAssertNotNil(self.cache.memoryCache, @"memory cache does not exist");
66-
STAssertNotNil(self.cache.diskCache, @"disk cache doe not exist");
64+
XCTAssertTrue([self.cache.name isEqualToString:TMCacheTestName], @"wrong name");
65+
XCTAssertNotNil(self.cache.memoryCache, @"memory cache does not exist");
66+
XCTAssertNotNil(self.cache.diskCache, @"disk cache doe not exist");
6767
}
6868

6969
- (void)testDiskCacheURL
7070
{
7171
BOOL isDir = NO;
7272
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:[self.cache.diskCache.cacheURL path] isDirectory:&isDir];
7373

74-
STAssertTrue(exists, @"disk cache directory does not exist");
75-
STAssertTrue(isDir, @"disk cache url is not a directory");
74+
XCTAssertTrue(exists, @"disk cache directory does not exist");
75+
XCTAssertTrue(isDir, @"disk cache url is not a directory");
7676
}
7777

7878
- (void)testObjectSet
@@ -88,7 +88,7 @@ - (void)testObjectSet
8888

8989
dispatch_semaphore_wait(semaphore, [self timeout]);
9090

91-
STAssertNotNil(image, @"object was not set");
91+
XCTAssertNotNil(image, @"object was not set");
9292
}
9393

9494
- (void)testObjectGet
@@ -106,7 +106,7 @@ - (void)testObjectGet
106106

107107
dispatch_semaphore_wait(semaphore, [self timeout]);
108108

109-
STAssertNotNil(image, @"object was not got");
109+
XCTAssertNotNil(image, @"object was not got");
110110
}
111111

112112
- (void)testObjectRemove
@@ -124,7 +124,7 @@ - (void)testObjectRemove
124124

125125
id object = [self.cache objectForKey:key];
126126

127-
STAssertNil(object, @"object was not removed");
127+
XCTAssertNil(object, @"object was not removed");
128128
}
129129

130130
- (void)testMemoryCost
@@ -135,16 +135,16 @@ - (void)testMemoryCost
135135
[self.cache.memoryCache setObject:key1 forKey:key1 withCost:1];
136136
[self.cache.memoryCache setObject:key2 forKey:key2 withCost:2];
137137

138-
STAssertTrue(self.cache.memoryCache.totalCost == 3, @"memory cache total cost was incorrect");
138+
XCTAssertTrue(self.cache.memoryCache.totalCost == 3, @"memory cache total cost was incorrect");
139139

140140
[self.cache.memoryCache trimToCost:1];
141141

142142
id object1 = [self.cache.memoryCache objectForKey:key1];
143143
id object2 = [self.cache.memoryCache objectForKey:key2];
144144

145-
STAssertNotNil(object1, @"object did not survive memory cache trim to cost");
146-
STAssertNil(object2, @"object was not trimmed despite exceeding cost");
147-
STAssertTrue(self.cache.memoryCache.totalCost == 1, @"cache had an unexpected total cost");
145+
XCTAssertNotNil(object1, @"object did not survive memory cache trim to cost");
146+
XCTAssertNil(object2, @"object was not trimmed despite exceeding cost");
147+
XCTAssertTrue(self.cache.memoryCache.totalCost == 1, @"cache had an unexpected total cost");
148148
}
149149

150150
- (void)testMemoryCostByDate
@@ -160,16 +160,16 @@ - (void)testMemoryCostByDate
160160
id object1 = [self.cache.memoryCache objectForKey:key1];
161161
id object2 = [self.cache.memoryCache objectForKey:key2];
162162

163-
STAssertNil(object1, @"object was not trimmed despite exceeding cost");
164-
STAssertNil(object2, @"object was not trimmed despite exceeding cost");
165-
STAssertTrue(self.cache.memoryCache.totalCost == 0, @"cache had an unexpected total cost");
163+
XCTAssertNil(object1, @"object was not trimmed despite exceeding cost");
164+
XCTAssertNil(object2, @"object was not trimmed despite exceeding cost");
165+
XCTAssertTrue(self.cache.memoryCache.totalCost == 0, @"cache had an unexpected total cost");
166166
}
167167

168168
- (void)testDiskByteCount
169169
{
170170
[self.cache setObject:[self image] forKey:@"image"];
171171

172-
STAssertTrue(self.cache.diskByteCount > 0, @"disk cache byte count was not greater than zero");
172+
XCTAssertTrue(self.cache.diskByteCount > 0, @"disk cache byte count was not greater than zero");
173173
}
174174

175175
- (void)testOneThousandAndOneWrites
@@ -202,7 +202,7 @@ - (void)testOneThousandAndOneWrites
202202

203203
dispatch_group_wait(group, [self timeout]);
204204

205-
STAssertTrue(count == 0, @"one or more object blocks failed to execute, possible queue deadlock");
205+
XCTAssertTrue(count == 0, @"one or more object blocks failed to execute, possible queue deadlock");
206206
}
207207

208208
- (void)testMemoryWarningBlock
@@ -221,7 +221,7 @@ - (void)testMemoryWarningBlock
221221

222222
dispatch_semaphore_wait(semaphore, [self timeout]);
223223

224-
STAssertTrue(blockDidExecute, @"memory warning block did not execute");
224+
XCTAssertTrue(blockDidExecute, @"memory warning block did not execute");
225225
}
226226

227227
- (void)testBackgroundBlock
@@ -240,7 +240,7 @@ - (void)testBackgroundBlock
240240

241241
dispatch_semaphore_wait(semaphore, [self timeout]);
242242

243-
STAssertTrue(blockDidExecute, @"app background block did not execute");
243+
XCTAssertTrue(blockDidExecute, @"app background block did not execute");
244244
}
245245

246246
- (void)testMemoryWarningProperty
@@ -263,7 +263,7 @@ - (void)testMemoryWarningProperty
263263

264264
dispatch_semaphore_wait(semaphore, [self timeout]);
265265

266-
STAssertNotNil(object, @"object was removed from the cache");
266+
XCTAssertNotNil(object, @"object was removed from the cache");
267267
}
268268

269269
- (void)testMemoryCacheEnumerationWithWarning
@@ -295,7 +295,7 @@ - (void)testMemoryCacheEnumerationWithWarning
295295

296296
dispatch_semaphore_wait(semaphore, [self timeout]);
297297

298-
STAssertTrue(objectCount == enumCount, @"some objects were not enumerated");
298+
XCTAssertTrue(objectCount == enumCount, @"some objects were not enumerated");
299299
}
300300

301301
- (void)testDiskCacheEnumeration
@@ -323,7 +323,7 @@ - (void)testDiskCacheEnumeration
323323

324324
dispatch_semaphore_wait(semaphore, [self timeout]);
325325

326-
STAssertTrue(objectCount == enumCount, @"some objects were not enumerated");
326+
XCTAssertTrue(objectCount == enumCount, @"some objects were not enumerated");
327327
}
328328

329329
@end

0 commit comments

Comments
 (0)