xctest

xctest - how to test if a new view loads on a button press

我是研究僧i 提交于 2019-12-07 05:17:57
问题 Just started xcode 5 and xctest. How do I test that a view loads on button press. I have programatically added method that gets called when the rightBarButtonItem is clicked action:@selector(onSettingsButton) and in onSettingsButton -(void) onSettingsButton{ SettingsViewController *svc = [[SettingsViewController alloc] init]; [self.navigationController pushViewController:svc animated:YES]; } How to write xctest to ensure SettingsViewController brings up the Settings view? Thank you. 回答1: You

How can I verify existence of text inside a table view row given its index in an XCTest UI Test?

淺唱寂寞╮ 提交于 2019-12-07 03:22:39
问题 I am using XCTest UI Test framework to check rows in a table view. In my test I need to verify the existence of text in a table view row given its index. I was thinking of using tableRows.elementBoundByIndex method, but it did not return anything. The number of rows returned by calling tableRows.count is zero. The table is present and filled because I can query the text inside the rows successfully: XCTAssertEqual(app.tables.staticTexts["Cute Alpaca"].exists) How can I verify existence of a

XCTest UI Testing - How to close and open an app without relaunch?

▼魔方 西西 提交于 2019-12-07 03:01:24
问题 I want to make my app to go to background, and then comeback to the foreground. To make an app to go background: XCUIDevice.shared().press(XCUIDeviceButton.home) To terminate an app(force tap): XCUIApplication().terminate() To launch the app: XCUIApplication().launch() Problem : when I try to close and open the app, the launch() method clears the app from background and it opens the app freshly. I saw this comment regarding this. But cant able to figure out it in UI test. I'm using Swift.

Xcode 6.1 dyld: Library not loaded: @rpath/XCTest.framework/XCTest error

China☆狼群 提交于 2019-12-06 16:39:52
I imported my old project in Xcode 6.1 and error mentioned above started coming during runtime, with reason image not found ,I have tried all off the answers suggested in following link Xcode 5.0.2 dyld error but none of them worked for me so far,so does anybody have any idea how to get rid of this problem. any help will be appreciated. This was used for betfair/aping-ios-sdk 1) Go to Project settings -> App Main Target -> Build Phases -> Link Binary With Libraries and make sure you have XCTest.frameworks in there if not, click + button, then Add Other Framework then press together CMD + SHIFT

Insert test data in Core Data

无人久伴 提交于 2019-12-06 16:21:38
I'm currently writing some unit tests in a project using Core Data (Xcode 5). For testing purpose I need to insert a bundle of data into my Core Data model in the setUp . What is the easiest way doing that? For instance it would be helpful if I could write an XML file and populate this into my Core Data . You can use Valentina studio to open Core Data Model(SQLite file) and insert values. I end up inserting the test data programatically in the test setup. You can check this article for a guide for testing Core Data - to sum it up, they are using MagicalRecord: http://www.cimgf.com/2012/05/15

How to test if a UIImageView contains an image with a specific name using XCUITest?

大兔子大兔子 提交于 2019-12-06 10:35:24
I have a collectionView that has a bunch of cells that contain a single UIImageView in each cell. I want to test wether or not in each cell, the imageView's image matches the correct image name. In the production code, I've added an accessibility identifier to the UIImageView example: "My Image View". I loop through an array of strings containing image names and set the cell's image in accordance to the index, example: ["image0.png", "image1.png", "image2.png"] so cells at index 0-2 would have those images respectively. In my XCUITest file I'm trying something like this: XCTAssert(cells.images

XCTestCase not launching application in setUp class method

China☆狼群 提交于 2019-12-06 07:43:05
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 line to launch the application in the second setUp, it will get launched. How can I have the

Xcode 5 Tests Not Running

那年仲夏 提交于 2019-12-06 06:05:45
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: /Users/tatami/Library/Developer/Xcode/DerivedData/MyProject-gcralijdlibafgeyfwfeiynnothy/Build

unit test async function by using XCTestExpectation but it doesn't wait for the seconds I set

孤街浪徒 提交于 2019-12-06 05:27:35
I have a MyService class which inherits NSThread : header: @interface MyService : NSThread { -(void) startMe; -(void) doTask; ... } implementation: @implementation MyService -(void)startMe { [self start]; } -(void) doTask { [self performSelector:@selector(checkData:) onThread:self withObject:nil waitUntilDone:YES]; } -(void) checkData { ... // NOTE: dataChecked is an instance variable. dataChecked = YES; } @end I want to unit test the above -(void)doTask and verify that -(void)checkData is really called. I use OCMock library to partially mock MyService . Inspired by this tutorial (use

In XCTest UI Testing, how to check the background color of button, label , views?

☆樱花仙子☆ 提交于 2019-12-06 00:07:39
问题 I am trying to validate if the background color can be obtained in XCTest UI Testing, I am looking to compare the background color with the set value, so that i don't have to rely on image comparison 回答1: XCTest is for functional testing, rather than asserting visual requirements. To test requirements such as background color, use a unit test to initialize the view controller in question and check the view's background color there. You don't need to rely on image comparison, and unit tests