Skip to content

Commit

Permalink
Make test handing pedantic.
Browse files Browse the repository at this point in the history
- Always super the setUp/tearDown
- Ensure we cleanup (in tearDown) all fetcher related things created in setUp.
  • Loading branch information
thomasvl committed Dec 6, 2016
1 parent 44106c4 commit f16f9c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/UnitTests/GTMReadMonitorInputStreamTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ @implementation GTMReadMonitorInputStreamTest

- (void)setUp {
_monitoredData = [[NSMutableData alloc] init];

[super setUp];
}

- (void)tearDown {
_monitoredData = nil;

[super tearDown];
}

- (void)testGTMReadMonitorInputStream {
Expand Down
6 changes: 6 additions & 0 deletions Source/UnitTests/GTMSessionFetcherChunkedUploadTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ - (void)setUp {
[super setUp];
}

- (void)tearDown {
_service = nil;

[super tearDown];
}

#pragma mark - Chunked Upload Fetch Tests

- (void)testChunkedUploadTestBlock {
Expand Down
8 changes: 8 additions & 0 deletions Source/UnitTests/GTMSessionFetcherFetchingTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ @implementation GTMSessionFetcherBaseTest
+ (void)setUp {
SubstituteUIApplication *app = [[SubstituteUIApplication alloc] init];
[GTMSessionFetcher setSubstituteUIApplication:app];

[super setUp];
}

+ (void)tearDown {
[GTMSessionFetcher setSubstituteUIApplication:nil];

[super tearDown];
}

#endif // GTM_BACKGROUND_TASK_FETCHING
Expand All @@ -59,6 +63,8 @@ - (void)setUp {
_isServerRunning = (_testServer != nil);
XCTAssertTrue(_isServerRunning,
@">>> http test server failed to launch; skipping fetcher tests\n");

[super setUp];
}

- (void)tearDown {
Expand All @@ -69,6 +75,8 @@ - (void)tearDown {
_fetcherService = nil;

[[GTMSessionFetcher staticCookieStorage] removeAllCookies];

[super tearDown];
}

#pragma mark -
Expand Down
4 changes: 4 additions & 0 deletions Source/UnitTests/GTMSessionFetcherServiceTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ - (void)setUp {

XCTAssertTrue(_isServerRunning,
@">>> http test server failed to launch; skipping service tests\n");

[super setUp];
}

- (void)tearDown {
_testServer = nil;
_isServerRunning = NO;

[super tearDown];
}

- (void)testFetcherService {
Expand Down

0 comments on commit f16f9c4

Please sign in to comment.