2,020 questions
-2
votes
0
answers
67
views
XCTest doesn't return the elements in navigation bar after iOS 26 upgrade
The buttons in the navigation bar are not available in the element tree after iOS 26 upgrade of the test phones. The same IPA version, the same XCode version, but different trees on different phones. ...
-1
votes
1
answer
83
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
91
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
135
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
97
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
128
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
125
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
0
answers
35
views
How to get CPU usage in percentage using XCTCPUMetric (which gives CPU Time in seconds)
I'm trying to calculate CPU usage of my app while launching using measure block with XCTCPUMetric and XCTest framework in iOS.
XCTCPUMetric is giving CPU Time in seconds. I want to calculate CPU usage ...
-1
votes
3
answers
836
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
87
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
72
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
26
views
XCUIElement.typeText() fails for iPhone 13 mini
Application's simplified logic:
struct Gigma30: View {
@State private var clientName = ""
var body: some View {
TextField("Enter", text: $clientName)
....
0
votes
0
answers
55
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
28
views
How do I simulate TouchID match in XCTest?
Below is my test code based on my research:
func test_touchId() throws {
let app = XCUIApplication()
app.launch()
let device = XCUIDevice.shared
let selector = ...
0
votes
0
answers
78
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() ...