webdriverio-boneyard / wdio-junit-reporter

A WebdriverIO v4 plugin. Report results in junit xml format.
http://v4.webdriver.io
MIT License
11 stars 42 forks source link

fix a crash when using cucumber hooks #67

Closed Kignuf closed 7 years ago

Kignuf commented 7 years ago

Fixes a crash when using cucumber hooks (https://github.com/webdriverio/wdio-junit-reporter/issues/65)

Cucumber hooks will add an "undefined" test in suite.tests See following example:

suite.tests: { 'I launch app5':
   TestStats {
     type: 'test',
     start: 2017-07-03T14:54:12.771Z,
     _duration: 0,
     uid: 'I launch app5',
     title: 'I launch app',
     state: 'pass',
     screenshots: [],
     output: [] },
  'I click FB login6':
   TestStats {
     type: 'test',
     start: 2017-07-03T14:54:14.780Z,
     _duration: 0,
     uid: 'I click FB login6',
     title: 'I click FB login',
     state: 'pass',
     screenshots: [],
     output: [] },
  undefined:
   TestStats {
     type: 'test',
     start: 2017-07-03T14:54:16.248Z,
     _duration: 0,
     uid: 'undefined',
     title: undefined,
     state: '',
     screenshots: [],
     output: [] } }

This PR fixes the crash by verifying that the test is not undefined before doing anything with it.

Kignuf commented 7 years ago

Tests also fail locally with a clean clone of the repo. This is due to some linting errors that seem to have been made on purpose. I've run manually the non linting tests and they are all green.

Kignuf commented 7 years ago

Hello Christian, I just pushed a test, please let me know if that's fine for you.

Kignuf commented 7 years ago

I appologize for those mistakes. I've amended the last commit to remove the trailing spaces and the console.log.

Thanks a lot for your review Christian !

christian-bromann commented 7 years ago

@Kignuf last thing: could you please update your branch via rebase?

$ git checkout master
$ git pull origin master
$ git checkout fixUndefinedTestTitle
$ git rebase master
$ git push origin fixUndefinedTestTitle

Thanks

Kignuf commented 7 years ago

@christian-bromann It should be ok now

Kignuf commented 7 years ago

\o/ thanks Christian, that's awesome !