Questions tagged [xctest]

XCTest is an Apple-provided framework which implements unit testing functions. It works with iOS 7 and all versions of OS X.

XCTest is a testing framework initially released with Xcode 5, provides a common framework for writing unit tests. XCTest supports unit testing for iOS, IPadOS, tvOS, watchOS, and macOS projects.

XCTest is part of the following SDKs:

  • Xcode 5.0 and later.

References

1962 questions
0
votes
1 answer

What is a good or common way to structure a CLI appliction in Swift

I am in the process of learning Swift 5 and what better way to write some exercises. But this is becoming a bit of a headache for me. This is what I am trying to do. I want to write a simple CLI application, but I also want to include unit tests.…
dospro
  • 450
  • 1
  • 5
  • 17
0
votes
1 answer

Swift UI: Unit testing @Published var in an ObservableObject ViewModel

So I'm trying to write a unit test to test a view model function however it is an Async function and in the test I'm trying to write it will run synchronously. I've seen a few examples online e.g listViewModel.$list.sink { _ in …
0
votes
1 answer

AWS device-farm iOS XCTest UI suite can't access main app's container

I'm using XCTestUI to write automated tests for an iOS app. Got a couple of tests running on Xcode Simulator and on several real devices (iPhones). When I try to run the exact same tests in AWS device-farm, on the same devices (including iOS…
x00e
  • 1
  • 1
0
votes
0 answers

What should be the best approach to test iOS SDK public functions with number of real devices and iOS version?

I am looking into the approaches for testing the iOS SDK public functions without explicitly developing an dedicated app to test the SDK public function. Approach which did not worked: We can develop an app and include button's and on clicking that…
atul
  • 1
0
votes
2 answers

UISearchController's isActive property can't be set to true in unit tests

I am writing unit tests for my UITableViewController's data source, which has a UISearchController for filtering results. I need to test the logic in NumberOfRowsInSection so that when the search controller is active, the data source returns the…
user2129800
  • 131
  • 1
  • 9
0
votes
1 answer

zip created using -jr flags unzipped differently on macOS when double clicking vs running unzip

I am zipping the .xctest file from Plugins folder inside the .app target generated by building my app. I have a build phase script that runs last in my test target to copy this file over. I use the following script to do the…
Parth
  • 2,682
  • 1
  • 20
  • 39
0
votes
1 answer

FBSnapshotTestcase vs xcuiscreenshot

I am trying to understand the use case FBSnapshotTestcase solves. We already have native apple lib named xcuiscreenshot. Whenever any UITest fails, it automatically takes screenshot of the view for reference. FBSnapshotTestcase compares with the…
0
votes
1 answer

Could not load Main.Storyboard in XCUITest

I am try to make UITestCase for UIViewcontrollers, But when I load main storyboard in my QuizAppUITests, It could not identify from Bundle and it's gives below error Could not find a storyboard named 'Main' in bundle NSBundle…
Hitesh
  • 896
  • 1
  • 9
  • 22
0
votes
1 answer

How to get the configurations of current running XC Test plan programmatically?

Problem Statement: My Test flow will depend on the type of configuration that is currently running for a test plan. I want to get the configuration name and environment variable entries of the currently running test plan in Xcode, so that according…
Samarth Kejriwal
  • 1,168
  • 2
  • 15
  • 30
0
votes
0 answers

XCTest: lines covered by unit test reported as not covered

I have unit tests for my XCode project, the test result that shows lines that are covered or not has something incorrect, in the report it's like: But I do have unit test covering that line, I tried…
Heuristic
  • 5,087
  • 9
  • 54
  • 94
0
votes
0 answers

How to know the test case failure reason in iOS?

I'm running the unit tests and getting the result Test failed Here is the exception I'm getting: Asynchronous wait failed: Exceeded timeout of 5 seconds, with unfulfilled expectations: "SIGN-UP step1 with valid email & pw succeeds". How can I…
0
votes
2 answers

Errors setting up XCTest using Swift Result type

I am learning how to write tests for my API requests but having trouble setting up my test's completion code and response model. I tried using an instance of UserResponse (let userResponse = UserResponse() ) however it required a value for its…
user14542817
0
votes
0 answers

How to run Xcode tests with yml?

It seems like it should be pretty simple, I just want to trigger a build and unit tests to be executed every time a developer pushes to their fork. GithubActions. I’m creating a macOS app. Here is what I'm trying. It doesn't work. name: Smoke Test…
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
0
votes
0 answers

Getting error while mocking services in test target

I am trying to write test cases for the test target. The app is running perfectly, but the test case failing with the mocking. Here is my code, please let me know if there any other solutions. How do I mock services? Is there any other way to write…
DRN
  • 153
  • 2
  • 12
0
votes
1 answer

How to cancel a call with XCTest for iOS 14

Hi I'm writing some XCTest in Swift for iOS 14. Back in iOS 13 the springboard handled the call screen and you could end a call with let app = XCUIApplication(bundleIdentifier: "com.apple.springboard") app.buttons["End…
sago92
  • 51
  • 6