The primary class for defining test cases, test methods, and performance tests for iOS and Mac OS development.
Questions tagged [xctestcase]
226 questions
6
votes
5 answers
How to write unit test for button tap?
Here I'm trying to check unit test cases for view controller.
- I have a view controller with button and label.
- When you click on the button, it will call another method. which feeds the data to the button action label text change.
- I want to…

Damodar
- 707
- 2
- 10
- 23
6
votes
1 answer
XCTestCase save file? (Record NSSavePanel)?
I am trying to record a test case in which an NSDocument create and saves a file (then opens + verifies the contents again). The problem is when I record my test case, once a NSSavePanel is launched, the XCTestCase recording stops. I've tried to…

Kyle
- 17,317
- 32
- 140
- 246
6
votes
2 answers
ld:Framework not found for architecture i386
I am trying to test a method in my framework, and I wrote a simple test case. But it fails to execute , and xcode gives me the error:
ld: framework not found V***ments for architecture i386
clang: error: linker command failed with exit code 1 (use…

Teja Nandamuri
- 11,045
- 6
- 57
- 109
5
votes
1 answer
No matches found for Find: Elements matching predicate '"" IN identifiers' from input
Im getting this error on the Unit Test:
No matches found for Find: Elements matching predicate '"addressSearchBar" IN identifiers' from input {(
SearchField, 0x60000038a420, traits: 146029151232, label: 'Search on Google Maps', placeholderValue:…

Tassio Marques
- 81
- 1
- 10
5
votes
1 answer
Can't run xctest on macOS app - couldn’t be loaded because it is damaged or missing necessary resources
Please do help me on this scenario. I saw several post related to this, but could not able to resolve the issue with my mac App without pods.
Project is several years old, developed in macOS(Objective C). Now I am trying with XCTest for unit…

Anand
- 254
- 2
- 12
5
votes
0 answers
Unit Testing : cellForItem(at: IndexPath.init(item: 0, section: 0)) returns nil for UICollectionView
I am running into a very weird problem where my code for unit testing a UiCollectionViewCell returns nil.
var indexPath = IndexPath.init(item: 0, section: 0)
let cell = libraryGridViewController?.libraryCollectionView.cellForItem(at:…

Swarup Pattnaik
- 51
- 1
5
votes
1 answer
In Xcode 8, what is the way to make test methods run in a particular order within a given XCTestCase class?
Prior to Xcode 8, you could get your unit tests to run in a particular order by alphabetizing the names of the test methods within a given XCTestCase class (as described in this answer). E.g., tests would run like: testA, testB, testC, testD, etc.…

CommaToast
- 11,370
- 7
- 54
- 69
4
votes
1 answer
XCTestCase of a UIButton tap
I am trying to unit test the wiring of button taps in a UIViewController but I'm finding these tests fail even though the code in the running app works fine.
I've simplified the failing test by removing the view controller and such leaving…

Benjohn
- 13,228
- 9
- 65
- 127
4
votes
2 answers
UnitTest should I have to use teardown and setup
I want to test such a class:
class Foo {
var number: Int = 0
}
In the iOS unit test, normally test case should be:
class FooTests: XCTestCase {
var foo: Foo!
override func setUp() {
foo = Foo()
}
override func…

William Hu
- 15,423
- 11
- 100
- 121
4
votes
0 answers
How to send matching fingerprint in iOS XCTest
I am using xcode 8, swift, and creating a XCTest. I need to login to the application using a 'fingerprint' via the simulator. How can I send the option via an XCTest to the XCUIApplication that is normally chosen via the Hardware menu?:
When the…

reutsey
- 1,743
- 1
- 17
- 36
4
votes
1 answer
XCTestCase disable Snapshot accessibility hierarchy
I'm using XCode's XCTestCase for automated UI testing in order to measure performance of my application. I currently have a UITable with 25 000 elements in it and when trying to run tests that is supposed to swipe this list it takes for ever and…

Timothy Karvonen
- 347
- 1
- 2
- 9
4
votes
2 answers
Why does XCTestCase override the setup method of XCTest?
I'd like to think that I understand the idea of inheritance but apparently I don't because I'm confused as to why there a setup method in XCTestCase if XCTest provides the setup method in its class? XCTestCase is a subclass of XCTest but after…

Laurence Wingo
- 3,912
- 7
- 33
- 61
4
votes
2 answers
Use of undeclared identifier error in my case
My code invokes a C library function:
@implementation Store
...
-(void) doWork {
// this is a C function from a library
int data = getData();
...
}
end
I am unit testing the above function, I want to mock the C function getData()…

Leem.fin
- 40,781
- 83
- 202
- 354
4
votes
2 answers
UI XCTest, elements which exist in view
I am new to UI test writing.
I wanted to know if it is possible to know what elements are/exists in view. I want to know how many and how they are called.
I tried something like this to loop through all elements, but it does not work.
for element…

Konrāds Bušs
- 134
- 1
- 9
3
votes
1 answer
How should write the test case for the code below?
If this code is not suitable for write test code, how should modify the code for writing test case?
class MyFileManager {
static let shared = MyFileManager()
func isStored(atPath path: String) -> Bool {
return…

emraz
- 1,563
- 20
- 28