Closed Supereg closed 6 months ago
Attention: 5 lines
in your changes are missing coverage. Please review.
Comparison is base (
d8b6645
) 91.53% compared to head (d8e8643
) 91.20%.
@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?
Does it make sense to add https://github.com/StanfordSpezi/Spezi/issues/64#issuecomment-1881658917 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.
Improve support for Previews and Unit Testing
:recycle: 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.:gear: 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.:books: 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.
:white_check_mark: Testing
Several test cases were added to support this new functionality.
:pencil: Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: