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

xunit reporter does not report <testcase /> #1864

Closed
aaronabramov opened this issue Sep 5, 2015 · 10 comments · Fixed by gluckgames/pixi-packer#17
Closed

xunit reporter does not report <testcase /> #1864

aaronabramov opened this issue Sep 5, 2015 · 10 comments · Fixed by gluckgames/pixi-packer#17

Comments

@aaronabramov
Copy link

currently Xunit reporter only reports the top

<testsuite name="Mocha Tests" tests="16" failures="0" errors="0" skipped="0" timestamp="Fri, 04 Sep 2015 23:05:49 GMT" time="0.043">`

but not the child test cases
something that i would expect is:

<testsuite name="Mocha Tests" tests="16" failures="0" errors="0" skipped="0" timestamp="Fri, 04 Sep 2015 23:35:14 GMT" time="0.043">
  <testcase classname="case1" name="abc" time="0.2"/>
  <testcase classname="case2" name="cde" time="0.1"/>
</testsuite>

is there a reason for it?

@boneskull
Copy link
Contributor

quite possible it's broken since we don't have good tests for the reporters

@igl
Copy link

igl commented Sep 5, 2015

yep. since i upgraded mocha from 2.2.4 to 2.3.0.

using:

--reporter xunit --reporter-options output=build/testreport-integration.xml

only writes the first line:

<testsuite name="Mocha Tests" tests="242" failures="0" errors="0" skipped="21" timestamp="Fri, 04 Sep 2015 18:55:09 GMT" time="25.353">

@thefotios
Copy link

Just to help confirm this.

Stupid simple test file

> cat test.js
describe('my test', function() {
    it('should pass', function(done) {
        done();
    });

    it('should fail', function(done) {
        done(new Error('fail'));
    });
});

Works as expected in 2.2.5

> mocha --version
2.2.5

> mocha --reporter=xunit test.js
<testsuite name="Mocha Tests" tests="2" failures="1" errors="1" skipped="0" timestamp="Wed, 09 Sep 2015 18:29:50 GMT" time="0.006">
<testcase classname="my test" name="should pass" time="0.001"/>
<testcase classname="my test" name="should fail" time="0"><failure><![CDATA[fail
Error: fail
    at Context.&lt;anonymous&gt; (test.js:7:8)]]></failure></testcase>
</testsuite>

> mocha --reporter=xunit --reporter-options output=results.xml test.js; cat results.xml
<testsuite name="Mocha Tests" tests="2" failures="1" errors="1" skipped="0" timestamp="Wed, 09 Sep 2015 18:29:56 GMT" time="0.007">
<testcase classname="my test" name="should pass" time="0.001"/>
<testcase classname="my test" name="should fail" time="0"><failure><![CDATA[fail
Error: fail
    at Context.&lt;anonymous&gt; (test.js:7:8)]]></failure></testcase>
</testsuite>

But not 2.3.0

> mocha --version
2.3.0

> mocha --reporter=xunit test.js
<testsuite name="Mocha Tests" tests="2" failures="1" errors="1" skipped="0" timestamp="Wed, 09 Sep 2015 18:31:10 GMT" time="0.007">
<testcase classname="my test" name="should pass" time="0.001"/>
<testcase classname="my test" name="should fail" time="0"><failure><![CDATA[fail
Error: fail
    at Context.&lt;anonymous&gt; (test.js:7:8)]]></failure></testcase>
</testsuite>

> mocha --reporter=xunit --reporter-options output=results.xml test.js; cat results.xml                                                           
<testsuite name="Mocha Tests" tests="2" failures="1" errors="1" skipped="0" timestamp="Wed, 09 Sep 2015 18:31:12 GMT" time="0.007">

@danielstjules
Copy link
Contributor

oops, spammed this issue a bit while working on the test for the PR 😅

danielstjules added a commit that referenced this issue Sep 9, 2015
Fix #1864: xunit missing output with --reporter-options output
@danielstjules
Copy link
Contributor

Fixed via #1878 :)

@aaronabramov
Copy link
Author

sweet. thanks!

@igl
Copy link

igl commented Sep 9, 2015

👍 thank you

kevinawoo added a commit to kevinawoo/mocha that referenced this issue Oct 6, 2015
* master: (25 commits)
  Fix mochajs#1798: Correctly attribute mutiple done err with hooks
  Remove redundant harmony flag
  Cast non-string return values from err.inspect()
  Call the inspect() function if message is not set
  Revert jade to support npm < v1.3.7
  Fix eqeqeq linting errors from eslint 1.4.0 release
  Fix mochajs#1669: catch uncaught errors outside test suite execution
  Support all harmony flags
  Fix fragile xunit reporter spec
  Fix linter warning "Expected a conditional expression and instead saw an assignment"
  Stackfilter fix: Don't remove modules/components from stack trace in the browser
  Fix mochajs#1864: xunit missing output with --reporter-options output
  Fix 1875: Markdown reporter exceeds maximum call stack size
  IE<=8 no [].reduce, so use 'utils.reduce' instead
  Release v2.3.2
  remove lodash.create; closes mochajs#1868
  update package.json & component.json for v2.3.1
  update HISTORY.md
  fix package.json to use exact version of lodash; closes mochajs#1867
  Fix: Bail flag causes before() hooks to be run even after a failure
  ...

# Conflicts:
#	lib/runnable.js
@wip0
Copy link

wip0 commented Jun 21, 2017

xunit reporter which is in mocha 3.4.2 generates the wrong output
<testsuite name="Mocha Tests" tests="2" failures="0" errors="0" skipped="0" timestamp="Wed, 21 Jun 2017 04:07:09 GMT" time="0.007">

@ScottFreeCode
Copy link
Contributor

@wip0 If you can put together a minimal but complete Mocha usage example (test, CLI command, mocha.opts file if any) to reproduce this, then please open a new issue for your case. Thanks!

@wip0
Copy link

wip0 commented Jun 21, 2017

@ScottFreeCode Thank you
I found that the error came from mocha-multi

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

Successfully merging a pull request may close this issue.

7 participants