This page describes how to configure a Bamboo task to parse JUnit test results.
Because TestNG uses the JUnit XML format, the JUnit Parser task is also able to parse TestNG test results.
Before you begin:
- Java builder tasks in Bamboo (e.g. Maven) parse test information as part of the task. You do not need to configure a test task, if you have specified that test results will be produced as part of the builder task.
Related pages:
Atlassian blogs:
To configure a JUnit Parser task:
- Navigate to the Tasks configuration tab for the job (this will be the default job if creating a new plan).
- Click the name of an existing JUnit Parser task, or click Add Task and then JUnit Parser to create a new task.
- Update the task settings:
Task Description Enter a description of the task, for display in Bamboo. Disable this task Check, or clear, to selectively run this task. Specify custom results directories Enter the name of the test results directory (or multiple directories, separated by commas). You can also use Ant-style patterns such as **/test-reports/*.xml/ where the base directory is the "working directory" – this can be found at the start of your build log. Do not specify an absolute path.
For jobs that use CVS, the job build's root directory is<bamboo-home>/xml-data/build-dir/JOB_KEY/<cvs-module>. - Click Save.

8 Comments
Anonymous
Jan 15, 2013How to configure remoteAgent to send pass/fail response to the bamboo server
James Dumay
Jan 15, 2013All you have todo is add this Task to your Job and the Bamboo agent will automatically send the pass/fail response back to the server for you.
Anonymous
Jan 15, 2013In my current set-up, the python script that executes tests only generates a log file and not XML. Is there anyway in Bamboo I can parse the log-file and read the results. I am using a PyTest framework and the results are automatically reported to TestLink. Any suggestions ?...Thanks
Michaelian
Dec 10, 2013I had a similar issue so I added a function to output junit. It takes a dictionary of results and transforms that into the proper XML. I then write that out to a file. This is fairly specific to my test harness but one can retrofit this to work with your result input format.
def report_xunit(report): """ Generate a junit style xml report. We build the xml doc in reverse order so we can nest it. The xml is returned as a string. """ xmltests = "" suitedata = defaultdict(lambda: 0) for jid, jinfo in report.items(): jinfo['testid'] = jid if jinfo['status'] in ['fail', 'aborted']: t = """\t<testcase classname="${testname}" name="${testid}" time="${time}">\n""" t += """\t\t<error message="${detail}">\n\t\t</error>\n""" t += """\t</testcase>\n""" if jinfo['status'] == 'fail': suitedata['failures'] += 1 if jinfo['status'] == 'aborted': suitedata['error'] += 1 else: t = """\t<testcase classname="${testname}" name="${testid}" time="${time}">\n\t</testcase>\n""" suitedata['tests'] += 1 xmltests += string.Template(t).substitute(jinfo) data = {'autoid': 'fake', 'results': 'tests="%s" errors="%s" failures="%s" ' % ( suitedata['tests'], suitedata['errors'], suitedata['failures']), 'xmltests': xmltests} suite = string.Template("""<testsuite name="${autoid}" ${results}>\n${xmltests}</testsuite>\n""").substitute(data) xmlreport = """<?xml version="1.0" encoding="UTF-8"?>\n%s""" % suite return xmlreportDavid Ljung Madison
Jan 25, 2013I'm getting errors from the JUnit parser:
How can I find out what these errors are?
paulwatson
Jan 29, 2013Hi David,
Please go to Atlassian Support and create a support issue (you'll need to create an account if you don't already have one).
Attach the XML file that needs to be parsed - oe of our engineers will be able to help.
regards, Paul
David Ljung Madison
Jan 29, 2013I've already filed the issue and found the problem with my specific XML, but I still think that the error output from the parser should perhaps be a bit more verbose.
Nate
Jun 18, 2013I am seeing my junit xml file being created, but it seems that my command that runs the "Script" task step that runs the tests immediately before the "JUnit Parser" task step will halt the process if there are task failures so it never gets there. Is there a special "run tests" task that I am unable to find that will not stop execution when a "JUnit Parser" is present? FYI, I am seeing the XML file being created...