-
Notifications
You must be signed in to change notification settings - Fork 796
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
Use Proper Tests LifeCycle #677
Merged
bguidolim
merged 3 commits into
marmelroy:master
from
michalsrutek:feature/use-tests-lifecycle
Jul 11, 2023
Merged
Use Proper Tests LifeCycle #677
bguidolim
merged 3 commits into
marmelroy:master
from
michalsrutek:feature/use-tests-lifecycle
Jul 11, 2023
Conversation
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
bguidolim
approved these changes
Jul 11, 2023
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.
Thanks for this refactoring :)
cgrindel-self-hosted-renovate bot
added a commit
to cgrindel/rules_swift_package_manager
that referenced
this pull request
Aug 16, 2023
….7" (#515) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [marmelroy/PhoneNumberKit](https://togithub.com/marmelroy/PhoneNumberKit) | patch | `from: "3.6.6"` -> `from: "3.6.7"` | --- ### Release Notes <details> <summary>marmelroy/PhoneNumberKit (marmelroy/PhoneNumberKit)</summary> ### [`v3.6.7`](https://togithub.com/marmelroy/PhoneNumberKit/releases/tag/3.6.7) [Compare Source](https://togithub.com/marmelroy/PhoneNumberKit/compare/3.6.6...3.6.7) #### What's Changed - Use Proper Tests LifeCycle by [@​michalsrutek](https://togithub.com/michalsrutek) in [marmelroy/PhoneNumberKit#677 - Updated metadata to version metadata/8.13.17 by [@​github-actions](https://togithub.com/github-actions) in [marmelroy/PhoneNumberKit#678 - Updated metadata to version metadata/8.13.18 by [@​github-actions](https://togithub.com/github-actions) in [marmelroy/PhoneNumberKit#680 **Full Changelog**: marmelroy/PhoneNumberKit@3.6.6...3.6.7 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4yNC4yIiwidXBkYXRlZEluVmVyIjoiMzYuMjQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
MahranBayed
added a commit
to MahranBayed/PhoneNumberKit
that referenced
this pull request
Aug 28, 2023
…into upgrade * 'master' of https://github.com/marmelroy/PhoneNumberKit: (125 commits) Updated metadata to version metadata/8.13.19 (marmelroy#685) Release 3.6.7 Updated metadata to version metadata/8.13.18 (marmelroy#680) Updated metadata to version metadata/8.13.17 (marmelroy#678) Use Proper Tests LifeCycle (marmelroy#677) Release 3.6.6 Added configuration to keep the search bar always visible for the default country picker (marmelroy#676) Updated metadata to version metadata/8.13.16 (marmelroy#675) Improve PhoneNumberKitParsingTests (marmelroy#674) Remove unnecessary iOS 11 checks (marmelroy#673) Release 3.6.5 Fix marmelroy#670 - Infinite loop on clearButtonRect (marmelroy#671) Release 3.6.4 Add support for optional text field insets applied only if a new initilizer is used (marmelroy#669) Update README.md (marmelroy#666) Updated bug report template Stop using NSObject (fix marmelroy#634) (marmelroy#665) Release 3.6.3 Release 3.6.2 Added tests to PR (marmelroy#664) ... # Conflicts: # PhoneNumberKit/PhoneNumberKit.swift # PhoneNumberKit/Resources/PhoneNumberMetadata.json # PhoneNumberKit/UI/CountryCodePickerViewController.swift # PhoneNumberKit/UI/PhoneNumberTextField.swift
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Use Proper Tests LifeCycle
XCTestCase
works differently from a standard Swift class. It uses Objective-C runtime in the background.That is why there should never be stored properties created directly inside of the class.
The reason being, that with having
the test case lifecycle for
n
tests would look like thisphoneNumberKit-1
phoneNumberKit-2
phoneNumberKit-n
test-1
test-2
test-n
(Note that the⚠️ )
phoneNumberKit
-s never get deinitialized!There are (at least) 2 ways to solve this
phoneNumberKit
at the start of each test (this adds visual noise)phoneNumberKit
as an unwrapped optional and use setUp() to initialize it and tearDown() to clear itI would suggest we go with the second approach.
That way, we would have
phoneNumberKit-1
test-1
phoneNumberKit-1
✅ //deinit
was not called before (at all!)phoneNumberKit-2
✅ // all theinit
-s were run before the teststest-2
phoneNumberKit-2
Source: iOS Unit Testing by Example by Jon Reid or his website (or better yet - you can try it yourself!)