-
Notifications
You must be signed in to change notification settings - Fork 264
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
[unit tests] Add some infrastructure for OneSignalCore
and OneSignalUser
#1371
Conversation
Looks like these methods are no longer used within the SDK, so let's remove them from OneSignalClient: - executeSimultaneousRequests - executeSynchronousRequest - executeDataRequest Update OneSignalClient.h And types: - OSDataRequestSuccessBlock - OSMultipleCompletionBlock - OSMultipleFailureBlock - OSMultipleSuccessBlock - genericTimedOutError
- Make a OneSignalCore class through which the services of this module can be set and accessed - To start, make a protocol for OneSignalClient, IOneSignalClient (name of protocol TBD)
- Change all `OneSignalClient.sharedClient` calls to `OneSignalCore.sharedClient`
* Store in the variable `POLL_INTERVAL_MS` so that it can have a different value for testing vs non-testing
OneSignalCore
and OneSignalUser
* Add mocking framework called `OneSignalCoreMocks` to simplify working with `OneSignalCore` in unit tests - Add helper method `clearUserDefaults()` - Create `MockOneSignalClient` class to replace `OneSignalClient` in unit tests * Add mocking framework called `OneSignalUserMocks` to simplify working with `OneSignalUser` in unit tests - Add some helper methods to reset state between tests, WIP * Add unit testing bundle `OneSignalCoreTests`, meant to test `OneSignalCore` - Add one test `testNotificationJson`, to get started * Add unit testing bundle `OneSignalUserTests`, meant to test `OneSignalUser` - Add one test `testLoginSetsExternalId`, to get started
* Delete old "user model" test files `UserModelObjcTests.m and `UserModelSwiftTests.swift` - These weren't real tests
2e215b4
to
d6102b4
Compare
* We want to use force casts in testing
The CI succeeded at first because it was only testing the tests in UnitTests module (which includes 0 tests). We are trying to make all testing bundles run, so we added UserTests and CoreTests to the UnitTestApp scheme. However, after that change, now the CI is failing. |
2db39b3
to
4f30fe0
Compare
* Missed adding this
4bfcb1e
to
a7c1143
Compare
- ENABLE_TESTABILITY in OneSignalUserTests and OneSignalCoreTests modules updated to match existing UnitTests - UnitTestApp scheme updated to include OneSignalUserTests and OneSignalCoreTests test modules - Now, the CI runs all tests automatically!
78158a4
to
194832e
Compare
The CI now passes, and runs all the testing bundles, UnitTests, OneSignalCoreTests.xctest, and OneSignalUserTests.xctest. |
Description
One Line Summary
Rebuilding our unit tests by adding basic infrastructure to work with the modules
OneSignalCore
andOneSignalUser
.Details
1. (cleanup) Removed some unused things from the
OneSignalClient
2. Make
OneSignalCore
class to set and access module's servicesOneSignalClient
, calledIOneSignalClient
(open to more ios-appropriate name for the protocol)OneSignalClient.sharedClient
but if unit tests set their own client, return that one3. Now, access the client via OneSignalCore
OneSignalClient.sharedClient
calls toOneSignalCore.sharedClient
4. Extract Operation Repo's poll interval into a constant
POLL_INTERVAL_MS
so that it can have a different value for testing vs non-testing5. Add 2 mocking frameworks and 2 testing bundles
OneSignalCoreMocks
to simplify working withOneSignalCore
in unit testsclearUserDefaults()
MockOneSignalClient
class to replaceOneSignalClient
in unit testsOneSignalUserMocks
to simplify working withOneSignalUser
in unit testsOneSignalCoreTests
, meant to testOneSignalCore
testNotificationJson
, to get startedOneSignalUserTests
, meant to testOneSignalUser
testLoginSetsExternalId
, to get started6. (cleanup) Delete old "user model" test files
UserModelObjcTests.m
andUserModelSwiftTests.swift
7. Add separate swiftlint file for test modules to allow force casts
Motivation
Rebuilding unit tests
Scope
Testing
Unit testing
Manual testing
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is