1

I'm using ocunit and I'm trying to verify I set the background image on a UITableView

In the test below my assertion is failing

- (void)testNumberOfRowsInSectionSetsBackgroundViewOnTableView
{
    UIImageView *expectedBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]];
    UITableView *tableView = [[UITableView alloc] init];
    [self.sut tableView:tableView numberOfRowsInSection:0];
    STAssertEqualObjects(tableView.backgroundView, expectedBackground, @"");
}

assertion error below

'<UIImageView: 0xe65c2a0; frame = (0 0; 0 0); opaque = NO; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0xe65cb40>>' should be equal to '<UIImageView: 0xe65bcf0; frame = (0 0; 320 480); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0xe65bd50>>'

The production code is below

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    [tableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]]]; //untested
    return [self.options count];
}

I'd like to just verify the png (not the entire UIImageView if that's possible)

Thank you in advance

Toran Billups
  • 27,111
  • 40
  • 155
  • 268

0 Answers0