xctest

Unable to access Main Target Methods when Adding Tests to OSX Project in Swift

≡放荡痞女 提交于 2019-12-12 03:44:44
问题 I have tried adding a testing bundle to my Project which seems to have succeeded. However when I try to create instances of the Classes in my main project- I am unable to see them. The Project seems to build fine - but I can' instantiate any of the test objects Any ideas how to access them Example Class to Test: class EmailHelper: NSObject { func generateEmailBody (greeting: String, bodyContent: String) -> String { //Content goes in here return message } } import XCTest class MyProject

performTaskWithPathArgumentsTimeout in XCTest?

陌路散爱 提交于 2019-12-12 02:56:58
问题 Does the new way of UI testing with Xcode have a method like performTaskWithPathArgumentsTimeout? Ultimately, how can I Check Email during Xcode UI Testing? 回答1: It does not. I've scraped the framework's headers to put together some unofficial documentation and it's not present. 来源: https://stackoverflow.com/questions/35678717/performtaskwithpathargumentstimeout-in-xctest

Add xctest dependency to Xcode 7 project

徘徊边缘 提交于 2019-12-12 02:45:56
问题 Created a new OS X library project, deleted the Objective-C stubs and add a Swift file (Empty.swift). In the same directory, added a unit test (new->Unit Test), EmptyTest.swift. The code generated won't compile because this OS X library project doesn't know how to resolve the dependency to XCTest. XCTest is at this location /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/XCTest The solution for command line tools is here (How can I run XCTest for a swift

XCTests for SLComposeViewController

我与影子孤独终老i 提交于 2019-12-12 01:59:18
问题 i was trying to write unit test cases using XCTest for SLComposeViewController and couldn't find any solution so far.Any suggestion in terms of approach and code would be helpful. My objective is to test the below code using XCTest SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; SLComposeViewControllerCompletionHandler __block completionHandler = ^(SLComposeViewControllerResult result) { [tweetSheet

Unit testing asychronous UI code which does not know about XCTestExpectations?

谁说我不能喝 提交于 2019-12-12 01:55:26
问题 How can one go about unit-testing pieces of iOS code that work in a non-trivial graphical setup? Consider for instance view controllers A and B , where A stacks B on top with performSegueWithIdentifier:sender: . A unit test should check the behavior of a C that depends on the two view controllers being arranged like that. performSegueWithIdentifier:sender: works asynchronously, i.e. the unit test would end before it has completed its task unless one lets the unit test wait for something like

How to test launching a viewcontroller XCTest

て烟熏妆下的殇ゞ 提交于 2019-12-11 20:50:14
问题 I have a framework under test, I want to test a method from public interface which user will call to show a ViewController with xib, I want to unit test this situation using XCTest, call to the method which does above described thing looks like this testClass = [[AdGateMedia alloc] initWith:@"nac" and:@"1234" withParent:view]; [testClass showView]; The parent view controller is instance of calling view controller from host application which is using framework. When testing this parent

Should I refactor to be able to use mocking with XCTests?

旧巷老猫 提交于 2019-12-11 19:14:22
问题 I have a current codebase that has all of its functions in its view controllers. Meaning in the SignUpViewController, we have a signup function that does the signing up. Moreover, we also have a User model, but it does not have any member signup function. In order to use mocking and dependency injection during testing, should I refactor the code so that the User model has a signup member function, and the view controller's sign up function just receives a user object and calls the object's

How to test async functions in swift using XCTWaiter and exceptions

寵の児 提交于 2019-12-11 17:35:02
问题 I want to test asynchronous functions in Swift, hence as shown below, I created a XCTestExpectation and passed it on to an XCTWaiter . Now, irrespective if the expectation is fulfilled or not, I get a test ran successfully always . Can you point out what is wrong in the code. I followed exactly a blog which was made for Swift 3, however, I am running Swift 4. Is that the issue? func testAsyncFunction() { let expectation = XCTestExpectation(description: "Some description") vc.asyncFunction(5)

XCUITest Class teardown isnt deleting the app. But works if its instance teardown. What am I doing wrong?

无人久伴 提交于 2019-12-11 15:50:06
问题 I have a class teardown which is trying to remove the app, but it doesn't recognize app.terminate(). class DeviceSettingsUtilities : UITestUtilities { func removeApp(productName:String){ print("in teardown") let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") XCUIApplication().terminate() // this does nothing XCUIApplication(bundleIdentifier: "com.xxx.xxxx").terminate()//this does nothing too, but this works when called as an instance teardown sleep(5) springboard

Perform a full swipe left action in UI Tests?

谁说我不能喝 提交于 2019-12-11 15:14:31
问题 I have implemented leading and trailing swipe actions in a table view. Now, I'm trying to test them in XCTest UI tests. To test a regular swipe in either direction is easy: tableCell.swipeRight() tableCell.swipeLeft() Using one of these causes the 1st action button to be displayed, and I can then .tap() on the button. However, testing a full swipe is proving a little more challenging. I have played with this extension from How do I swipe faster or more precisely? I have also played with this