xctest

XCTest: running tests fails with Cycle inside X; building could produce unreliable results in project with CocoaPods and Carthage

空扰寡人 提交于 2020-12-13 03:39:55
问题 After upgrading my project to Xcode 12, the test suite stopped working. The tests target doesn't compile, fails with: Cycle inside <redacted>Tests; building could produce unreliable results. This usually can be resolved by moving the shell script phase '[CP] Embed Pods Frameworks' so that it runs before the build phase that depends on its outputs. Cycle details: → Target '<redacted>Tests' has copy command from '/Applications/Xcode12.app/Contents/Developer/Platforms/iPhoneSimulator.platform

XCTAssertThrows stops at breakpoint

折月煮酒 提交于 2020-11-29 08:35:55
问题 I'm writing a test method where I want the SUT to throw an exception when under certain conditions. The code looks like this: - (void) testCantStartTwice { XCTAssertThrows([self.sut start], @""); } Now, all is good and the test passes. However, I have Xcode set an Exception Breakpoint for all ObjC exceptions, which is pretty useful when testing out an app in the debugger. As you now, now when I execute my test suite with ⌘U, now it stops at that test and looks like if it's failing, even

XCTAssertThrows stops at breakpoint

十年热恋 提交于 2020-11-29 08:35:21
问题 I'm writing a test method where I want the SUT to throw an exception when under certain conditions. The code looks like this: - (void) testCantStartTwice { XCTAssertThrows([self.sut start], @""); } Now, all is good and the test passes. However, I have Xcode set an Exception Breakpoint for all ObjC exceptions, which is pretty useful when testing out an app in the debugger. As you now, now when I execute my test suite with ⌘U, now it stops at that test and looks like if it's failing, even

[基础]iOS 单元测试(一)入门与配置

こ雲淡風輕ζ 提交于 2020-11-29 02:01:46
所有文章目录: http://my.oschina.net/ChenTF/blog/677112 本篇文章地址: http://my.oschina.net/ChenTF/blog/677309 会持续的更新所有历史文章, 所以收藏的话请收藏上面的地址。 workspace — project — targets 讲解 一个工作空间可以包含多个项目,一个项目可以包含多个目标(生成物)。 一个项目中根据运行的targets不同,可以进行不同的编译设置,project是基础父类,targets是子类,targets的设置会覆盖project的设置。 Target与单元测试的关系 单元测试是在一个新的target上进行的设置,这样就不会影响程序开发,编译。 在XCode7中创建一个项目时默认是选中创建测试target的,如果没有,创建方法如下:File -> New -> target -> UITest/UnitTest,创建完成后会自动创建对应的文件夹。 UnitTest 使用该UnitTest测试一些代码逻辑,使用UITest测试UI的点击交互逻辑。 1.创建要测试的代码 2.创建测试类 说明: 任何测试类都需要继承自 XCTestCase 类 setUp,tearDown是系统默认方法 命名:测试的目标类名+Tests 3.编写测试方法 说明: 测试方法必须以testXXX开头

How to delete/reset an app from iOS 13 with XCTest?

扶醉桌前 提交于 2020-08-03 08:16:37
问题 Recently I started testing an iOS app using XCTest but I found some difficulties, the main difficulty was deleting or resetting the app content in each test class. I'm currently using XCode 11 and trying to delete/reset an app from iOS 13 for each test class, I've already tried: Delete app through springboard Delete app by going to the app settings This step is really important in my tests because in each test I need to create a profile and log in, so in the next test I need to have the app

UI testing fails with error “Failed to get snapshot within 15.0s”

冷暖自知 提交于 2020-05-08 17:23:32
问题 I am having a table view with a huge amount of cells. I tried to tap a particular cell from this table view. But the test ending with this error: Failed to get snapshot within 15.0s I assume that, the system will take snapshot of the whole table view before accessing its element. Because of the huge number of cells, the snapshot taken time was not enough (15 secs is may be the system default time). I manually set the sleep time / wait time (I put 60 secs). Still I can not access the cells

typeText() is typing inconsistent characters

喜你入骨 提交于 2020-04-18 06:09:40
问题 I'm beginning to dip my toes into Swift alongside writing UI tests and am having a problem with typing text into a textField. Below is the code: func testLoginUsernameField() { let app = XCUIApplication() app.launch() let username = "testusername2" let usernameField = app.textFields["username_field"] XCTAssertTrue(usernameField.exists) usernameField.tap() usernameField.typeText(username) XCTAssertEqual(usernameField.value as! String, username) } The problem occurs when I do usernameField

Use Xcode's Test Classes Assistant Editor with Swift Classes

若如初见. 提交于 2020-02-29 12:34:29
问题 When working in Xcode, it's often nice to pull up unit test cases in an assistant editor. Currently, I've been selecting the tests file manually, but I see the assistant editor has an option for Test Classes . I've tried to get this option to pull up my tests file automatically, but I can't seem to make it work. Is there some sort of configuration required for it? Does it just not work for swift projects? 回答1: The assistant editor can automatically open the companion file in many cases.