I am new to SwiftUI and XCode and trying to learn it via a TDD book. So far all the tests are non-UI tests; they're just logic unit tests. Is there any way to disable the simulator when running non-UI unit tests? It's going to run slightly faster without simulator I guess and it's slightly annoying to run an unit test with the simulator popping up every time. I tried to edit my test scheme which only includes the unit tests not the UI tests; still it pops up the simulator every time. I am using XCode 12.5.1.
Disable simulator in SwiftUI unit test
557 Views Asked by dragonfly02 At
2
There are 2 best solutions below
0
Patrick
On
This doesn't achieve your goal of "Disable simulator" however if your intention is to not execute any code beyond App then it achieves it.
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
let isUnitTest = ProcessInfo.processInfo.environment["XCTestBundlePath"] != nil
if isUnitTest {
Text("Unit Test")
} else {
ContentView()
}
}
}
}
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in UNIT-TESTING
- Google Truth.assertThat.contains does not behave similar to List.contains
- What's the best way to breakup a large test in pytest
- How to refer to the filepath of test data in test sourcecode?
- How to mock a dynamic endpoint in Apache Camel Spring Boot
- pytest mock failing when mocking function from imported package
- Jest configuration error while running test case in teamcity
- Resolve paths dynamically based on directory where test (or tested files) is located in Jest
- One-time implementation with Jest's mockResolvedValueOnce within test remains from one test to another
- Why can't I mock the decorator of the function?
- Gitlab pipeline stuck with nx cloud issue
- How to create an improperly closed gzip file using python?
- Nest.js service structure for API integration
- uiState not updating in Tests
- Unit Tests not Compiling or Being found without mod tests in main.rs. Is this a requirement or am I missing some configuration?
- Mocking Stream or Reader in Java Junit
Related Questions in SWIFTUI
- Navigate after logged in with webservice
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- ScrollView with multiple LazyVGrids jumping around when using .scrollPosition
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Hide LiveActivityIntent Button from Shortcuts App
- Accessibility : Full keyboard access with scroll view in swiftui
- Custom layout occupies all horizontal space
- Detect Tab View drag gesture
- Lazy loading of dependent relationship in SwiftData
- How do a create a reusable simple custom list style with my own color and spacing
- Why/how does a SwiftUI view's identity depend on the value of its `@StateObject` member variable?
- Sheet binded item doesn't deinitialize SwiftUI
- Realm Swift - collection changes listener in SwiftUI
Related Questions in XCODE12.5
- Navigation Bar doesn't alway vertically center buttons and title text in the bar?
- Error Updating Facebook SDK for iOS: Module map file 'FBSDKCoreKit.modulemap' not found
- Disable simulator in SwiftUI unit test
- xcode Firebase Crashlytics Command PhaseScriptExecution failed with a nonzero exit code
- react-native ios app in release mode build is not working ,xcode-12.5.1
- NavigationBar color changes not carried through to other views with UINavigationBarAppearance()
- Creating an ios 15 device in xcode 12
- 0 i would like to delete a blank space when I embebbeded a TableViewCell in my ViewController
- Xcode 13 - The project at '/Users/test.xcodeproj' cannot be opened because it is in a future Xcode project file format
- Xcode doesn’t support iOS 15.0
- Xcode 12.5.1 (or git) keeps deleting Package.resolved from our repo
- Using Threads in Swift causes memory leak
- How do I delete VALID_ARCHS?
- Target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting warning in Xcode 12.5 and Swift 5
- CALayer message while playing video (Xcode 12.5.1, Swift 5)
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The way I do that is to put all my business logic code and its unit tests into a framework. Xcode tests a framework without loading the app target, so the Simulator is not involved.