shunit2 icon indicating copy to clipboard operation
shunit2 copied to clipboard

jUnit XML-Like Output

Open GoogleCodeExporter opened this issue 9 years ago • 27 comments

Hello,

I would like to submit you a bunch of changes:
  - adds a trick to prevent tested scripts to prematurely exit,
  - fixes a typo in docbookPrep.sh,
  - translates output report format to jUnit XML format,
  - adds a command to run all test suites in a directory and optionally
write test reports to a specific directory (shunit2_testsuite),
  - adds a command to join all test suite reports in a directory into a
single one report (shunit2_collect).
  - adds a RPM specfile.

The API was not changed at all. And by default, reports are displayed to
stdout except if the SHUNIT_OUTPUTDIR is set. In that situation, the report
is saved to $SHUNIT_OUTPUTDIR/TEST-<test suite name>.xml, eg
/tmp/testsuites/reports/TEST-foo.xml for test suite foo.sh.

Please note, that due to network issues, I was not able to start coding
from the latest version (r294) but instead I started from the latest stable
release ie 2.1.5.

Nonetheless, I let you assess the pertinence of those changes and let you
pick whatever is needed to the project. Please help yourself!

Regards,

Frédéric MOULIN.

Original issue reported on code.google.com by [email protected] on 23 Oct 2009 at 7:02

Attachments:

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

I would really like to get the xml format support into shunit2. What is needed 
to get
this integrated into shunit? Make it optional? Allow to specify the output 
style?

Original comment by [email protected] on 8 Jan 2010 at 8:24

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Currently the proposed patch is a partial rewrite of the existing code. It was 
done
for a personal homework. So you have to understand that it is is not fully 
tested,
and is rather intrusive: xml is the default format. Right now, I do not have 
enough
time to update this code, but there should not be too much work to make the xml
output optional. Nonetheless, I am very interesting by a,y feedback. We keep in
touch! Thanks for your comment ;-)

Original comment by [email protected] on 8 Jan 2010 at 8:43

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Hi Frederic, thankyou for posting this patch. This is really useful.

Original comment by [email protected] on 27 Aug 2010 at 12:37

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Original comment by [email protected] on 15 Mar 2011 at 12:30

  • Added labels: Priority-Low, Type-Enhancement
  • Removed labels: Priority-Medium, Type-Defect

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

the junit-xml patch works great! Now I'm merging Kate's new changes in to the 
patched r294.

Original comment by [email protected] on 24 May 2011 at 8:37

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Ok, I've got a patch that updates 2.1.6 to include Frédéric Moulin's 
JUnit-xml patch.  Unfortunately it is not too clean - it reduces shunit2 to 
only work with bash, and I've only been able to test it on Ubuntu and Redhat 
linux flavours.  With some more cleanup it can be made available.  Contact me 
for the dirty patch - however, I endavour to come up with a proper patch that 
allows for both the junit-xml output and the normal shunit2 output.

In fact anyone else is in my position, I'm hooking the tests up to Atlassian 
Bamboo's test reporting.  So if that happens to be what you're doing, then I 
suspect my dirty patch might be just the ticket for you!

Regards,
-Ben

Original comment by [email protected] on 3 Jun 2011 at 5:54

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Ben - Would like to get your patch for JUnit XML output in 2.1.6.  Please post, 
if possible.  Much thanks!

Original comment by [email protected] on 28 Sep 2011 at 8:58

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Same here ! I would be really interested by the patched version with XML output.

Original comment by [email protected] on 24 Oct 2011 at 1:35

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

This hasn't been merged yet?

Original comment by [email protected] on 31 Jan 2013 at 3:28

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Attached! There was quite a bit of tweaky stuff,
but in the end I did manage to merge 2.1.6 with the earlier work that
another fellow did to get junit-xml with an earlier version of shunt.
The patch is a bit messy, but it works great for us. We are now using
this approach with quite a few of our products.

Here's my diff command:

diff -u -r shunit2-2.1.6-orig shunit2-2.1.6 > shunit-2.1.6-xml.patch

Enjoy!

Original comment by [email protected] on 31 Jan 2013 at 8:38

Attachments:

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Bummer! Only bash?! That not good :\

