Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:44:06+00:00 2026-06-14T03:44:06+00:00

Not sure if I’m using OCMocks correctly, or if it’s because I’m using the

  • 0

Not sure if I’m using OCMocks correctly, or if it’s because I’m using the cocoapods version and not the .lib file.

Here’s the test(s)

#import "MWViewControllerTests.h"
#import "MWViewController.h"
#import "OCMockObject.h"
#import "MWGoogleTrends.h"
#import "OCMockRecorder.h"

@implementation MWViewControllerTests {

    MWViewController *vcSUT;
    id googleTrends;
    NSArray *trends;
}

- (void)setUp
{
    [super setUp];
    vcSUT = [[MWViewController alloc] init];
    googleTrends = [OCMockObject mockForClass:[MWGoogleTrends class]];
    vcSUT.googleTrends = googleTrends;
    trends = [[NSArray alloc] initWithObjects:@"trend1", @"trend2", @"trend3", nil];
    [[[googleTrends stub] andReturn:trends] getLatestTrends];
}

- (void)tearDown
{
    // Tear-down code here.
    [super tearDown];
}

- (void)test_ViewDidLoadShouldCallGoogleTrends_getLatestTrends
{
    [[googleTrends expect] getLatestTrends];
    [vcSUT view];  // calls loadView
    [googleTrends verify];
}

@end

Here’s the VC:

@implementation MWViewController {

    NSArray *_trends;
}

@synthesize googleTrends;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _trends = [self.googleTrends getLatestTrends];
}

The googleTrends is a property in the header of course:

 @property (nonatomic, strong) MWGoogleTrends *googleTrends;

I would imagine it’s being invoked because the following tests below it are passing:

- (void)test_numRowsInTableViewShouldBeNumOfTrendsReturnedFromGetLatestTrends {

    [vcSUT view];
    int numSections = [vcSUT tableView:nil numberOfRowsInSection:0];
    STAssertEquals(numSections, 3, @"should be 3 sections");
}

- (void)test_cellForRowAtIndexPath_should_return_cell_with_trendName_as_text {

    [vcSUT view];
    UITableViewCell *cell1 = [vcSUT tableView:nil cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    UITableViewCell *cell2 = [vcSUT tableView:nil cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1]];
    UITableViewCell *cell3 = [vcSUT tableView:nil cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:2]];

    STAssertEquals(cell1.textLabel.text, @"trend1", @"cell text should be correct trend name");
    STAssertEquals(cell2.textLabel.text, @"trend2", @"cell text should be correct trend name");
    STAssertEquals(cell3.textLabel.text, @"trend3", @"cell text should be correct trend name");
}

@end

also getting this warning from the compiler, not sure if it related in any way:

ld: warning: directory not found for option '-L/Users/markw/Projects/XCode/OReillyCasts/MWGoogleTrends/Pods/build/Release-iphoneos'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:44:07+00:00Added an answer on June 14, 2026 at 3:44 am

    Yes, the issue is with stubbing the method.

    I had to stub the method on the mock only for the test methods that needed the stub, the expectation passes when I took out the stubbing from the Setup.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if this belongs here because its not technically a 'programming' question, but
Not sure whats going on here, or what could be the integer in this
Not sure if im just being stupid or something but here goes i work
not sure what I'm missing here, but i keep getting the error. SQLSTATE[HY093]: Invalid
Not sure if this is the correct Stack Exchange website but here goes.. A
Not sure this is a known issue. I’m using VS2012 RC (Ultimate), and Win8
Not sure if i'm taking the right approach here. I've set up various controller
not sure what i'm missing, but here ti go's: i have a floating left
Not sure whether this should be asked here or on another site such as
Not sure what I'm doing wrong, but here is the code 1: var currDoc:NotesDocument

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.