Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

1 vote
Answer 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 Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

653 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you