Edgewall Software
Modify

Opened 17 years ago

Closed 15 years ago

Last modified 15 years ago

#177 closed defect (fixed)

Support for JUnit4 XML format

Reported by: markus@… Owned by: osimons
Priority: major Milestone: 0.6
Component: Recipe commands Version: dev
Keywords: junit Cc: trac@…
Operating System:

Description

I'm using Junit4 for my unit tests and that has a different xml format. This patch changes the junit function to support junit4. Unfortunatly junit3 isn't supported anymore with this version. I guess it wouldn't be hard to have either a new junit4 function or a function that autodetects the version. Maybe I'll try to do so later, just wanted to post this patch as is for comments and for people that use JUnit4.

The patch also allows wildcards in the srcpath. I'm sure that could be done better, but this is actually my first try with python at all, so i'm happy that it actually works for me. :)

Attachments (2)

bitten_junit4.patch (1.4 KB) - added by markus@… 17 years ago.
TEST-fr.rtaw.pegase.minplus.expression.impl.TomFractionLPImplMappingTest.xml (12.5 KB) - added by loic.fejoz@… 15 years ago.
An example of JUnit4 file that make bitten junit crash

Download all attachments as: .zip

Change History (10)

Changed 17 years ago by markus@…

comment:1 Changed 17 years ago by cmlenz

Cool, thanks for the patch!

I think having the same code handling both JUnit4 output and the output by previous versions would be the best options. The differences don't look so substantial that a couple of added ifs wouldn't do the trick ;)

comment:2 Changed 17 years ago by cmlenz

  • Component changed from Build slave to Recipe commands

comment:3 Changed 15 years ago by trac@…

  • Cc trac@… added

We have been using Junit4 at work ever since we set up Bitten and never had a problem with the test reporting or the <java:junit/> tool.

And just running a quick test using both Junit 3.8 and Junit 4.5 (with some engineered failures), it looks to me like there are no differences in the XML that is spit out whatsoever.

From my experiments, they certainly both seem to work fine with the current trunk of Bitten (r700).

Can the original reporter supply a sample junit report that doesn't work? If not I'd suggest closing this ticket.

Changed 15 years ago by loic.fejoz@…

An example of JUnit4 file that make bitten junit crash

comment:4 Changed 15 years ago by loic.fejoz@…

The error exists in the Debian and Ubuntu version of bitten-trac, ie version 6b2. I have attach a file that exhibits such a junit4 crash.

[ERROR   ] Internal error in build step 'junit'
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.5/bitten/slave.py", line 327, in _execute_step
    step.execute(recipe.ctxt):
  File "/usr/lib/pymodules/python2.5/bitten/recipe.py", line 228, in execute
    ctxt.run(self, child.namespace, child.name, child.attr)
  File "/usr/lib/pymodules/python2.5/bitten/recipe.py", line 106, in run
    function(self, **args)
  File "/usr/lib/pymodules/python2.5/bitten/build/javatools.py", line 134, in junit
    result[0].attr['message'])
  File "/usr/lib/pymodules/python2.5/bitten/util/xmlio.py", line 294, in __getitem__
    raise KeyError(name)
KeyError: 'message'
[WARNING ] Stopping build due to failure

comment:5 Changed 15 years ago by loic.fejoz@…

  • Priority changed from minor to major
  • Type changed from enhancement to defect

After a few investigation, the error comes from assertions without message (sic!). The obvious enhancement is to change line 134 of build/javatools.py from

result[0].attr['message'])

to

result[0].attr.get('message',''))

That's all folk!

comment:6 Changed 15 years ago by osimons

  • Milestone set to 0.6
  • Owner changed from cmlenz to osimons

Thanks. I've committed the small change in [806]. As I then read this ticket, the JUnit tool really does seem to work? I'm closing, so please reopen if I've misunderstood anything.

BTW: Thanks for the xml file - I've added this to my todo, so that perhaps one day we'll get a test suite for junit parsing... Kudos offered to anyone willing to add parsing of a minimum XML file showing the various supported attributes and elements (including a traceback). Tests to be included in source:trunk/bitten/build/tests/javatools.py one day... :-)

comment:7 Changed 15 years ago by osimons

  • Resolution set to fixed
  • Status changed from new to closed

... and closing.

comment:8 Changed 15 years ago by loic.fejoz@…

Well, It works for me now. But indeed further investigation would be mandatory.Especially a complete review of the JUnit XML format would be welcome but it is already on your todo list! ;-)

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.