Create and run unit tests, performance tests, and UI tests for your Xcode project using XCTest.

XCTest Documentation

Posts under XCTest tag

182 Posts
Sort by:
Post not yet marked as solved
4 Replies
300 Views
When I generate an xctestrun file using Xcode 14 with: xcodebuild build-for-testing -project UITestTesting.xcodeproj -scheme UITestTesting -destination 'id=00008020-000545362EE1002E' -derivedDataPath ./build I'm able to see the xctestrun file at "/Users/noahmartin/Desktop/UITestTesting/Build/Build/Products/UITestTesting_iphoneos16.0-arm64.xctestrun" However, I can't use it to run tests on my iOS 16 iPad. I'm trying to invoke the test like this: xcodebuild test-without-building -xctestrun "/Users/noahmartin/Desktop/UITestTesting/Build/Build/Products/UITestTesting_iphoneos16.0-arm64.xctestrun " -destination 'id=00008020-000545362EE1002E' -derivedDataPath ./build And getting this error: xcodebuild: error: Unable to find a destination matching the provided destination specifier: { id:00008020-000545362EE1002E } Available destinations for the "Transient Testing" scheme: { platform:macOS, arch:arm64e, id:00006001-0012198A0102801E } { platform:macOS, arch:arm64, id:00006001-0012198A0102801E } { platform:macOS, arch:x86_64, id:00006001-0012198A0102801E } { platform:macOS, arch:arm64e, variant:Mac Catalyst, id:00006001-0012198A0102801E } { platform:macOS, arch:arm64, variant:Mac Catalyst, id:00006001-0012198A0102801E } { platform:macOS, arch:x86_64, variant:Mac Catalyst, id:00006001-0012198A0102801E } { platform:macOS, arch:arm64e, variant:DriverKit, id:00006001-0012198A0102801E } { platform:macOS, arch:arm64, variant:DriverKit, id:00006001-0012198A0102801E } { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00006001-0012198A0102801E } { platform:iOS Simulator, id:3113F5B7-7358-4ADE-9660-667872D113A7, OS:16.0, name:iPad (9th generation) } { platform:iOS Simulator, id:D7232872-AC19-4DF1-BF18-D23C2C2A5BFE, OS:16.0, name:iPad Air (5th generation) } { platform:iOS Simulator, id:EE6444F9-2664-4907-9481-08CE44D028E9, OS:16.0, name:iPad Pro (9.7-inch) } { platform:iOS Simulator, id:10063708-10B3-4510-A41F-E948B2D09DB3, OS:16.0, name:iPad Pro (11-inch) (3rd generation) } { platform:iOS Simulator, id:794714E1-25E0-474A-BA79-F5E0EFA3E646, OS:16.0, name:iPad Pro (12.9-inch) (5th generation) } { platform:iOS Simulator, id:809FAD25-CFE5-44CA-B642-0FF2A0E638E5, OS:16.0, name:iPad mini (6th generation) } { platform:iOS Simulator, id:055D580A-859B-42F8-B306-BD8CB68BF1CC, OS:16.0, name:iPhone 8 } { platform:iOS Simulator, id:228440FE-9536-401D-9221-E909761468FE, OS:16.0, name:iPhone 8 Plus } { platform:iOS Simulator, id:D2F30B3E-32F9-44B2-9B02-20A1B6FEDFC3, OS:16.0, name:iPhone 11 } { platform:iOS Simulator, id:1677A963-4BBC-4DE3-896B-2D93FBF10A1B, OS:16.0, name:iPhone 11 Pro } { platform:iOS Simulator, id:67F569A4-B422-406F-961A-C9093F4EA861, OS:16.0, name:iPhone 11 Pro Max } { platform:iOS Simulator, id:927F62C4-CB4E-487A-B021-0A986B9B700A, OS:16.0, name:iPhone 12 } { platform:iOS Simulator, id:AAAE026B-A40E-4D84-9447-91B2034B6FDA, OS:16.0, name:iPhone 12 Pro } { platform:iOS Simulator, id:96E6D2AB-140B-496F-8C31-71A12412AB0C, OS:16.0, name:iPhone 12 Pro Max } { platform:iOS Simulator, id:B68ACAB0-A87A-4384-B9F8-63ECF09D9564, OS:16.0, name:iPhone 12 mini } { platform:iOS Simulator, id:E6FFBA89-6B9E-4A76-A99E-0510E1EFE97B, OS:16.0, name:iPhone 13 } { platform:iOS Simulator, id:0ECA5023-8C7B-4CFA-B264-E0539509E61A, OS:16.0, name:iPhone 13 Pro } { platform:iOS Simulator, id:203AC07C-503F-476E-9F14-DA7FA4D63131, OS:16.0, name:iPhone 13 Pro Max } { platform:iOS Simulator, id:16AA1AE3-1D75-4358-A4FB-8A73141A0551, OS:16.0, name:iPhone 13 mini } { platform:iOS Simulator, id:FAC28F61-2CF8-40C1-AB2D-64CE6F11B96B, OS:16.0, name:iPhone SE (3rd generation) } Ineligible destinations for the "Transient Testing" scheme: { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device } { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device } { platform:macOS, name:Any Mac } { platform:macOS, variant:Mac Catalyst, name:Any Mac } { platform:tvOS, id:dvtdevice-DVTiOSDevicePlaceholder-appletvos:placeholder, name:Any tvOS Device } { platform:tvOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-appletvsimulator:placeholder, name:Any tvOS Simulator Device } { platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device } { platform:watchOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-watchsimulator:placeholder, name:Any watchOS Simulator Device } I am able to launch the test directly from xcode, or with the "project" and "scheme" flags and xcodebuild test but I can't get the xctestrun file to work with iOS 16. This method works fine for iOS 15/Xcode 13. Is there anything I'm missing to make this work with the new betas? Also filed as FB10129497
Posted Last updated
.
Post not yet marked as solved
2 Replies
2.1k Views
When executing the test suites I have, I see many times where the “wait for app to idle” stalls and will time out with the message “App animations complete notification not received, will attempt to continue.”The code I used to make the test suites have zero customized code and most of it was generated via the recorder. Example below: t = 23.41s Find the "btn login" Button t = 23.41s Snapshot accessibility hierarchy for com.testapp.mobilecordova t = 24.44s Find: Descendants matching type NavigationBar t = 24.44s Find: Elements matching predicate '"LOG IN" IN identifiers' t = 24.44s Find: Descendants matching type Button t = 24.44s Find: Elements matching predicate '"btn login" IN identifiers' t = 24.45s Wait for app to idle t = 24.95s Synthesize event t = 25.22s Wait for app to idle t = 147.39s App animations complete notification not received, will attempt to continue. t = 147.39s Snapshot accessibility hierarchy for com.testapp.mobilecordova t = 148.10s Find: Descendants matching type StaticText t = 148.10s Find: Elements matching predicate '"PLEASE TURN ON NOTIFICATIONS" IN identifiers' t = 148.10s Use cached accessibility hierarchy for com.testapp.mobilecordova t = 148.10s Find: Descendants matching type CollectionView t = 148.11s Find: Descendants matching type StaticText t = 148.11s Find: Elements matching predicate '"3D Rooms Now Available!" IN identifiers' t = 148.11s Use cached accessibility hierarchy for com.testapp.mobilecordova t = 148.11s Find: Descendants matching type StaticText t = 148.12s Find: Elements matching predicate '"DAILY" IN identifiers' t = 148.17s Check predicate `exists == 1` against object `"HOME" StaticText` t = 148.17s Snapshot accessibility hierarchy for com.testapp.mobilecordova t = 148.62s Find: Descendants matching type NavigationBar t = 148.62s Find: Elements matching predicate '"HOME" IN identifiers' t = 148.62s Find: Descendants matching type StaticText t = 148.62s Find: Elements matching predicate '"HOME" IN identifiers' t = 148.62s Use cached accessibility hierarchy for com.testapp.mobilecordova t = 148.63s Find: Descendants matching type NavigationBar t = 148.63s Find: Elements matching predicate '"HOME" IN identifiers' t = 148.63s Find: Descendants matching type StaticText t = 148.63s Find: Elements matching predicate '"HOME" IN identifiers' t = 148.63s Use cached accessibility hierarchy for com.testapp.mobilecordova t = 148.64s Find: Descendants matching type Button t = 148.64s Find: Elements matching predicate '"My Friends" IN identifiers' t = 148.64s Tap "compose" Button t = 148.64s Wait for app to idle t = 269.48s App animations complete notification not received, will attempt to continue. t = 269.48s Find the "compose" Button t = 269.48s Snapshot accessibility hierarchy for com.testapp.mobilecordova t = 269.96s Find: Descendants matching type CollectionView t = 269.96s Find: Descendants matching type Button t = 269.97s Find: Elements matching predicate '"compose" IN identifiers' t = 269.97s Wait for app to idle t = 391.80s App animations complete notification not received, will attempt to continue. t = 391.80s Synthesize event t = 392.12s Wait for app to idleI have been searching for a way to modify this or add code to make it pass but have not been successful. I tried disabling the animations and found that the tests no longer wait and tests fail 100% of the time.
Posted
by RufusV3.
Last updated
.
Post not yet marked as solved
0 Replies
37 Views
Hi everybody, given the following case using SwiftUI: Button("testButton", action: noop) .accessibilityRepresentation{representation: { Slider(value: $sliderData.sliderValue) }) .accessibilityIdentifier("testSlider") I'm trying to control the slider using XCUITest via slider.adjust(toNormalizedSliderPosition: 0.2) and receive the following error message: Failed: Unable to get expected attributes for slider, found { "XC_kAXXCAttributeMaxScrubberPosition" = { X = 0; Y = 0; }; "XC_kAXXCAttributeMinScrubberPosition" = { X = 0; Y = 0; }; Similarly, print (slider.normalizedSliderPosition) leads to the error message "Failed to determine current position of slider "0 %". Is there a way to set and read the value of accessibilityRepresentation-Sliders with XCUITest? Thanks!
Posted
by sasro.
Last updated
.
Post not yet marked as solved
1 Replies
364 Views
Hello, I'm attempting to automate some performance tests we currently do manually using signposts and Instruments. It looks like XCTOSSignpostMetric is the perfect tool for the job, but I can't get it to play nicely. If I use the pre-defined signpost metric constants (customNavigationTransitionMetric, scrollDecelerationMetric, etc), it works fine. If I use a custom signpost using the XCTOSSignpostMetric.init(subsystem: category: name:) initializer, nothing happens. The documentation is very sparse on this topic and Googling, Binging, Githubing and Twittering have come up empty. I reduced the issue to the smallest example I could ( https://github.com/tspike/SignpostTest ). What am I doing wrong? Thanks, Tres Environment details: macOS 11.6 Xcode 12.5.1 iOS 14.6 iPhone SE 1st Gen In the app: ... let signpostLog = OSLog(subsystem: "com.tspike.signpost", category: "signpost") let signpostName: StaticString = "SignpostTest" @main struct SignpostTestApp: App { init() { os_signpost(.begin, log: signpostLog, name: signpostName) DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500), execute: { os_signpost(.end, log: signpostLog, name: signpostName) }) } ... } In the test    func testSignposts() throws {     let app = XCUIApplication() // No performance data let metric = XCTOSSignpostMetric.init(subsystem: "com.tspike.signpost",  category: "signpost",  name: "SignpostTest") // Works as expected // let metric = XCTOSSignpostMetric.applicationLaunch let options = XCTMeasureOptions() options.iterationCount = 1 measure(metrics: [metric], options: options, block: { app.launch() }) }
Posted
by tresebay.
Last updated
.
Post not yet marked as solved
1 Replies
113 Views
I have a DataManager class as follows: enum DataManagerType { case normal, preview, testing } class DataManager: NSObject, ObservableObject { static let shared = DataManager(type: .normal) static let preview = DataManager(type: .preview) static let testing = DataManager(type: .testing) @Published var todos = [Todo]() fileprivate var managedObjectContext: NSManagedObjectContext private let todosFRC: NSFetchedResultsController<TodoMO> private init(type: DataManagerType) { switch type { case .normal: let persistentStore = PersistentStore() self.managedObjectContext = persistentStore.context case .preview: let persistentStore = PersistentStore(inMemory: true) self.managedObjectContext = persistentStore.context for i in 0..<10 { let newTodo = TodoMO(context: managedObjectContext) newTodo.title = "Todo \(i)" newTodo.isComplete = false newTodo.date = Date() newTodo.id = UUID() } try? self.managedObjectContext.save() case .testing: let persistentStore = PersistentStore(inMemory: true) self.managedObjectContext = persistentStore.context } let todoFR: NSFetchRequest<TodoMO> = TodoMO.fetchRequest() todoFR.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)] todosFRC = NSFetchedResultsController(fetchRequest: todoFR, managedObjectContext: managedObjectContext, sectionNameKeyPath: nil, cacheName: nil) super.init() // Initial fetch to populate todos array todosFRC.delegate = self try? todosFRC.performFetch() if let newTodos = todosFRC.fetchedObjects { self.todos = newTodos.map({todo(from: $0)}) } } func saveData() { if managedObjectContext.hasChanges { do { try managedObjectContext.save() } catch let error as NSError { NSLog("Unresolved error saving context: \(error), \(error.userInfo)") } } } private func fetchFirst<T: NSManagedObject>(_ objectType: T.Type, predicate: NSPredicate?) -> Result<T?, Error> { let request = objectType.fetchRequest() request.predicate = predicate request.fetchLimit = 1 do { let result = try managedObjectContext.fetch(request) as? [T] return .success(result?.first) } catch { return .failure(error) } } } My persistence store is as such: struct PersistentStore { let container: NSPersistentContainer init(inMemory: Bool = false) { container = NSPersistentContainer(name: "CoreDataModel") if inMemory { container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null") } container.viewContext.automaticallyMergesChangesFromParent = true container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) } var context: NSManagedObjectContext { container.viewContext } func saveContext () { if context.hasChanges { do { try context.save() } catch let error as NSError { NSLog("Unresolved error saving context: \(error), \(error.userInfo)") } } } } I get an error when calling: let predicate = NSPredicate(format: "id = %@", todo.id as CVarArg) //todo.id is just some UUID() //irrelevant here let result = fetchFirst(TodoMO.self, predicate: predicate) This is the error: 2022-07-09 21:36:17.425709-0400 CoreDataExample[73965:7495035] [error] error: No NSEntityDescriptions in any model claim the NSManagedObject subclass 'CoreDataExampleTests.TodoMO' so +entity is confused. Have you loaded your NSManagedObjectModel yet ? CoreData: error: No NSEntityDescriptions in any model claim the NSManagedObject subclass 'CoreDataExampleTests.TodoMO' so +entity is confused. Have you loaded your NSManagedObjectModel yet ? 2022-07-09 21:36:17.425780-0400 CoreDataExample[73965:7495035] [error] error: +[CoreDataExampleTests.TodoMO entity] Failed to find a unique match for an NSEntityDescription to a managed object subclass CoreData: error: +[CoreDataExampleTests.TodoMO entity] Failed to find a unique match for an NSEntityDescription to a managed object subclass /Users/santiagogarciasantos/Documents/Xcode Projects/CoreDataExample/CoreDataExample/DataManager/DataManager.swift:87: error: -[CoreDataExampleTests.CoreDataExampleTests test_Add_Todo] : executeFetchRequest:error: A fetch request must have an entity. (NSInvalidArgumentException) I've checked the target, made sure my Entity is in "Current Product Module" but it still won't work. Important: This only occurs when I'm testing (using my DataManager.testing)
Posted Last updated
.
Post not yet marked as solved
0 Replies
60 Views
I've got a UIAutomation test that tests an app with a Share Extension. I want to pass in some launchArguments and launchEnvironment properties to the Share Extension in my test. I can't figure out a way of doing it. When debug the ProcessInfo in the extension my values aren't there. I've tried setting them like this: XCUIApplication(bundleIdentifier:"com.my.app").launchArguments = ["TEST"] XCUIApplication(bundleIdentifier:"com.my.app").launchEnvironment = ["TEST":"TEST"] and this: XCUIApplication().launchArguments = ["TEST"] XCUIApplication().launchEnvironment = ["TEST":"TEST"] Note, I am correctly getting the correct process when I'm finding it with the bundle identifier.
Posted Last updated
.
Post not yet marked as solved
0 Replies
89 Views
For the Core Data stack in my project's test target, I have the NSPersistentStoreDescription's url set to "/dev/null" as recommended by Apple at WWDC18. I previously was using an in-memory persistent store. I have found that tests that test fetches where the fetch request is set to have the result type as NSFetchRequestResultType.dictionaryResultType will always fail. However, when running the project, the very same code will work as expected. Is there really no way to test these fetches? I have found nothing from search engines. I understand that a persistent store is required for this result type but is "/dev/null" not supposed to give us the same behaviour?
Posted Last updated
.
Post not yet marked as solved
1 Replies
380 Views
In our application, we are having custom logging. When the project is compiled locally on the XCode, I can see that those logs are appearing properly on Xcode Console (Debug Area). Also, when compiling the UITest scheme, the application logs are appearing as expected. But when I run a uitest, then only test runner logs are showing up in debug area. When I select My application target then it's not having application logs.Is this something expected? Is there any setting that I have to turn ON with in Xcode?Any help will be really appreciated.Thanks
Posted
by mmittal79.
Last updated
.
Post not yet marked as solved
1 Replies
760 Views
When running a UI test the other day, an assertion failure terminated the test early when an expected button did not come onto screen. In looking at the screenshots, it appears the hosting app died during the test, leaving the UI test runner staring at the Springboard, rather than the main app, during accessibility element evaluation.In looking through the log files (Xcode Server &gt; xcbot_name &gt; Logs &gt; Download Logs...) I see logs about the test runner and its attempts to find an on-screen button. But I see nothing about the main hosting app itself and why it crashed.Are these crash logs kept only in the Simulator?(I really hope not, as the nature of our project requires constant Simulator resets to avoid app cache conflicts between branch integrations)
Posted Last updated
.
Post not yet marked as solved
3 Replies
10k Views
Hi,I'm using Xcode 9.2 and iOS 11.2 Simulator.I would like to see my application's logs (NSLog call) while the app is tested with XCTest UI tests.I can launch the test with:xcodebuild -project MyProject.xcodeproj -scheme MyScheme -destination "platform=iOS Simulator,name=iPhone 5s,OS=11.2" testThe output of this command is the ouput of the UI test, but I don't see the application NSLog logs.Test Case '-[TestsUIOrangeEtMoi.OEMHomeTest testTapOnFactureTile]' started. t = 0.00s Start Test at 2017-12-07 11:26:05.743 t = 0.04s Set Up t = 0.15s Open com.orange.fr.orangeetmoisettings.bdx2 t = 0.18s Launch com.orange.fr.orangeetmoisettings.bdx2 t = 4.30s Wait for com.orange.fr.orangeetmoisettings.bdx2 to idle t = 6.49s Tap "Adresse mail ou numéro de mobile" TextField t = 6.49s Wait for com.orange.fr.orangeetmoisettings.bdx2 to idleIn the Simulator, I can go to 'Debug &gt; Open System Log...", and it will open a log file ~/Library/Logs/CoreSimulator/DA22333D-A6BF-41EC-8BA4-F21C0EE6E177/system.log where DA22333D-A6BF-41EC-8BA4-F21C0EE6E177 is a hash of the simulator id. If I tail -f this file, I don't see any application logs, just "core" logs.Any idea how to access the application logs in this case ?Regards, Jc
Posted
by jicea78.
Last updated
.
Post not yet marked as solved
1 Replies
139 Views
Hello, I am automating a test scenario, as part of it I have to make a Raspberry Host connection which is on local area network. I can make successful connection to the host from UnitTest target. But the connection is failing when I make the same connection from Unit Test target. I am using XCUITest to automate the app. I am blocked here. I did refer some posts but didn't find any solution. Kindly help. Thanks, Sudheer
Posted Last updated
.
Post not yet marked as solved
0 Replies
107 Views
Getting error in XCUIApplication.launch() after deleting app between tests using Springboard. I created about 20 UI tests in a few different files. Every time a test ends I delete the app from the device using Springboard in the tear down func. When I execute one test at the time everything works fine and without any problems. But when I execute the whole testplan or all tests from one file I always get an error after the first time as soon as I try to launch the second test.  This is the error I receive every time: Failed to create directory on device 'iPhone' (device identifier) to hold runtime profiles for application with bundle ID ‚bundle ID': No matching application with bundle identifier ‚bundle ID' Domain: IDEFoundationErrorDomain Code: 17 User Info: {     DVTErrorCreationDateKey = "2022-06-30 11:42:41 +0000";     IDERunOperationFailingWorker = IDELaunchiPhoneLauncher; } My Springboard class looks like this  Setup looks like this  Tear down looks like this  The error always occurs in the setUpWithError func on line app.launch(). Does anyone know how to solve this problem?  Thanks in advance for any help or answers. best regards Stefan
Posted
by _stefan_.
Last updated
.
Post not yet marked as solved
0 Replies
97 Views
I have an app that relies on Core Data for persistence. The app is using MVVM architecture in order to facilitate testing The dev environment is a MacBook Pro (M1 Max) running MacOS 12.4 and Xcode 14 beta 2 So far everything has been working well until I attempted to add a new entity to my Model that had a relationship (many-to-one) to another entity. Attempting to instantiate one of these entities resulted in a NSUnknownKeyException associated with the property that defined the relationship so I deleted this relationship from the model and re-ran the test. Much to my surprise, the error persisted and I have been singularly unable to resolve it since despite the following: Delete derived data, reboot XCode Rename offending entity (error persists, just with the different entity name) Delete entity and add back into the Model Turn off code-gen and defined the MO subclass manually Check Core Data XML - this looks unremarkable and there are no residual properties that could be causing the problem The one thing I haven't tried yet is to run the code through Xcode 13 (it's a new machine so I was all enthusiastic and went straight for the beta which might have been a mistake!) so will be doing that shortly. For now it seems that something relating to the Core Data model and relationships between entities is hiding out somewhere I can't find it but it could be a bug in the tooling. The problem of course is that I can't continue to develop the app with a compiler error I can't clear. Any thoughts or guidance would be very welcome... Xcode Model interface for relevant entities and XML: Extension on the offending ManagedObject subclass (convenience methods): extension Prescription {     // MARK: - INTERNAL TYPES     enum PointOfCareContext: String, CustomStringConvertible {         case premedication, perioperative, postoperative, hospitalised         var description: String {             return self.rawValue.capitalized         }     }     // MARK: - PROPERTIES     var drug: Drug {         get { guard let drug = cd_drug else {             fatalError("Persistent store corrupted: Prescription is missing relationship to Drug.")         }             return drug         }         set { cd_drug = newValue }     }          var timePrescribed: Date {         get { guard let timePrescribed = cd_timePrescribed else {             fatalError("Persistent store corrupted: Prescription is missing timePrescribed.")         }             return timePrescribed         }         set { cd_timePrescribed = newValue }     }     /// When the drug should be administered     /// Passing nil to this property indicates the drug should be given asap (so will return current Date)     var timeScheduled: Date? {         get { guard let timeScheduled = cd_timeScheduled else {             return Date.now         }             return timeScheduled         }         set { cd_timeScheduled = newValue }     }     /// When the drug was administered     /// Nil indicates not given yet     var timeAdministered: Date? {         get { return cd_timeAdministered }         set { cd_timeScheduled = newValue }     }     var doseRate: Measurement<UnitDensity> {         get {             if (cd_doseRate != 0) {                 fatalError("Persistent store corrupted: Prescription doseRate == 0.")             }             return Measurement(value: cd_doseRate, unit: .milligramsPerKilogram)         }         set {             cd_doseRate = newValue.converted(to: .milligramsPerKilogram).value         }     }     var dose: Measurement<UnitMass> {         get {             return Measurement(value: cd_dose, unit: .milligrams)         }         set {             cd_doseRate = newValue.converted(to: .milligrams).value         }     }     var doseVolume: Measurement<UnitVolume> {         get {             return Measurement(value: cd_doseVolume, unit: .milliliters)         }         set {             cd_doseVolume = newValue.converted(to: .milliliters).value         }     }     var context: PointOfCareContext {         get {             guard let contextValue = cd_context, let context = PointOfCareContext(rawValue: contextValue) else {                 fatalError("Persistent store corrupted: Prescription has an invalid administration context [\(cd_context ?? "")]")             }             return context         }         set {             cd_context = newValue.rawValue         }     } Error encountered when attempting to save managed object context in the unit test:
Posted Last updated
.
Post not yet marked as solved
2 Replies
169 Views
I have configured multiple test plans, I see them in the scheme editor. I have marked one as default. Now I would like to choose a specific one for the Xcode Cloud Test action, but there is only the option "Use Scheme Settings". The Test Action in the workflow The Test Plans in the Scheme
Posted Last updated
.
Post not yet marked as solved
0 Replies
115 Views
Hello, We have multiple iOS real devices attached to a Mac mini which serve as a server in a CI pipeline. From iOS 15 after a few hours, the phone requires the pin code, even if the UI automation is enabled and the pin was set at the first run. A few mentions: We need to have a pin set because the app under test needs a pin for security reasons We set the display to never sleep because we cannot unlock the phone through the automation script For automation, we're using Appium (https://github.com/appium/appium) My question is, how can we handle the case without unlocking manual the phone considering that we're using the devices in a CI pipeline?
Posted
by alexki07.
Last updated
.
Post not yet marked as solved
3 Replies
633 Views
On an intel mac, my XCUITest test cases which is included swipe actions works perfectly but it doesn't work on my m1 mac. I tried running simulator with Rosetta but it doesnt work out it still gives an error when I run my cases because it clicks instead of swipe. Does anyone have a solution for swiping problem on the m1?
Posted
by beyz.
Last updated
.
Post not yet marked as solved
0 Replies
113 Views
I am running my UI Tests on Github CI and the tests are flaky. I don't understand how I can fix it. The animations are disabled and I am running the tests on a iPhone 13 plus. A lot of tests are running green, but some are not working. Locally, I got everything working. These are some logs: 2022-06-21T13:42:23.2627250Z t = 63.34s Tap Cell 2022-06-21T13:42:23.2707530Z t = 63.34s Wait for com.project.project to idle 2022-06-21T13:42:23.2733620Z t = 63.41s Unable to monitor event loop 2022-06-21T13:42:23.2734250Z t = 63.41s Unable to monitor animations 2022-06-21T13:42:23.2734800Z t = 63.42s Find the Cell 2022-06-21T13:42:24.1158670Z t = 64.45s Find the Cell (retry 1) 2022-06-21T13:42:24.1287900Z t = 64.45s Collecting extra data to assist test failure triage 2022-06-21T13:42:24.2022460Z /Users/runner/work/project/UITestCase.swift:665: error: -[project.UserTagTest testTapInTextView] : Failed to get matching snapshot: Lost connection to the application (pid 12676). (Underlying Error: Couldn’t communicate with a helper application. Try your operation again. If that fails, quit and relaunch the application and try again. The connection to service created from an endpoint was invalidated: failed to check-in, peer may have been unloaded: mach_error=10000003.) It can not find the cell because of these logs: Unable to monitor event loop Unable to monitor animations I know this because I sometimes get different errors than the error above, which says that the connection to the application is lost, right below the Unable to monitor... error logging. Is there anything I can try? I don't have a reproduction project. This is the command that is executed: xcodebuild test -project project.xcodeproj -scheme project-iosUITests -destination 'platform=iOS Simulator,name=iPhone 13 Pro,OS=15.5' The CI runs 35 tests and 5 fails randomly with the Unable to errors. Is there any suggestion to fix this problem?
Posted
by Jasperav.
Last updated
.
Post not yet marked as solved
1 Replies
631 Views
HiThe app under test is localized and internationalized. So when device language is changed, strings displayed on the app are changed.I am trying to write test cases that work independent of the current language, in order to achieve this some of the static text/button labels have to be localized for the element query to work correctly.How can we achieve this? If I try to have all the strings in an external file, the bundle created for UITesting for some reason does NOT include this strings file.Can someone please shed light on how to include non-code files into UI Testing bundle?I tried having the file named as .json, .strings. It does not work.ThanksNaveen
Posted Last updated
.
Post not yet marked as solved
1 Replies
201 Views
I have a multiplatform project in Xcode 13.3.1, but when I try to run a unit by clicking the diamond in the gutter, the linker fails. From the link line in the log, it looks as if it isn't even linking with my app at all. I also noticed that I had to put in my own @testable import NameOfMyApp instead of Xcode generating that line like it does for single-platform projects, so that makes me wonder if this something extra i need to do since this project is multiplatform? Everything compiles fine, but the linker seems to be forgeting to link with my app...
Posted
by remsleep.
Last updated
.
Post marked as solved
1 Replies
129 Views
Hello, we use XCTest to run test on our macOS apps. It is good, but it prevents the use of the mac in the meantime, since it actually moves the mouse and perform click, rather than simulate them. Is there a way to send mouse movements and clicks to the app, rather than actually moving the mouse? Can I run the test inside a macOS simulator? How do XCTest work under the hood? I can see the testing framework has access to a very detailed view of what's inside the macOS app, even though we have not done anything special. Is it using something like Apple Script under the hood?
Posted Last updated
.