xctest

XCTest output to a file

心已入冬 提交于 2019-12-23 07:51:43
问题 I am able to run XCTests using xcodebuild test command. But when I run this command it outputs the build log and then there is log from test at the end. Is there a way where I can redirect only the output of test (no build logs) to a separate file? I couldn't find anything in xcodebuild command. Regards Dev 回答1: You can use ocunit2junit https://github.com/ciryon/OCUnit2JUnit to parse the build log output into junit xml for use with Jenkins. This works with XCTest as well. xcodebuild test

unexpected '@' in program in test target

独自空忆成欢 提交于 2019-12-23 04:29:31
问题 I have string constant declared as below. This code compilers in normal app debug and release target. But in app's test target (Ctrl + U), I got error that unexpected '@' in program in test target. Using xcode 7. Modules are enabled as answered in this question. HeaderA.h #define URL_A "http://www.example.com/service" HeaderB.h #define URL_AC @URL_A Got error here, unexpected '@' in program. Expanded from macro @URL_AC Modules are enabled as answered in this question. Used in an .m file as,

How to expose XCTestCases to external test bundles?

杀马特。学长 韩版系。学妹 提交于 2019-12-23 03:36:10
问题 I have a framework Whiteboard that encapsulates my business logic. I'm trying to keep my dependencies inverted and decoupled, so since Whiteboard depends on a repository, it declares a protocol WhiteboardRepository , and it expects clients that link against Whiteboard to supply an implementation of WhiteboardRepository . You can see this in the screen shot below. Note also the WhiteboardTests group, which includes a WhiteboardRepositoryTests class along with a WhiteboardRepositoryFake and its

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

好久不见. 提交于 2019-12-23 01:34:36
问题 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. 回答1: 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

Insert test data in Core Data

末鹿安然 提交于 2019-12-23 01:34:18
问题 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 . 回答1: You can use Valentina studio to open Core Data Model(SQLite file) and insert values. 回答2: I end up inserting the test data programatically in the test setup. 回答3: You can check this

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

梦想与她 提交于 2019-12-22 17:41:38
问题 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

XCode 7: Unable to Convert OCUnit to XCTest

北战南征 提交于 2019-12-22 10:34:18
问题 I upgraded the XCode to 7.0 and ran into compilation issues. XCode asked me to convert my test target to use XCTest and I followed the wizard screen. I'm unable to find any test targets and cannot finish converting. Does any one know how to fix this ? Thanks. 回答1: Make sure you have selected the scheme of your test target (in the top-left scheme selector), then select Edit -> Convert -> To XCTest... This will make Xcode recognize the appropriate target. 来源: https://stackoverflow.com/questions

XCTest & GPX Files: Can Location Updates Be Started Automatically?

血红的双手。 提交于 2019-12-22 06:22:58
问题 I have added a gpx file to my project; its name is TrailOfHistory.gpx. I have edited my project's scheme so that this file will be used by Xcode 9 to perform locations updates. Here are screen shots of the scheme's Run and Test configurations wherein I have designated that the gpx file should be used: When I run my application, user location updates (as given by the gpx file) begin automatically. I can watch this happening on my application's MKMapView. In contrast, when I run one of my unit

Xcode 7 UI Testing with Cocoapods fails on device

梦想的初衷 提交于 2019-12-22 04:29:18
问题 When trying to run my UI Tests on my device I get the error: XCTRunner[1476:104021] The bundle “AppUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2015-11-23 20:58:53.903 XCTRunner[1476:104021] (dlopen_preflight(/var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests.xctest/TrueMostUITests): Library not loaded: @rpath/UIColor_Hex_Swift.framework/UIColor_Hex_Swift

Can't use Swift classes inside Objective-C unit test

﹥>﹥吖頭↗ 提交于 2019-12-22 03:40:10
问题 I have followed this recipe in order to use a Swift class in an existing Objective-C project MyProject . That works fine. However, I'm still not able to use the same Swift class in the same project's unit tests. The compiler marks the line where my Objective-C unit test says #import "MyProjectTests-Swift.h" with file not found . If tried changing the test target's Product Module Name from its default MyProjectTests to MyProject as suggested in a comment to this (unanswered) question. However