Questions tagged [xctestcase]

The primary class for defining test cases, test methods, and performance tests for iOS and Mac OS development.

226 questions
3
votes
4 answers

how to stop Xcode iOS unit tests if a fatalerror is hit?

How can I stop Xcode iOS unit tests if a fatalerror is hit? That is in case I have 10 unit tests, but it happens that the code it calls for unit test number 5 has a coding problem (** coding issue in this case is in the test case and setup code **)…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
1 answer

How can I download apps to iOS Simulator?

with the recent updates appstore is not available in simulator. I want to download apps such as twitter, facebook etc... to implement some UITests. How can I achieve that?
SwiftyQA
  • 33
  • 4
2
votes
1 answer

Are there architectural patterns for Swift Unit Testing?

I wondered if there were architectural patterns, like MVP, MVVM for unit tests in swift. I know about AAA pattern, but it breaks the logic inside the test method. In all the stuff I've read, the structure of the tests was made the same as the…
2
votes
1 answer

XCTAssertEqual gives me error - UIViewController.Type cannot conform to 'Equatable'

I have an enum like following- enum Vehicle: String, CaseIterable { case car = "/car/" case boat = "/plane" case bicycle = "/bicycle/" case train = "/train" var targetControllerType:…
Natasha
  • 6,651
  • 3
  • 36
  • 58
2
votes
0 answers

XCTest Error: Restarting after unexpected exit, crash, or test timeout in TestClass/testMethod(); summary will include totals from previous launches

My XCTest Test case is failing with the following error when I try to Tap on the Menu button as the first step after application launches. Restarting after unexpected exit, crash, or test timeout in TestClass/testMethod(); summary will include…
Yogesh Solanki
  • 487
  • 5
  • 12
2
votes
1 answer

Access NavigationLink using accessibility identifier in XCTestCases class - SwiftUI

I have recently started work on the SwiftUI framework, I'm writing UI Test Cases using XCTest. NavigationLink("Login", destination: TabBarDashboardView()) .accessibility(identifier: "linkLogin") .frame(width: 200, height: 50,…
2
votes
1 answer

Test if a function is called in Unit Testing for Objective C

In the implementation file (.mm) I have a function that calls different APIs depending on the value of a boolean isTrue which is set in other APIs @implementation Controller -(void) setProperty:(Id)Id value:(NSObject*)value { if(value) { …
2
votes
1 answer

Testing Dark Mode using snapshot testing

Any leads how can we use Snapshot testing to test darkmode implementation? Or any other testing strategy for dark mode on iOS. When XCUITest is one of the options along with XCTest (unit-test). The problem with UITest in dark mode means for every…
2
votes
1 answer

XCUITest pass arguments to the test

i have an app that can show many popups in various scenarios, and i would like to verify their text using XCUITest. but would like to be able to do that with no effort for multiple text configurations. for multiple languages for instance. Is there a…
Itay Bianco
  • 697
  • 6
  • 16
2
votes
1 answer

Unit test API Call with internal switch case

I am trying to unit test a class that has different modes of setup. class Controller{ enum Mode{ case listing case pages(String?) } private (set) var mode : Mode = .listing private (set) var models = [Model]() …
Rikh
  • 4,078
  • 3
  • 15
  • 35
2
votes
1 answer

I can't delete my application during the teardown phase of my tests

I'm writing tests within my SwiftUI application and am working with XCTest and XCTestCase. Within my tests, I'm working with (and without) certain user permissions. The problem that I am running into, is that once permission is set, I must delete…
Bonteq
  • 777
  • 7
  • 24
2
votes
0 answers

XCTest test case failed with error "Failed to install or launch the test runner". (Underlying error: Could not connect to the device)

I am running an Xcode test command in the terminal. Here is the command xcodebuild test -project $project_dir/Application.xcodeproj -scheme Application -sdk iphoneos -destination id=$UDID >> $LOGFILE_PATH But my test case has failed with the error…
Yogesh Solanki
  • 487
  • 5
  • 12
2
votes
0 answers

How can make this RxSwift based Coordinator more testable

I am trying to add tests to an existing code base. The app uses RxSwift w/ a coordinator pattern. The AppCoordinator looks like - import UIKit import RxSwift enum AuthenticationState { case unknown, signedIn, signedOut } final class…
Tim J
  • 1,211
  • 1
  • 14
  • 31
2
votes
1 answer

getting strange Thread 1: EXC_BAD_ACCESS (code=1, address=0x9) crash error in swift

I'm writing unit test for MyClass. consider below code: MyClass.swift class MyClass { let collectionPeriod: TimeInterval var previousCollectDate: Date? init(period: TimeInterval, previousCollectDate: Date?) { …
2
votes
1 answer

XCTEST addUIInterruptionMonitor false selects cancel button

I have multiple system alerts that appear one after another and I handle them using addUIInterruptionMonitor. The last alert I would like to not interact with but if you return false from addUIInterruptionMonitor it will automatically select the…
reutsey
  • 1,743
  • 1
  • 17
  • 36