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

Hans Sebastian November 22, 2011

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
James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 27, 2011

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

Hans Sebastian November 27, 2011

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.

James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 28, 2011

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

Hans Sebastian November 28, 2011

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.

Ed C March 25, 2012

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

0 votes
sseveringhaus-newclassrooms April 19, 2017

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.

0 votes
Ed C March 25, 2012

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

0 votes
Ed C March 25, 2012

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

0 votes
Hans Sebastian November 22, 2011

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events