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.

To configure a JUnit Parser task:

  1. Navigate to the Tasks configuration tab for the job (this will be the default job if creating a new plan).
  2. Click the name of an existing JUnit Parser task, or click Add Task and then JUnit Parser to create a new task.
  3. Update the task settings:

     

    Task DescriptionEnter a description of the task, for display in Bamboo.
    Disable this taskCheck, or clear, to selectively run this task.
    Specify custom results directoriesEnter 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>.
  4. Click Save.

 

  • No labels

8 Comments

  1. Anonymous

    How to configure remoteAgent to send pass/fail response to the bamboo server

    1. James Dumay

      All 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. 

      1. Anonymous

        In 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

        1. Michaelian

          I 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.

          report_xunit
          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 xmlreport

           

           

           

  2. David Ljung Madison

    I'm getting errors from the JUnit parser:

     

    25-Jan-2013 07:06:37Starting task 'Final output' of type 'com.atlassian.bamboo.plugins.testresultparser:task.testresultparser.junit'
    25-Jan-2013 07:06:37Parsing test results...
    25-Jan-2013 07:06:37Failed to parse test result file "regress.xml"

     

    How can I find out what these errors are?

     

    1. paulwatson

      Hi 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

  3. David Ljung Madison

    I'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.  (smile)

  4. Nate

    I 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...