xctest

Xcode UI test manual snapshot

女生的网名这么多〃 提交于 2019-12-21 17:28:11
问题 I want to manually take some snapshots from my applications using UI Tests intoduced in Xcode 7. By default, Xcode takes screenshots of every step and in result I got screenshots that was taken in the middle of transitions between view controllers. I want to manually take snapshot in the specific moments. Any ideas how to do this? I know how to take screenshot of UIView, but XCUIApplication doesn't provide any API to get UIView objects. 回答1: I've created a library for this: https://github.com

Replicate pull to refresh in XCTest UI testing

こ雲淡風輕ζ 提交于 2019-12-20 16:39:40
问题 I am trying to replicate a pull to refresh on a UITableView using the new Xcode UI testing framework in Xcode 7 (beta 3) My current approach is dragging from the table to whatever element below the table I can find. This works when there is a fixed item below the table like a UIToolbar or UITabBar I would rather not rely on having a UITabBar or UIToolbar but I can't figure out a way to do the pull to refresh/drag action without using the method in XCUIElement . func pressForDuration(duration:

Replicate pull to refresh in XCTest UI testing

家住魔仙堡 提交于 2019-12-20 16:39:07
问题 I am trying to replicate a pull to refresh on a UITableView using the new Xcode UI testing framework in Xcode 7 (beta 3) My current approach is dragging from the table to whatever element below the table I can find. This works when there is a fixed item below the table like a UIToolbar or UITabBar I would rather not rely on having a UITabBar or UIToolbar but I can't figure out a way to do the pull to refresh/drag action without using the method in XCUIElement . func pressForDuration(duration:

How to let the app know if its running Unit tests in a pure Swift project?

依然范特西╮ 提交于 2019-12-20 08:23:22
问题 One annoying thing when running tests in Xcode 6.1 is that the entire app has to run and launch its storyboard and root view controller. In my app this runs some server calls that fetches API data. However, I don't want the app to do this when running its tests. With preprocessor macros gone, whats the best for my project to be aware that it was launched running tests and not an ordinary launch? I run them normally with CMD+U and on a bot. Pseudo code would be: // Appdelegate.swift if

Why, when I am testing that a method throws an exception and the method throw an exception, does the test stop?

扶醉桌前 提交于 2019-12-20 04:24:39
问题 I have a unit test that tests if method throws an exception when condition is present, and method does throws exception as expected. - (void)testMethodThrowsWhenConditionIsPresent { XCTAssertThrows([Foo methodWithCondition: condition], @"Condition is true, method should throw exception"); } Here is the exception source: - (void)methodWithCondition:(someType)condition { if (condition) { [NSException raise: @"condition is true!" format: @"condition is true!"]; } } Why does the test stop at the

XCTest Unit Test data response not set in test after viewDidLoad

牧云@^-^@ 提交于 2019-12-20 03:23:35
问题 I'm trying to write Unit Tests and currently I try to test a viewController which received data in viewDidLoad() , the data is set after a alamofire request. The problem is, that in my test function when I check the array which should be filled with 10 elements after the successful request, is 0. I've checked if viewDidLoad() in the test is not executed, but it should be, because when I just add elements to another array, which is outside the request, the specific test works. I guess, it has

Test bundle could not be loaded because an unanticipated error

元气小坏坏 提交于 2019-12-18 12:54:27
问题 Recently I have started writing test case for one old static library. I have loaded the library to Xcode 5,Since Static Library is old , I have to manually add TestProject with Test Target. When I am trying "Product-->Test" , It launches emulator and Console shows following error The test bundle at /xxx/xxx/xxx/StaticLibTest.xctest could not be loaded because an unanticipated error occurred: Error Domain=NSCocoaErrorDomain Code=3587 "The bundle “StaticLibTest.xctest” couldn’t be loaded

How do I migrate from SenTestingKit/OCUnit to XCTest?

孤街醉人 提交于 2019-12-18 10:41:38
问题 I am in the process of migrating my project from Xcode 4.6.3 to Xcode 5.0.2. The project's unit tests were developed with SenTestingKit/OCUnit. Now when I am running the tests in Xcode 5, I get an error from the RunUnitTests script telling me that RunUnitTests is obsolete. Possibly related is this note in the Xcode 5 release notes: SenTestingKit and OCUnit are deprecated. Use the migrator to move to XCTest. Unfortunately, I have not been able to find out more about this mysterious "migrator".

Unit testing Parse framework iOS

强颜欢笑 提交于 2019-12-18 05:13:07
问题 I am attempting to write unit tests for an iOS application which makes use of the Parse backend framework, and after much experimentation seem to be failing at writing successful unit tests. I have found a few posts on testing asynchronous code (Testing asynchronous call in unit test in iOS) and testing network calls, but am yet to find a way of testing calls to the Parse backend with async callbacks. To give an example, could anyone advise how I would test the following line of code: [PFUser

XCTest/XCTest.h not found on old projects built in Xcode 6

╄→гoц情女王★ 提交于 2019-12-17 23:19:16
问题 I have a few projects I'm trying to build with Xcode 6 Beta 2. The projects all have some type of library that uses XCTest (Kiwi/XCTest and Specta) that don't build in Xcode 6 because XCTest/XCTest.h cannot be found. fatal error: 'XCTest/XCTest.h' file not found #import <XCTest/XCTest.h> I noticed that XCTest.framework is no longer in the "Link Libraries with Binaries" build phase list, but that's fine because when I create a new project with Xcode 6 it appears the library is linked in