xctest

AFNetworking Cause Error while using XCTest in Xcode5

醉酒当歌 提交于 2019-12-09 11:20:37
问题 I am using Xcode 5 and now just started unit testing on my existing project, for that I added the CocoaTouch Unit Testing Bundle as a target (Target Name is : MyAppTests) to my project.I was previously added AFNetworking library using CocoaPods ,while I am running the test Case I got the error AFNetworking.h file not found. I added AFNetworking.h in the Tests.m but issue till remains. Is there any additional setting s for including the Pods to my testing target?? 回答1: Got the solution finally

can we check the validation of uitextfield while Unit Testing?

我只是一个虾纸丫 提交于 2019-12-09 07:29:04
问题 Suppose we have some validation in our ViewController ( say vc1 ) for a UItextfield in shouldChangeCharactersInRange method, as user only can enter the numbers not the alphabets or other special character. I just want to know that in our XCTestCase class, is this possible in unit testing, to check for a particular uitextfield , is allowing some characters (in my case only numbers) or not? 回答1: Make unit tests that call shouldChangeCharactersInRange and check the expectation that the result

iOS, locking the device from code

允我心安 提交于 2019-12-08 16:01:29
问题 for testing purposes (making a screenshot of a local notification) i need to be able to lock the device (simulator) from code (either tests code or app code). I've looked at a couple of answers from here (GSEventLockDevice), but they are quite old and didn't work for me 回答1: There is a private method in XCUIDevice, so you can lock device/simulator using it. Example for Swift 3: import XCTest class LockTests: XCTestCase { func testExample() { XCUIDevice.shared().perform(NSSelectorFromString(

XCTest not registering new methods as tests

此生再无相见时 提交于 2019-12-08 15:48:57
问题 I have a seemingly weird problem (unless I'm missing something totally obvious!) and am curious if anyone here has any insight. I've done quite a bit of searching and haven't found anything. When I try and write unit tests in XCTest - creating new methods - they don't seem to register as tests and aren't executed when I run the test suite. They also don't get one of those nice little diamond run buttons next to them that allows you to run individual tests: When using JUnit for example here

XCUITest: Running tests across two apps in a coordinated fashion

余生长醉 提交于 2019-12-08 05:27:23
问题 I am looking at using XCUITest for UI tests for my iOS apps. It looks like XCUITest has a wide arrange of functionality, including the ability to work with multiple apps. However, the multiple app support seems somewhat limited. It seems that using XCUIApplication I can start another app using Bundle ID and even monitor its state. However, what I want to do is be able to run a coordinated test for two apps that have tight interaction (for example, one app does an open URL to another app,

How to properly unit test Realm migration

荒凉一梦 提交于 2019-12-08 04:28:07
问题 I have looked at the post here How to unit test Realm migrations and am trying to implement what they have stated which is the following: Store old .realm files and write tests for before / after migrations. I have my v0.realm file in my unit test bundle and am creating a copy of it to work with. The issue is that with my latest migration I removed a Type from my application and thus from Realm and I'd like to test that it no longer exists. When I set up my realm configuration I should be

xcode 5 syntax highlight not working for unit test file

我只是一个虾纸丫 提交于 2019-12-08 02:21:26
问题 I have setup a unit test for my project. Initially i got stuck with errors during the compilation of the test file, finally i solved it and my tests now are working. The problem now is that the syntax highlight is not working for the test file, only for that. I tried following this answer to solve this issue but no luck. Removing the derived data of the project worked one time but then i closed xcode and when i reopened it there was no syntax highlight again. Also i have reinstalled xcode 5

XCTestCase not launching application in setUp class method

不想你离开。 提交于 2019-12-08 01:36:22
问题 I am using XCode 8 and XCTestCase. I created a class setUp function to be ran once before all tests, and the other setUp to be ran before each test case. I want the application to be launched once before all test cases. If I use the launch in the class setUp, it never gets executed. If I use the launch in the setUp that is ran before each test, it does launch the test. It prints: IN CLASS SETUP END CLASS SETUP IN SETUP IN TEST METHOD But the application never gets launched. If I uncomment the

Xcode 5 Tests Not Running

无人久伴 提交于 2019-12-07 23:56:11
问题 I get the following message from Xcode when I try to run my tests: 2013-11-13 09:02:57.849 MyProject[378:303] Error loading /Users/tatami/Library/Developer/Xcode/DerivedData/MyProject-gcralijdlibafgeyfwfeiynnothy/Build/Products/Debug/MyProjectTests.xctest/Contents/MacOS/MyProjectTests: dlopen(/Users/tatami/Library/Developer/Xcode/DerivedData/MyProject-gcralijdlibafgeyfwfeiynnothy/Build/Products/Debug/MyProjectTests.xctest/Contents/MacOS/MyProjectTests, 262): no suitable image found. Did find:

How to wait in a XCTest for T seconds without timeout error?

可紊 提交于 2019-12-07 05:25:49
问题 I want to delay progression of a test for T seconds, without generating a timeout. First I tried the obvious: sleep(5) XCTAssert(<test if state is correct after this delay>) But that failed. Then I tried: let promise = expectation(description: "Just wait 5 seconds") waitForExpectations(timeout: 5) { (error) in promise.fulfill() XCTAssert(<test if state is correct after this delay>) } My XCTAssert() now succeeded. But waitForExpectations() failed with a timeout. This is according to the