Monday 6 May 2013

Calabash-ios backdoor - A Magic way to set precondition in calabash - Be careful & choosy while using it

Lets looks at the Use of it

I had a test app for which i had to write tests but after each login, to logout I had to navigate 4-5 pages, This added extra overhead to my testing

Suppose i have 3 tests and second test fails without logging out I would never have starting point for my 3rd test and hence that would fail
I wanted a single start point from where I start my test each time. Thats when I decided to use calabash backdoor function.

Lets looks at changes first
  
1) Added below function delaration in app AppDelegate.m
This code will change for your application but the way of using it is similar.
In my case dev team member helped me with logout functionality

#pragma mark -
#pragma mark - Calabash Method
- (NSString *) calabashBackdoor:(NSString *)aIgnorable
{
    [[ONEApplication sharedInstance] logOut];
    AppDelegate* delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    [delegate showLoggedOutViewController];
   
    return aIgnorable;
}


2) Add declaration in AppDelegate.h
This can be kept as below or method name can be changed but method signature has to be maintained.
//Calabash Method
- (NSString *) calabashBackdoor:(NSString *)aIgnorable;

3) Now compile the Application
Time of verify changes are reflected or not



4) Deploy application , Launch calabash-ios console
run  'calabashBackdoor' command and this must be executed on the application

No comments:

Post a Comment