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

wdio-junit-reporter: include before and after all failures #3993

Merged
merged 1 commit into from
May 21, 2019
Merged

wdio-junit-reporter: include before and after all failures #3993

merged 1 commit into from
May 21, 2019

Conversation

mgrybyk
Copy link
Member

@mgrybyk mgrybyk commented May 20, 2019

Proposed changes

Capture before all and after all failures as test failures in junit-reporter.

Fix #3517

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)

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)

Further comments

Reviewers: @webdriverio/technical-committee

@codecov
Copy link

codecov bot commented May 20, 2019

Codecov Report

Merging #3993 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3993      +/-   ##
==========================================
+ Coverage   99.04%   99.04%   +<.01%     
==========================================
  Files         157      157              
  Lines        3462     3466       +4     
  Branches      766      767       +1     
==========================================
+ Hits         3429     3433       +4     
  Misses         28       28              
  Partials        5        5
Impacted Files Coverage Δ
packages/wdio-junit-reporter/src/index.js 97.82% <100%> (+0.2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2b9342...a858165. Read the comment docs.

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label May 21, 2019
@christian-bromann christian-bromann merged commit dc6f405 into webdriverio:master May 21, 2019
@mgrybyk mgrybyk deleted the fix-junit-all-hooks branch May 21, 2019 07:36
@helloitsdave
Copy link

helloitsdave commented May 30, 2019

Hi folks. I had been having this exact problem and just updated to @wdio/junit-reporter": "^5.9.3"

For me this doesn't appear to have resolved the issue.

I still end up with an empty report

Example test


import { expect } from 'chai'

before('Launch', () => {
  browser.navigateTo('http://www.google.com')
  expect(true).to.be.false
})

describe('Test', () => {
  it('anything', () => {
    console.log('Test')
  })
})

Dependancies

"devDependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.5",
    "@babel/preset-env": "^7.4.5",
    "@babel/register": "^7.4.4",
    "@wdio/cli": "^5.9.4",
    "@wdio/junit-reporter": "^5.9.3",
    "@wdio/sync": "^5.9.4",
    "babel-eslint": "^10.0.1",
    "config": "^3.1.0",
    "eslint": "^5.16.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-config-prettier": "^4.3.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.17.3",
    "eslint-plugin-lodash": "^5.1.0",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-wdio": "^5.7.8",
    "moment": "^2.24.0",
    "prettier": "^1.17.1"
  },
  "dependencies": {
    "@applitools/eyes.webdriverio": "^2.5.1",
    "@wdio/dot-reporter": "^5.9.3",
    "@wdio/local-runner": "^5.9.4",
    "@wdio/mocha-framework": "^5.9.4",
    "@wdio/selenium-standalone-service": "^5.9.3",
    "@wdio/spec-reporter": "^5.9.3",
    "chai": "^4.2.0",
    "chromedriver": "^74.0.0",
    "randomatic": "^3.1.1",
    "webdriverio": "^5.9.4"
  }

Just wondering if anyone else still has the issue?

<testsuites/>

@mgrybyk
Copy link
Member Author

mgrybyk commented May 31, 2019

@helloitsdave move before block inside describe

@helloitsdave
Copy link

helloitsdave commented May 31, 2019

Thanks @mgrybyk

I've tried that and as a workaround it does create the junit file as expected.

The downside is that it makes the tests slightly less readable when there are multiple describes in a test as whole thing needs to be wrapped in a parent describe, in order to have a before outside of the individual tests. For example, if my login fails in the before I don't want any of the other describes executed.

Before on wdio v 4

before('Login', () => {
  console.log('Login')
})

describe('Controls', () => {
  it('should load', () => {
    console.log('Do not what to run if login fails')
  })
})

describe('Video', () => {
  before('Click Video Link', () => {
    console.log('Click Video')
  })
  it('should load', () => {
    console.log('Do not what to run if login or video link click fails')
  })
})

after('Logout', () => {
  console.log('Logout')
})

Now on wdio v5

describe('Video Test', () => {
  before('Login', () => {
    console.log('Login')
  })
  describe('Controls', () => {
    it('should load', () => {
      console.log('Do not what to run if login fails')
    })
  })
  describe('Video', () => {
    before('Click Video Link', () => {
      console.log('Click Video')
    })
    it('should load', () => {
      console.log('Do not what to run if login or video link click fails')
    })
  })
  after('Logout', () => {
    console.log('Logout')
  })
})

yamkay pushed a commit to MoveInc/webdriverio that referenced this pull request Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bug Fix 🐛 PRs that contain bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

beforeAll and afterAll (mocha + chai) failures are not captured in report
4 participants