Does JUnit Parser require the classname and name attributes to be non-empty?

I have a bamboo plan and have Junit Parser as one of the tasks for its run. This is bamboo 3.3.2 build 2718.

I have two test results files in the same dir that I want JUnit Parser to pick up. The results are like this:

  • test/foo.xml
  • test/bar.xml

In the JUnit Parser, I put test/*.xml for the custom results directories. When I run, I only get results from bar.xml and the total number of tests is just coming rom bar.xml.

The difference other than the content of the tests is that classname and name attributes are blank in foo.xml:

foo.xml

<testsuite name="" errors="7" failures="8" skips="0" tests="17" time="1.531">
  <testcase classname="" name="tests.test_app" time="0">
    <failure message="collection failure">/home/foo/_path/local.py:529: in pyimport
E   ImportError: No module named Rest</failure></testcase>
  <testcase classname="" name="api.__init__" time="0"/>

bar.xml

<testsuite tests="583" errors="0" failures="0" skipped="0" name="contrib.AnonymousUserBackendTest" time="0.234">
  <testcase classname="contrib.AnonymousUserBackendTest" name="test_get_all_permissions" time="0.002"/>
  <testcase classname="contrib.AnonymousUserBackendTest" name="test_has_module_perms" time="0.000"/>

So, does JUnit Parser require the classname and name attributes to be non-empty? Is there any other reason the results are not picked up?

Thanks

5 answers

1 accepted

G'day,

Yes you need to provide a name for the testsuite and test class in the test results for the file to be considered a valid JUnit report by Bamboo.

What testing framework is generating that output?

Thanks

James

We use py.test

(env26_qa)[hsebastian@puri removeme]$  python --version
Python 2.6.1
(env26_qa)[hsebastian@puri removeme]$  py.test --version
This is py.test version 2.1.3, imported from /Users/hsebastian/zion_repo/env26_qa/lib/python2.6/site-packages/pytest.pyc
(env26_qa)[hsebastian@puri removeme]$  cat test_filename.py 
import invalidmodule


class TestClassName(object):
    def test_method_name(self):
        pass

(env26_qa)[hsebastian@puri removeme]$  py.test --junitxml results.xml

platform darwin -- Python 2.6.1 -- pytest-2.1.3
collected 0 items / 1 errors 


____________________________________________________________________________________________________ ERROR collecting test_filename.py _____________________________________________________________________________________________________
test_filename.py:1: in <module>
>   import invalidmodule
E   ImportError: No module named invalidmodule
----------------------------------------------------------------------------------------------------- generated xml file: results.xml ------------------------------------------------------------------------------------------------------

(env26_qa)[hsebastian@puri removeme]$  cat results.xml 
<?xml version="1.0" encoding="utf-8"?><testsuite name="" errors="1" failures="0" skips="0" tests="0" time="0.009" >
<testcase classname="" name="test_filename" time="0"><failure message="collection failure">test_filename.py:1: in &lt;module&gt;
&gt;   import invalidmodule
E   ImportError: No module named invalidmodule</failure></testcase></testsuite>(env26_qa)[hsebastian@puri removeme]$  

Thanks for confirming my observation. I'll look into py.test to see if there is a way for the values to be inserted even though the setup failed. I am pretty sure older version of py.test did not behave like this.

Think you could email me the reports that failed to parse? I think we should add some sensible behavior for when we get reports with data missing. My email is james@atlassian.com

I think the results.xml i pasted above should be sufficient to repro this. I haven't tried it though but the nature is similar. Otherwise, I can send you the reports from an actual bamboo run, but I need your email address. :) I could not find it on this website.

Hi, have you found a way to get py.test to fill these testsuite name value? I have run into the same issue

I also tried running the plan such that only foo.xml is created. Still bamboo sees no results.

Hi, have you found a way to get py.test to fill these testsuite name value? I have run into the same issue

Hi, have you found a way to get py.test to fill these testsuite name value? I have run into the same issue

I hit this same issue. Bamboo would successfully pass or fail the build based on the test results, but it wouldn't display any of them, instead just giving the cryptic "No failed tests found, a possible compilation error occurred" message.

In my particular case, I'm using dotnet test, which generates Microsoft's TRX format, which I then transform to JUnit format. The transformation was not correctly picking up the className from TestDefinitions/UnitTest/TestMethod in the TRX file.

An error or warning message from the JUnit Parser plugin when testcase/@classname is missing would be very helpful.

Suggest an answer

Log in or Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,074 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot