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

Rework Browserstack service, improve Cucumber integration #5271

Merged
merged 12 commits into from
May 8, 2020

Conversation

nextlevelbeard
Copy link
Member

@nextlevelbeard nextlevelbeard commented Apr 15, 2020

Proposed changes

Reworks BrowserStack service way of handling failures

  • No longer using a failure counter:
    • directly uses after hooks' result code to measure failure as it is more accurate
    • exception being onReload which has no choice but to update session status by evaluating number of failure reasons

Mocha / Jasmine

  • Initial session name is now the top-level Suite' name (if it exists)
  • If there is no top-level Suite, session name is the default sessionId
  • Keeps old behaviour: at the end of the session, the name is updated to the last test's name

Improves Cucumber integration:


For 2 Sessions, same Cucumber feature, different Scenarios:

preferScenarioName = false
image

preferScenarioName = true, on session start has feature name
2 sessions 1 scenario each feature on start

preferScenarioName = true, on session end has scenario name
2 sessions 1 scenario each feature on end


Single reasons for failure (i.e. 1 test failed)
pending scenario reason
custom error reason
fail reason timeout
Reason when multiple tests fail
multiple errors reason

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make these modifications also in the Sauce, Testingbot and Crossbrowsertesting service?

packages/wdio-browserstack-service/src/service.js Outdated Show resolved Hide resolved
packages/wdio-browserstack-service/src/service.js Outdated Show resolved Hide resolved
packages/wdio-browserstack-service/README.md Outdated Show resolved Hide resolved
@esaari
Copy link
Contributor

esaari commented Apr 17, 2020

@nextlevelbeard I can provide you an example curl request that will return a session status: of timeout. I tried DM'ing you on gitter, but here is a partial response object (omitted most of it due to PII) with a status of timeout:

{"automation_session":{"name":"","duration":375,"os":"Windows","os_version":"10","browser_version":"80.0","browser":"chrome","device":null,"status":"timeout","hashed_id":"f360634511258f578d9e5d9cd9ad1563db887d3b","reason":"TIMEOUT","build_name": ... }

I realize their own documentation says passed or failed but they're documentation isn't always accurate. I've brought this to their attention.

@goatsy
Copy link
Contributor

goatsy commented Apr 23, 2020

@nextlevelbeard Is this issue here also related with the problem that all API-Status marked with

Status
Failed
(Marked via REST API : Unknown Error)

image

@nextlevelbeard nextlevelbeard changed the title Improve Cucumber integration with BrowserStack Rework BrowserStack failure handling, Improve Cucumber integration Apr 25, 2020
@nextlevelbeard
Copy link
Member Author

Can we make these modifications also in the Sauce, Testingbot and Crossbrowsertesting service?

I can but it should be out of scope of this PR, don't you agree?

@nextlevelbeard nextlevelbeard marked this pull request as ready for review April 25, 2020 21:23
@nextlevelbeard
Copy link
Member Author

@nextlevelbeard Is this issue here also related with the problem that all API-Status marked with

Status
Failed
(Marked via REST API : Unknown Error)

image

Not quite sure but this PR is redefining failure, shouldn't report any false failures like that, no.

@nextlevelbeard
Copy link
Member Author

@christian-bromann tests run locally just fine, do you have an idea why CI is failing here?

@christian-bromann
Copy link
Member

tests run locally just fine, do you have an idea why CI is failing here?

@nextlevelbeard the error is caused by this line: https://github.com/webdriverio/webdriverio/pull/5271/files#diff-540108e09662df242d6404527d1597ddR96

@nextlevelbeard
Copy link
Member Author

@nextlevelbeard the error is caused by this line: https://github.com/webdriverio/webdriverio/pull/5271/files#diff-540108e09662df242d6404527d1597ddR96

Should be taken care of.

@nextlevelbeard nextlevelbeard changed the title Rework BrowserStack failure handling, Improve Cucumber integration Rework @wdio/browserstack-service failure handling, improve Cucumber integration Apr 26, 2020
}
}

async onReload(oldSessionId, newSessionId) {
this.sessionId = newSessionId
await this._update(oldSessionId, this._getBody())
this.failures = 0
await this._update(oldSessionId, { name: this.fullTitle })
Copy link
Member

@erwinheitzman erwinheitzman Apr 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are the status and reason updated in this case?

Copy link
Member Author

@nextlevelbeard nextlevelbeard Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwinheitzman @christian-bromann
We should update everything, ideally it would execute after for oldSessionId.
I took a look at the Sauce service:

this.failures = 0 // counts failures between reloads

apparently the whole raison d'être for the failure counter (which this PR removes) is so that onReload hook can report on the ending session' status

We don't have any session results exposed on onReload, we would ideally use what is later given in after hook. Would it make sense to expose some results on the onReload hook along with oldSessionId and newSessionId? Something like

    onReload: function(oldSessionId, result, newSessionId) {
    ...
    },

Illustrating the problem:

it("Test that runs first", () => throw new Error('I fail!')) // sessionId 1 will fail
it("Test that runs second", () => {
    console.log("I am running on session 1")
    browser.reloadSession() // We should update session 1 with status "failed"
    // but there's no session 1 results exposed in `onReload`
    // every service has to count failures so far (with varying degrees of success)
    return true // session 2 passes and `after` will update the status accordingly
})

Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good but I left some remarks and concerns, thank you for the PR 👍

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, please address @erwinheitzman comments and we can ship this. Thanks!

@nextlevelbeard
Copy link
Member Author

nextlevelbeard commented Apr 30, 2020

#5271 (comment)

^ Making this more visible.
Would appreciate some guidance from the devs about what to do here for onReload.
I see two options:

  • exposeresult for the old session in onReload hook, use it to report the status (out of scope)
  • reintroduce the failure counter and use it to report the status but keep the added features and bug fixing of this PR

@nextlevelbeard nextlevelbeard changed the title Rework @wdio/browserstack-service failure handling, improve Cucumber integration Rework Browserstack service, improve Cucumber integration May 7, 2020
@nextlevelbeard
Copy link
Member Author

Should be good to go, OP updated.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@erwinheitzman some last comments?

@nextlevelbeard
Copy link
Member Author

nextlevelbeard commented May 7, 2020

Addressed one last thing about destructing parameters.

Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the awesome work you put into this 👍

@christian-bromann christian-bromann added the PR: Polish 💅 PRs that contain improvements on existing features label May 8, 2020
@christian-bromann christian-bromann merged commit 85ee21d into webdriverio:master May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Polish 💅 PRs that contain improvements on existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants