FAQ Database Discussion Community


Using Xcode7's UI tests to create app screenshots for the App Store

ios,swift,xctest,xcode7,ios9
Every time we change something in the UI, we have to manually prepare and take 375 (= 5 screenshots * 5 device types * 15 languages) screenshots for iTunes Connect's listing. I'm trying to "exploit" iOS 9's new UI testing to automatically prepare and take these screenshots for each language....

Is there a way to inject test data into a XCTestCase?

ios,unit-testing,dependency-injection,xctest,xctestexpectation
I'm trying write some simple test cases for a project I am working on. I have a simple method that takes an input and returns true/false depending on the outcome of an operation on that input. base case unit test right? In java, I can use a framework called TestNG...

Applying the same test to all members of a collection

objective-c,cocoa,tdd,xctest
In a test I have a NSArray with several objects. They must all pass the same test. Is there a better or more elegant way to express this than just doing a for-in and applying the same macro to each element?...

XCTest fails when calling [NSBundle mainBundle]

ios,unit-testing,nsbundle,xctest,ocmock
I have some code that calls [NSBundle mainBundle] at some point, mainly to read/set preferences. When I unit test the method, the test fails because the test's mainBundle does not contain the file. This is a known issue, that Apple won't fix as they consider it is not a bug:...

Manipulate app permissions on iOS 8 simulator

ios8,ios-simulator,xctest
Same question as this one, but for iOS 8. While running xctests, how can I make sure permissions are granted/denied programmatically? Is the same TCC.db used? If so, as there are no $HOME/Library/Application Support/iPhone Simulator/8.x directories, where has it moved to?...

OCUnit (SenTestingKit) is deprecated, please convert to XCTest

objective-c,xml,xcode,parsing,xctest
How can I convert SenTestingKit framework to XCTest. My warning is SenTestCase_Macros.h:34:2: OCUnit (SenTestingKit) is deprecated, please convert to XCTest. I am doing XML parsing in Ios (Objective-C)...

How to use classes from another target for tests in XCTest

ios,xcode,unit-testing,xctest
I use Xcode 6.1 to create a new project, and it comes with a Tests target. I am trying to use the classes defined in another demo target in the same project for tests. But how do I accomplish this (besides setting the class's target membership to both demo and...

XCTest UI Record and Play - Simulator not updating UI

xctest,ios9,xcode7
Apple released a new UI Testing framework 2 days ago during WWDC2015. I'm trying to write a test case and when I try to record the UI testing, to generate the scaffolding code, it looks the code is being generated, however the UI on the simulator is not actually updating....

Tests are not executed - Bot Issue: Test target MyTests encountered an error (Test session exited(0) without checking in

objective-c,xcode,xctest,osx-server
I'm using Xcode Continuous Integration for making builds. OS X Server 4.1, Mac OS X 10.10.4, Xcode 6.3.1 My all test cases start failing after OS X update OS X 10.10.4 (Build 14E17e) and Xcode 6.3.2. I'm not sure whether these update cause the issue or something else. Error: Bot...

module.map for accessing (Swift and Objective-C) classes in main target from test target

objective-c,swift,module,xcode6,xctest
I am in the process of adding Swift classes to an existing Objective-C project. As part of this, I have added a MyProjectTests.swift to the target MyProjectTests. It imports Swift classes from target MyProject with import MyProject and that works just fine. I now want to use @import Swift; in...

Unit test case fails in xcode

ios,objective-c,xcode,xctest
When I run my unit test cases in xcode 6.3 it gives me an error saying ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation). The unit tests...

Unit testing asychronous UI code which does not know about XCTestExpectations?

objective-c,asynchronous,xctest,unit-testing
How can one go about unit-testing pieces of iOS code that work in a non-trivial graphical setup? Consider for instance view controllers A and B, where A stacks B on top with performSegueWithIdentifier:sender:. A unit test should check the behavior of a C that depends on the two view controllers...

How one tests http requests in iOS 8?

ios,unit-testing,swift,ios8,xctest
In ruby I used to test http requests with vcr gem which recorded the request so the tests didn't send request to real host. Is there anything like this in iOS8 world? The requests I want to test really need to be recorded since those requests may be outdated in...

XCTAssertThrowsSpecific example

objective-c,xctest
I have an XCTest case with the following code: - (void)testNilInDict { NSMutableDictionary *r = (NSMutableDictionary*) @{@"1": @1, @"2": @2}; XCTAssertThrowsSpecific([r setObject:nil forKey:@"3"], NSInvalidArgumentException); } This does not build. Then, I wanted to look for the correct syntax or an example online, but all I found was a list of...