ocunit

How to verify a partial mock has a base method invoked with args using ocmock?

只谈情不闲聊 提交于 2019-12-11 07:48:22
问题 I'm working with a very simple web service that uses a base class to reuse some commonly used functionality. The main method under test simply builds a url and then it uses a super / base method with this argument. - (void)getPlacesForLocation:(Location *)location WithKeyword:(NSString *)keyword { NSString *gps = [NSString stringWithFormat:@"?location=%@,%@", location.lat, location.lng]; NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@%@", self.baseurl, gps]]; [super

OCUnit will not allow me to use my own data types

微笑、不失礼 提交于 2019-12-11 07:15:48
问题 I am using XCode 3.2.2 to unit test some custom data types. The tests run properly without those data types, but when I use said data types, I get this error: "_OBJC_CLASS_$_classname", referenced from: (where "classname" is the, well, class name...) I have seen hints online that it could be linker related. The strange thing is, I originally followed these instructions http://www.mobileorchard.com/ocunit-integrated-unit-testing-in-xcode/ and they worked for me the first time I tried them. Now

OCUnit tests not running / not being found

心已入冬 提交于 2019-12-11 06:34:59
问题 I'm trying to get to grips with OCTest, but can't seem to get it to actually run my tests (at least, I believe it's not running my tests). I've set up a project as described in the developer documentation, and added a class called UnitTests which contains the following function: -(void)testFailures { STFail(@"A message"); } When I build the test bundle (in Debug or Release), the Build Results panel shows briefly that it's running the unit tests (it says something like 'Running unit tests for

Mach-O Linker Error When Adding Unit Tests - XCode

▼魔方 西西 提交于 2019-12-10 21:52:14
问题 I'm trying to add OCUnit tests to an existing project (in XCode 4.6.3). I followed the instructions here - http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/ however I'm getting 78 Mach-O errors only when trying to run the tests. I can compile the main target just fine. One thing to note I have not modified the tests yet, they are just the standard template. I'm not sure example what I'm doing wrong. One error message Undefined symbols for architecture i386:

How do I run a subset of OCUnit tests in Xcode

我怕爱的太早我们不能终老 提交于 2019-12-10 20:26:06
问题 I have a suite of unit tests that I use before checking in my project. However, very often it's the case that only one of them finds some regression in the code. In these cases I'd like to only run that particular unit test while debugging the failure. I haven't found any way to do this in Xcode. Is it possible? 回答1: If you're happy restricting your testing to a single test class, a simple option is to create a second test target (duplicate the existing target, change the product name and

OCMock for iPhone (iOS4, XCode 3.2.3)

£可爱£侵袭症+ 提交于 2019-12-10 19:13:58
问题 I have the last version of OCMock (1.55) and XCode 3.2.3. I have created a test bundle target in my project. What is the best way to use OCMock in my tests? When I add OCMock.framework to the test bundle, this build error appears: "_OBJC_CLASS_$_OCMockObject", referenced from: objc-class-ref-to-OCMockObject in NotificationTests.o ld: symbol(s) not found collect2: ld returned 1 exit status 回答1: I had the same problem, here is how i solved it : Delete ocmock.framework, the copy file phase, and

Simplified asserts in OCUnit

烂漫一生 提交于 2019-12-10 10:08:27
问题 I just started jusing OCUnit and find the asserts a bit cumbersome. In JUnit I can write a test to compare numbers like below. This test will obviously fail, but this shows the nice, simple assert I can write for two numbers and the feedback I get: "expected <2> but was <3>" with very little code. What I tried so far i XCode is: Which works, but is not as elegant as JUnit. Do you know if it exists assertion macros alà JUnit for XCode (OCUnit)? Also, is it possible to get the red/green bar in

cannot stub class method with OCMock 2.1+ in Xcode 5.0

懵懂的女人 提交于 2019-12-10 08:11:51
问题 I know that OCMock version 2.1+ supports stubbing class methods out of the box. But for some reason it's not working with me. To make sure I isolated the problem, I simply cloned the example OCMock project (which is clearly marked as version 2.2.1) and simply added this inside testMasterViewControllerDeletesItemsFromTableView: id detailViewMock = [OCMockObject mockForClass:[DetailViewController class]]; [[[detailViewMock stub] andReturn:@"hello"] helloWorld]; in DetailViewController.h I added

TDD: Unit Testing Asynchronous Calls

…衆ロ難τιáo~ 提交于 2019-12-06 09:55:42
guys: I'm working on an application, and building it with unit testing. However, I'm now in a situation where I need to test asynchronous calls. For example, - (void)testUserInfoBecomesValidWhenUserIsBuiltSuccessfully { if ( ![userBuilder userInfoUpToDate] ) { [userBuilder buildUser]; } STAssertTrue([userBuilder userInfoUpToDate], @"User information is not valid before building the user"); } What is the general practice for testing such things? userInfoUpToDate is expected to be updated asynchronously. Thanks! William Sometimes there is a temptation to test things which you don't usually test

XCode 7: Unable to Convert OCUnit to XCTest

夙愿已清 提交于 2019-12-05 23:40:16
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. 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/32707166/xcode-7-unable-to-convert-ocunit-to-xctest