-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalize test mocks #179
Merged
Merged
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6cb7255
Fix typo
aokj4ck 92a19ca
Move MockResponse to protocol, add httpMethod and path fields
aokj4ck b508e71
Change MockServerIntegrationTestCase and MockWebServer to generics co…
aokj4ck e992fa1
Start implementing AutofillMockResponse for integration tests with Au…
aokj4ck 70bd1be
Add SBSMockResponse
aokj4ck 3b246c9
Rename LegacyResponse to GeocodingMockResponse
aokj4ck 59fa6aa
Add MockResponse generic to MockServerUITestCase
aokj4ck 5a59910
Disable OfflineIntegrationTests until later
aokj4ck fdb0d19
Change CI test frameworks step to ci-full-test which adds UI tests
aokj4ck 00b7474
Pare down GeocodingMockResponse, remove mocks that are not geocoding …
aokj4ck 2fe6b25
Add mark declarations to MockResponse file
aokj4ck 906a214
Pare down SBSMockResponse to remove unused mocks
aokj4ck 5f112f6
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into gener…
aokj4ck c83e0a5
Update changelog
aokj4ck 63ff493
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into gener…
aokj4ck 38be4db
Merge branch 'main' of github.com:mapbox/mapbox-search-ios into gener…
aokj4ck 3511414
Update visibility UI tests to use network Mocks
aokj4ck 5aa4242
Restore Package.resolved file
aokj4ck 051ef74
Update docs for CoreSearchEngine.ApiType.toSDKType (tests only)
aokj4ck 71b0fd5
Update for PR feedback: add typealias for MockSBSServerUITestCase, re…
aokj4ck 3629b6f
Merge branch 'main' into generalize-test-mocks
aokj4ck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Tests/MapboxSearchTests/Common/Extensions/CoreApiType+ToSDKType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@testable import MapboxSearch | ||
|
||
extension CoreSearchEngine.ApiType { | ||
/// Available only for tests. | ||
/// This is necessary for tests using subclasses and usages of ``AbstractSearchEngine`` to dynamically instantiate | ||
/// an engine with the appropriate ApiType for their test case mocks. | ||
/// ``AbstractSearchEngine`` and subclasses use a ``MapboxSearch.ApiType`` enum which is a **subset** of the Core | ||
/// ApiType. | ||
/// For all other ApiTypes specialized classes are provided that use the Core ApiType directly (such as | ||
/// AddressAutofill) or support is not yet fully implemented (such as search-box). | ||
/// Tests that attempt to use an Autofill or Search-box API type with a custom SearchEngine (instead of a provided | ||
/// specialized class) should encounter a runtime error. | ||
func toSDKType() -> ApiType? { | ||
switch self { | ||
case .geocoding: | ||
return .geocoding | ||
case .SBS: | ||
return .SBS | ||
case .autofill, | ||
.searchBox: | ||
fallthrough | ||
@unknown default: | ||
fatalError() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
Tests/MapboxSearchUITests/Integration/CategorySuggestionsIntegrationTestCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Tests/MapboxSearchUITests/Integration/CategorySuggestionsNavigationIntegrationTestCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Tests/MapboxSearchUITests/Integration/FavoritesIntegrationTestCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Tests/MapboxSearchUITests/Integration/SearchIntegrationTestCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: looks like we can remove explicit typealias declaration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would cause the Test subclasses to need either:
<Mock: MockResponse>
(more noise, but explicit which is nice) orMock
usages to the default nameT
, such asT.coreApiType.toSDKType()
(more obtuse IMHO)The typealias is inherited and I think it's the simplest approach (although you do have to visit the parent class definition to find the typealias.) Let me know what you think.