xctest

Writing a unit-test for a class extension in Swift

泪湿孤枕 提交于 2020-01-12 08:13:48
问题 I'm attempting to write a unit test for a class extension in Swift. The class extension itself will present a UIAlert with a specified title and message as such: extension UIViewController { func presentAlert(title: String, message : String) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert) alertController.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.Default, handler: nil)) UIApplication.sharedApplication().keyWindow?

Writing a unit-test for a class extension in Swift

旧街凉风 提交于 2020-01-12 08:13:30
问题 I'm attempting to write a unit test for a class extension in Swift. The class extension itself will present a UIAlert with a specified title and message as such: extension UIViewController { func presentAlert(title: String, message : String) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert) alertController.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.Default, handler: nil)) UIApplication.sharedApplication().keyWindow?

Unable to execute tests from command line via xcodebuild

笑着哭i 提交于 2020-01-12 02:49:13
问题 I am trying to build and run test cases using command line for iOS test cases. I have given the following command: xcodebuild -target AppEngineTests -configuration Debug -sdk iphonesimulator TEST_AFTER_BUILD=YES clean build It builds the app but the testcases are not run. could someone please help? Thanks 回答1: I've found the name property to require more specification. xcodebuild test -workspace #{WORKSPACE_FILE} -scheme #{TEST_SCHEME} -destination 'platform=iOS Simulator,name=iPhone Retina

Unable to execute tests from command line via xcodebuild

本小妞迷上赌 提交于 2020-01-12 02:48:06
问题 I am trying to build and run test cases using command line for iOS test cases. I have given the following command: xcodebuild -target AppEngineTests -configuration Debug -sdk iphonesimulator TEST_AFTER_BUILD=YES clean build It builds the app but the testcases are not run. could someone please help? Thanks 回答1: I've found the name property to require more specification. xcodebuild test -workspace #{WORKSPACE_FILE} -scheme #{TEST_SCHEME} -destination 'platform=iOS Simulator,name=iPhone Retina

Import XCTest into a dynamic framework

∥☆過路亽.° 提交于 2020-01-11 17:40:16
问题 I have a project where I have created a dynamic framework. Inside the framework itself, not the framework's tests, I have the following file: import Foundation import XCTest public func assertThrowsException(function: () throws -> Void) { XCTAssertTrue(doesItThrowException(function)) } public func assertDoesNotThrowsException(function: () throws -> Void) { XCTAssertFalse(doesItThrowException(function)) } private func doesItThrowException(function: () throws -> Void) -> Bool { do { let _ = try

XCTest UI tests: can not find collectionView within a table cell

血红的双手。 提交于 2020-01-11 11:42:09
问题 There is a cell contains a Collection View. I have set the cells within a Collection View using cell.accessibilityLabel = @"daren_shangjia_0001_add_new_photo_album"; and then in XCTest, I do print(app.debugDescription); I didn't see the accessibilityLabel that I have provided. Element subtree: →Application 0x608000367200: {{0.0, 0.0}, {414.0, 736.0}}, label: '纳豆行' Window 0x608000365e80: Main Window, {{0.0, 0.0}, {414.0, 736.0}} Other 0x608000365880: traits: 8589934592, {{0.0, 0.0}, {414.0,

XCTest UI tests: can not find collectionView within a table cell

爱⌒轻易说出口 提交于 2020-01-11 11:41:12
问题 There is a cell contains a Collection View. I have set the cells within a Collection View using cell.accessibilityLabel = @"daren_shangjia_0001_add_new_photo_album"; and then in XCTest, I do print(app.debugDescription); I didn't see the accessibilityLabel that I have provided. Element subtree: →Application 0x608000367200: {{0.0, 0.0}, {414.0, 736.0}}, label: '纳豆行' Window 0x608000365e80: Main Window, {{0.0, 0.0}, {414.0, 736.0}} Other 0x608000365880: traits: 8589934592, {{0.0, 0.0}, {414.0,

How to access Core Data generated Obj-C classes in test targets?

橙三吉。 提交于 2020-01-11 10:08:10
问题 I have a Core Data / Swift Cocoa application project in Xcode 6 (let's call the project Stuff ). I created a Core Data entity called Query and used Xcode to create an NSManagedObject subclass for it. At that point, Xcode 6 offered to create the bridging header for me, as expected, and created Stuff-Bridging-Header.h . Once I #import "Query.h" in the bridging header, then my model object Query is available in my app target Swift code. How do I make that Query Core Data object (backed by the

How can I delete Xcode test cases from the test case view?

爱⌒轻易说出口 提交于 2020-01-07 07:27:08
问题 Trying to figure out a way to delete a test case that I've added from within XCode and can't figure a way to do it. The obvious choice of using the delete key does nothing when pressed with the test case highlighted, there's no context option to delete the test case when right clicking on it. 回答1: Why you need to delete a test from the test case view? If you want to delete it means for me that you don't need this test anymore - if yes, remove it from the code. If you need it but not now click

XCTest: Crashing in XCTestExpectations in iOS

强颜欢笑 提交于 2020-01-06 20:23:19
问题 When I run my unit test scripts, it is crashing at ""waitForExpectationWithTimeout" in "ServiceTest" class. If I run test scripts for this "ServiceTest" class alone, then it is working properly without crash. But if I run test scripts for entire project, I am getting this crash. I am clueless on why and what this crash means. Appreciate any help. Thanks. 来源: https://stackoverflow.com/questions/33576790/xctest-crashing-in-xctestexpectations-in-ios