Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create page objects with KIF #853

Closed
Przemyslaw-Wosko opened this issue May 10, 2016 · 8 comments
Closed

Create page objects with KIF #853

Przemyslaw-Wosko opened this issue May 10, 2016 · 8 comments

Comments

@Przemyslaw-Wosko
Copy link

Hi, i wanted to create PageObjects with KIF, so i extended KIFTestActor and create helpers for each sceen in app.
Now the problem is that every exception make crash.
How should i init objects that inherit from KIFTestActor?

@phatmann
Copy link
Contributor

Can you share some code? I have done something similar in the past and I had no issues like this,

@Przemyslaw-Wosko
Copy link
Author

let's say we have Login screen to test, so i would like to create LoginPageObject

@interface LoginPageObject : KIFTestActor
- (void)loginTap;
@end
@implementation LoginPageObject
- (void)loginTap {
    [tester tapViewWithAccessibilityLabel:@"Login_button"]; // just simple code to clarify the problem
}
@end

i created this class with [LoginPageObject new]
and now, when view is not present on the screen, exception crash test and test failure hint is not showing up in tests file. latter i tried initWithFile:atLine:delegate but it's hard to find line when somethings goes wrong with test case.

i managed to fix this by using "tester-like" macro, placed in LoginPageObject:

#define login KIFActorWithClass(LoginPageObject)

now it seems to be work fine, but i don't want to invoke methods on macro

@phatmann
Copy link
Contributor

This was "fixed" by #849, which basically forces you to use the macro approach. So your workaround is correct.

I am hoping we can get rid of the macros at some point. But for now we are stuck with them.

@Przemyslaw-Wosko
Copy link
Author

for that, entire exception handling mechanism would have to change, now i'm aware of this.
i will try to make pull request with better solution ;)

@phatmann
Copy link
Contributor

If you can find a macro-less solution that @bnickel approves of, you will be the new KIF hero :-)

@Przemyslaw-Wosko
Copy link
Author

Just update for those that want to make Page Object before kif refactor - the workaround i made seems to be working for KIF, but don't work for OCMockito, xcode just mark line that failed in PageObject class, in tests it's not visible

@phatmann
Copy link
Contributor

Thanks for the update.

@setv-n13
Copy link

Is it possible to make something similar in Swift (since there are no macros in Swift)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants