@qcoding has shared a helpful new technique, courtesy of _his_ reader, for "bypass[ing] SwiftUI app launch during unit testing".

Who doesn't love a fast-launching unit test?

https://qualitycoding.org/bypass-swiftui-app-launch-unit-testing/

How to Bypass SwiftUI App Launch During Unit Testing

How can we bypass the normal SwiftUI app launch sequence during testing? We've done this for app delegates, so let's also do it for SwiftUI apps.

Quality Coding

@vermontcoder @qcoding Huh!

How does this compare with pushing the stuff you want to unit test into a separate library?

@mattiem @qcoding If a target consists entirely of Views, there is arguably no need to unit test it. But if a SwiftUI target has some unit testable code and therefore unit tests, you don't want to show or incur the cost of showing the target's UI while unit testing.

@vermontcoder @qcoding Yes!

So one way is to suppress the UI, like is presented here. Another option is to separate the UI from the code you want to test via a library so there is no UI to suppress. I *think*.

@mattiem @qcoding Agreed. A well-factored app might use that approach.

@vermontcoder @mattiem Putting things into smaller libraries is great, but I don't ever want it to be a requirement.

Also, I want to test Views.