Questions tagged [ochamcrest]

Hamcrest for Objective-C: Powerful, combinable, extensible matchers for verification

18 questions
6
votes
2 answers

Some verification involving block methods and OCMockito

I'm using OCMockito and I want to test a method in my ViewController that uses a NetworkFetcher object and a block: - (void)reloadTableViewContents { [self.networkFetcher fetchInfo:^(NSArray *result, BOOL success) { if (success) { …
Juan Herrero Diaz
  • 833
  • 1
  • 7
  • 17
4
votes
1 answer

Verify method call with a handle argument on an OCMockito mock

I have an OCMockito mock of a class QuestionBuilder with the method questionsFromJSON:error:. This method accepts a handle (NSError **)error as an argument. How do I verify the method was called? I’ve tried: [verify(builder)…
Endersstocker
  • 1,061
  • 9
  • 26
2
votes
0 answers

Running unit test to see if UIButton is connected to IBAction via Storyboard

I am trying to create some tests in Xcode for my view controllers, including tests to check IBOutlets and IBActions. These work fine if I am using a basic view controller + xib file, but if I use a Storyboard file then the actions don't appear to be…
jowie
  • 8,028
  • 8
  • 55
  • 94
2
votes
2 answers

iOS/Mac OS fluent matching framework that works with Swift?

Is there a fluent matching API that works for Swift code? The leading Objective-C matcher candidates seem to be OCHamcrest and Expecta, both of which rely on complex macros that (as per the docs) aren't available to Swift code, e.g. #define…
David Moles
  • 48,006
  • 27
  • 136
  • 235
2
votes
1 answer

Verify method call with OCMockito

I have these two methods in a ClassA -(IBAction)onSubmit; -(void)validateName:(NSString*)name; @Implementation - (IBAction)onSubmit { [self validateName:self.textfield.text]; } -(void)validateName:(NSString*)name{ // do something } My…
Bach
  • 2,684
  • 5
  • 26
  • 36
2
votes
1 answer

How to set expectations on parameters to mocked methods in Kiwi

Using OCMockito and OCHamcrest, I can set up expectations on the arguments to mocked methods, thusly: [verify(aMockObject) doSomething:allOf(is(instanceOf([NSArray class])), hasCountOf(3U), nil)]; There doesn't seem to be an equivalently simple way…
Cris
  • 1,939
  • 3
  • 23
  • 37
1
vote
2 answers

Adding OCHamcrest to an IOS Project

The documentation for the project says just add the framework and the linker flags and you are good to go. Hours and hours of wasted time later, I have figured out that that's not true. If you do that, the project does not see the header files. You…
Rob
  • 11,446
  • 7
  • 39
  • 57
1
vote
2 answers

Using OCMockito to mock methods that are void

In using OCMockito, the below works great: DSAPIManager *mockAPIManager = mock([DSAPIManager class]); [given([mockAPIManager initWithBaseURL:[mockAPIManager baseURL]]) willReturn:[DSAPIManager sharedAPIManager]]; However when I try the same thing…
Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83
1
vote
1 answer

Getting runtime exception while unit testing UIDatePicker ([UIPickerColumnView isDragging:] unrecognized selector)

I created a UIViewController with a UIDatePicker outlet, corresponding nib file, and correctly set the outlet in interface builder. I'm trying to run the following unit test (using OCHamcrest matcher library). -…
AnthonyMDev
  • 1,496
  • 1
  • 13
  • 27
1
vote
0 answers

Custom OCHamcrest matcher with a primitive function argument

I'm trying to write my own HCMatcher that I can use to simply some assertions when working with a collection of objects. Currently my test method is doing this: __block int totalNumberOfCells = 0; [configurations…
lukestringer90
  • 492
  • 7
  • 16
1
vote
0 answers

Returning custom description and debugDescription values for mock objects

I frequently use OCMock with the excellent OCHamcrest matchers. But I often encounter test failure messages that aren't as helpful as they could be. This is because the OCHamcrest output relies heavily on the value returned by the "description"…
Kris Schultz
  • 606
  • 1
  • 5
  • 9
1
vote
1 answer

Custom OCHamcrest matcher for OCMockito mock verfication

I am using OCHamcrest and OCMockito for unit testing an iOS project. I'm working my way toward understanding using custom matchers in a mock verification of a method expectation that takes parameters. In particular, I want to verify one of the…
GarlicFries
  • 8,095
  • 5
  • 36
  • 53
1
vote
1 answer

OCHamcrest matcher parameter is incompatible with Mockito mock at Verify

with the following unit test I'm using Mockito to mock NSUserDefaults but when I try to verify using OCHamcrest matcher to test that the param is an instance of an NSDictionary I get the warning: Sending 'id{HCMatcher}' to parameter of incompatible…
stan4th
  • 710
  • 1
  • 6
  • 19
1
vote
1 answer

ios TDD with Kiwi, OCHamcrest and OCMockiti, can they be mixed?

Has anyone successfully got OCHamcrest working with Kiwi? I have started a Kiwi project then I added OCHamcrest framework and got a successful build. However when I tried to assert a condition in my Kiwi test file using hamcrest: it(@"has 3…
Armin
  • 1,367
  • 1
  • 12
  • 17
0
votes
1 answer

OCMockito / OCHamcrest verify array contains object property

I'm creating an application which adds some local notifications. This is my test - (void)testFirstLogin { //some initials array NSArray *withoutFriends = @[@"a", @"b", @"c", @"e", @"f"]; NSArray *withFriends = @[@"v", @"w", @"x", @"y", @"z"]; //my…
milczi
  • 7,064
  • 2
  • 27
  • 22
1
2