Original comment by [email protected] on 1 Feb 2013 at 9:14

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

I'm sure it could be made to work without bash, but that was not in my 
requirements so I took the shortcut and just used bash.

Original comment by [email protected] on 1 Feb 2013 at 6:42

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Here's a, so far working, non bash dependent, patched, version of shunit2:
    https://github.com/s0undt3ch/shunit2

The regular output was kept, but can be omitted using SHUNIT_STDOUT.
There's an option to include the environment or not using SHUNIT_INCLUDE_ENV.

Original comment by [email protected] on 3 Feb 2013 at 11:53

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Could we get this patch included in the official shunit2 along with a new 
release ? 
Or is this project not supported anymore ? 

Thank you

Original comment by [email protected] on 29 Apr 2013 at 3:13

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

[deleted comment]

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

It seems that s0undt3ch is no longer supporting the XML patches

https://github.com/s0undt3ch/shunit2/pull/1

I have forked and fixed a couple of issues.

https://github.com/jeremycarroll/shunit2

My interest in the xml output is for integration with jenkins, and our 
continuous test server.

Original comment by [email protected] on 29 Apr 2013 at 8:49

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Thanks. This is a good thing, I've been needing this for a while. We've had to 
kludge JUnit XML output via a Perl script that runs with the end-of-suite hook. 
Our goal is also to integrate with Jenkins.

Original comment by [email protected] on 29 Apr 2013 at 9:56

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Thank you very much !
My question about support was more related with the project in itself. Ideally 
the fork should be merged back with the original shunit2 and released. 

Thank you again, I will use it with Jenkins. 
Barth

Original comment by [email protected] on 30 Apr 2013 at 6:14

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Hi Jeremy, 

I have also started to correct the XML patches to make it work with jenkins. I 
haven't had time to check your version, but you might want to check my patches, 
some of them might be useful: 
https://github.com/fekete-robert/shunit2/commits/jenkins

(I am not a programmer, so they might be ugly as hell.)

Regards, 

Robert

Original comment by [email protected] on 30 Apr 2013 at 7:34

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Hi, 

I think that we should change the line
    cat << EOF >> "${SHUNIT_OUTPUTDIR}/TEST-${__shunit_suite_name}.xml"
into
    cat << EOF > "${SHUNIT_OUTPUTDIR}/TEST-${__shunit_suite_name}.xml"

Appending only results in an invalid xml file. 

Original comment by [email protected] on 30 Apr 2013 at 11:54

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Hi, 

in the patch the functions oneTimeTearDown and oneTimeSetUp must not be piped. 
That is important in order allow the called code to modify variables such as 
the suite name.

Cheers,
Barth

Original comment by [email protected] on 21 May 2013 at 12:15

GoogleCodeExporter avatar Jun 26 '15 04:06 GoogleCodeExporter

Hey, i know it's been almost 5 years but i wanted to ask what the status if this issue is. Is there a way to get the patch integrated?

Also, i've seen there is a fork which already implements the feature: https://bitbucket.org/eddiewebb/shunit-with-reports

Regards!

makefu avatar Nov 20 '18 16:11 makefu

Now that I have used this tool a bit more, I was kind hoping to have this feature available. I see that there have been attempts to get this done, but those are now outdated as their implementation is based on old version of this repo.

If there is still demand for this, I can try to give it a try.

JussiPekonen avatar Jun 27 '22 20:06 JussiPekonen

@JussiPekonen, do you have a required patches for the latest version?

AJIOB avatar Nov 01 '23 16:11 AJIOB

This or TAP would be quite nice. My motivation would be to allow github actions to report test results. I can open a new one for TAP format.

ensonic avatar Feb 10 '24 18:02 ensonic

@ensonic, if you need JUnit XML output with timestamps support, you may use my repo with branch AJIOB/add-time-stamps, that stands in queue to create a PR (after the basic JUnit XML support adding).

AJIOB avatar Feb 11 '24 08:02 AJIOB

Hi all,

Looks like we've merged the #176, so I think we can close this issue as completed.

Time measure support will be added by #180, but you can start using the current version.

AJIOB avatar Jun 21 '24 05:06 AJIOB