I want to make test, but I do not know how to make it (I can use GHUnit).
This is the class I want to test:
Communicator.h
@interface Communicator : NSObject
-(void)loadURLWithString:(NSString*)urlString withWebView:(UIWebView*)webView;
@end
Communicator.m
#import "Communicator.h"
@implementation Communicator
##### I WANT TO EXCLUDE THE WEBVIEW BELOW #####
-(void)loadURLWithString:(NSString*)urlString withWebView:(UIWebView*)webView
{
NSURL *url = [[NSURL alloc] initWithString:urlString];
NSURLRequest *r = [[NSURLRequest alloc] initWithURL:url];
[webView loadRequest:r];
}
@end
And this is ViewController which control Communicator class.
ViewController.h
#import "Communicator.h"
@interface ViewController : UIViewController <UITextFieldDelegate>
{
Communicator *communicator;
}
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIButton *startButton;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
communicator = [[Communicator alloc] init];
[_startButton addTarget:self action:@selector(startButtonPushed) forControlEvents:UIControlEventTouchDown];
}
- (void)startButtonPushed
{
[communicator loadURLWithString:@"http://www.apple.co.jp" withWebView:_webView];
}
@end
Thank you for your help.