2,015 questions
0 votes
2 answers
85 views
XCUITest in simulator clone doesn't send to request to server and seems to cache network responses
I'm doing some UI Tests for my iOS app using the XCTest framework. I have a test that launches my app, taps a button, fills in the login info, and taps Login. The app then sends a request to a server ...
-1 votes
1 answer
109 views
Wait for Task to finish in XCTest without using Task.sleep
I have following case. NotMyProtocol is from external library. It is not suitable to work with Swift Concurrency so I though some way to implement it and I will pass some proxy into it to forward ...
1 vote
1 answer
129 views
How to reliably handle "Allow Paste" system alert in iOS UITests? (Alert sometimes blocks interaction)
I'm trying to stabilize a flaky UI test that deals with the "Allow Paste" system alert in iOS (see screenshot below). Sometimes it works, sometimes the test hangs or fails. I'd appreciate ...
-1 votes
1 answer
163 views
EXC_BREAKPOINT breaking tests in Xcode 16.4
In trying to run tests on my app in Swift, I am encountering a problem. I do not have any breakpoints set, and yet, the execution of the tests is being interrupted on the line containing "throw ...
6 votes
1 answer
106 views
Swift MeasurementFormatter Ignores Custom Locale on CI (GitHub Actions) but Works Locally — Always Uses Period Instead of Comma as Decimal Separator
I've created the following class that's a custom formatter supporting formatting both attributed and standard strings: import Foundation import SwiftUI /// A formatter that converts a distance value (...
0 votes
0 answers
143 views
How to tap on a markdown link within a SwiftUI Text view in a UITest
I am trying to write a UITest for SwiftUI link that I have set up in the following way: var body: some View { privacyPolicyLink } private func privacyPolicyLink(with url: URL) -> Text { ...
1 vote
1 answer
197 views
Get EXC_CRASH (SIGKILL (Code Signature Invalid)) when try to test on simulator
I'm trying to run unit XCTest on the simulator and I'm getting a signature error. At the same time, the tests on your iPhone device are running correctly. I use the Personal Team for the signature. In ...
0 votes
3 answers
1k views
How can I mock network responses and state for UI tests using XCTest?
For my new SwiftUI app I'm looking to add tests. Using Swift Testing I've started to write some unit tests. I'm looking to add UI tests as well. The app relies heavily on network calls to fetch data ...
-1 votes
1 answer
97 views
Why is XCTAssertTrue passing when it should fail
Started on some unit tests today in Xcode and decided to test my test. Turns out they always pass but not sure why. The following should fail: struct MyUnitTest { @Test func example() throws { ...
0 votes
1 answer
89 views
Running XCode tests (macOS app) turn on system dark mode unintentionally
I have a bunch of tests for my macOS app. It is XCTest. Being run the last test turning on whole OS theme to dark, so I need every time to go to the System settings changing it back manually. I did ...
0 votes
0 answers
61 views
Swift static properties are not marked as covered by tests in SonarQube
I have several tests written for a series of static properties within an extension in Swift, but I can't get SonarQube to mark them as covered. I've tried everything, but even with the following code,...
0 votes
0 answers
83 views
Swift Mocking a throwing function
I'm building the unit tests for my project and I encountered a problem about a mock I use for UNUserNotificationCenter. I oversimplified my code as an example: I use a protocol to Mock the add() ...
1 vote
1 answer
326 views
How to test predicate-based expectation with Swift Testing?
Sometimes, I have to write tests that validate that some value changes eventually. It happens, for example, if I need to deal with unstructured concurrency. Here's an example of such kind of tests in ...
3 votes
1 answer
405 views
SwiftData Unit Testing EXC_BREAKPOINT on insert
Hello, I'm trying to unit test a SwiftData Model, but I'm facing a weird situation and couldn't find an answer to the problem. The first solution I'll show you does not work, the second one does. ...
1 vote
0 answers
50 views
Got error when trying to write to a TextField in XCTest
In my code below, the TextField is seen by the framework as a .textView elementType. When I write to it, I get the following error Failed to synthesize event: Neither element nor any descendant has ...