Questions tagged [xctestcase]

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

226 questions
2
votes
0 answers

Ignore files when calculating Code Coverage in Xcode

I have recently add some extensions to my app, an example of which can be found below. Prior to this I was maintaining approx 93% code coverage, this has now dropped to around 56% and it appears all of the extensions I have added are showing 0%…
Harry Blue
  • 4,202
  • 10
  • 39
  • 78
2
votes
0 answers

Unit test keeps failing due to order of URLQueryItems

I have a unit test that is passing / failing randomly func test_WhenRequestHasURLParams_CorrectlyEncodesParams() { sut.call(endpoint: MockEndpoint.endpointOne(paramOne: "foo", paramTwo: "bar")) { (response: MockResponse) in } …
Harry Blue
  • 4,202
  • 10
  • 39
  • 78
2
votes
1 answer

How to access Apple Id "Sign In" dialog from UI Test?

I have some UI tests and wanna test what happens when I press "subscribe" button. In simulator there is an alert displayed asking to sign in with apple id: I tried to wait for alert using app.alerts["Sign In"] predicate and using…
silvansky
  • 2,426
  • 2
  • 19
  • 20
2
votes
2 answers

"Neither element nor any descendant has keyboard focus" when running XCTestCase in a real iPhone

I'm trying to run a UI test case where there are two input fields exists. Following is my code let usernameTextField = app.webViews.otherElements["Identity Server"].textFields["Username"] let passwordField = app.webViews.otherElements["Identity…
AnujAroshA
  • 4,623
  • 8
  • 56
  • 99
2
votes
0 answers

XCode code coverage

I would like to test my code completely with code coverage. But I am not able to find how to make complete code coverage. Here I have a simple test code to check code coverage. gist link:…
Damodar
  • 707
  • 2
  • 10
  • 23
2
votes
0 answers

EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) trying to run XCTest with SBTUITestTunnel

I'm trying to use the test framework SBTUITestTunnel in my XCTest UI automation. I have the Podfile set up as described: target 'MyApp' do pod 'SBTUITestTunnel/Server', '3.0.2' end target 'MyAppUITests' do pod 'SBTUITestTunnel/Client',…
Funktional
  • 4,083
  • 1
  • 30
  • 27
2
votes
1 answer

Limiting XCTests measure() to one run only

As part of a UI test I'm writing, I want to measure the performance of a feature. The test itself takes a while, and the part I want to measure is small, and the tests are frequently enough run that I will get the data I need with only one…
niklassaers
  • 8,480
  • 20
  • 99
  • 146
2
votes
1 answer

IOS UI Testing - Waiting for the network calls

I am writing a test cases for IOS using the XCTest framework. How can we wait for a network call and start our execution once our network call is finished. Currently, I am using sleep() for waiting. But, its not the best way to do it as it. So, is…
Deepak Terse
  • 652
  • 8
  • 30
2
votes
2 answers

Check that a view controller successfully dismissed with animation

I am very new to iOS dev and I am trying to write a unit test case for a class. It only has one method called homeButtonTouched() that dismisses the view controller with an animation. How may I write a unit test for this? This is what the class…
Erika
  • 235
  • 4
  • 12
2
votes
2 answers

How to change system date time before launch test [XCTest, swift]

I have no idea How to change system date time before launch test on real devices or simulator. Could you help me?
KeylorNavas
  • 131
  • 2
  • 10
2
votes
2 answers

What is the process of how an XCTestCase subclass is instantiated?

I understand that a class is a blueprint of a future object and I'm attempting to get a better grasp of OOP architecture using Swift. So the question I have is, what is the process that happens when you run your tests from a class and instances…
Laurence Wingo
  • 3,912
  • 7
  • 33
  • 61
2
votes
0 answers

Unit Test cases for iMessage extension iOS

I have added an iMessage extension as a target in my current app & I am trying to add unit tests for iMessage extension I tried adding the test cases for the iMessage extension but getting an error Undefined symbols for architecture x86_64: …
iYoung
  • 3,596
  • 3
  • 32
  • 59
2
votes
1 answer

Wait for multiple async calls in setUp() of XCTestCase

I need to perform multiple calls before letting the test() method run. I have a completion block, and I'm using waitForExpectations(). Since there is more than one async calls I'm using a counter. I let the expectation.fulfill() happen only when the…
Async-
  • 3,140
  • 4
  • 27
  • 49
2
votes
2 answers

How to capture Failure logs while testing : XCTest?

Working with XCTest. While testing testresults are saved in TestSummaries.plist at path: /Users/smriti/Library/Developer/Xcode/DerivedData/Project_name/Logs/Test/ Can anyone tell how to read contents of TestSummaries.plist file from above path? Need…
Smriti10
  • 58
  • 8
2
votes
0 answers

asynchron swift unit test getting called 3 times instead of 1

I've wrote a unit test for a asynchronous function which loads data via http request. When I start the test its getting called 3 times instead of 1 time. I tried to implement the unit tests like…
Kingalione
  • 4,237
  • 6
  • 49
  • 84