-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve support for Previews and Unit Testing #95
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #95 +/- ##
==========================================
- Coverage 91.53% 91.20% -0.33%
==========================================
Files 31 34 +3
Lines 661 693 +32
==========================================
+ Hits 605 632 +27
- Misses 56 61 +5
Continue to review full report in Codecov by Sentry.
|
2ff7277
to
56eaaa8
Compare
@PSchmiedmayer incorporated the ideas from our meeting today. Feel free to review. We are currently failing slightly on diff coverage. Do think it is necessary to cover this case with an UI test still? |
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.
Thank you @Supereg; I looked at the PR and only had a few minor comments 👍
Does it make sense to add #64 (comment) in the same PR as it will share a bit of the functionality with the lifecycle method and could e.g. use the same type in the configuration. |
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.
Thank you for the improvements @Supereg!
Improve support for Previews and Unit Testing
♻️ Current situation & Problem
As outlined in #63, there is a need to more easily configure the Spezi framework within SwiftUI Previews. This currently is not easily possible, as we require an
SpeziAppDelegate
to be configured to support infrastructure like theLifecycleHandler
protocol. This is not available for Previews.This PR adds two new shorthand
previewWith(simulateLifecycle:_:)
andpreviewWith(standard:simulateLifecycle:_:)
modifiers that are targeted for preview usage only. As documented,LifecycleHandler
are not fully supported with this configuration due to the missing App delegate. However, there is an option to partially simulate its behavior.Further, #64 illustrates difficulties to unit test Spezi
Modules
due to missing abilities to resolve Module dependencies without initializing a SwiftUI App. This PR adds first-hand support for this scenario using the methodswithDependencyResolution(simulateLifecycle:_:)
andwithDependencyResolution(standard:simulateLifecycle:_:)
in theXCTSpezi
package.⚙️ Release Notes
previewWith(simulateLifecycle:_:)
andpreviewWith(standard:simulateLifecycle:_:)
modifiers to be used within SwiftUI Previews.withDependencyResolution(simulateLifecycle:_:)
andwithDependencyResolution(standard:simulateLifecycle:_:)
methods to support unit testing Spezi Modules.📚 Documentation
Documentation was added to illustrate that these modifiers should only be used within Previews. Further, they are placed in a dedicated
Previews
section in the DocC landing page.New DocC bundle was added for the XCTSpezi target.
✅ Testing
Several test cases were added to support this new functionality.
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: