-
Notifications
You must be signed in to change notification settings - Fork 742
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
EarlGrey() has wrong line number for page objects #95
Comments
This particular feature is about highlighting the EarlGrey invocation in the test code which led to the failure. This is an interesting use case and will fail the same way for the Objc version as well. Even though Objc can rely on macro expansion to include file and line# alongside the original method calls it would require us to define a macro for each top-level API and sub-APIs which can be called from those top-level APIs. Perhaps we need to rethink this. |
This seems to be fixed by the above PR. @bootstraponline please close this or update it in case this is still present. |
// Use to report errors on the correct file/line
public func grey_invokedFromFile(_ file:StaticString, _ line:UInt) {
EarlGreyImpl.invoked(fromFile: file.description, lineNumber: line)
} I still have to use ^ throughout the code to get accurate file & line numbers. If that's the best we can do for Swift, then this issue is safe to close. |
@bootstraponline sorry, but how does this affect your final API? Do you have to add |
It looks like this using the page object pattern. // swift 3
private static var loginButton: GREYElementInteraction {
return EarlGrey.select(elementWithMatcher: grey_accessibilityID("login_button"))
}
static func tapLoginButton(_ file: StaticString = #file, _ line: UInt = #line) {
grey_invokedFromFile(file, line)
loginButton.perform(grey_tap())
}
func testLoginPage_loginSuccessful() {
loginPage.tapLoginButton()
} |
In
EarlGrey.swift
, EarlGrey is defined as:I define a login page object:
which is then used:
The line number is wrong because
EarlGrey()
sets it to be on theEarlGrey().selectElementWithMatcher...
line.I've had to update
EarlGrey.swift
like this:and update the page object:
now the line number is correctly identified in the test. Thoughts on how to best update
EarlGrey.swift
to handle this use case?The text was updated successfully, but these errors were encountered: