Publish attachments using JUnit format in automated build

Category: visual studio online

Question

Michaelw85 on Tue, 29 Mar 2016 17:53:13


Hi,

Is it possible to link an attachment to a failed test using results in JUnit format?

I've got a build definition in visual studio online to run automated tests. The results are stored in a xml file in JUnit format. My build definition has a "publish test results" build step. This build step has an advanced option "Upload test attachments" which I checked, but I cant get it to work. What I did so far is try all kinds of different formats in the xml which should work according to JUnit xml specs. When I look at the tests tab, attachments always end up being 0 and nothing is uploaded if I look at the log.

Here's the xml:

<testsuite name="suite01">
<testcase classname="tc02" name="tc02-description" time="0.609">
<failure message="Some Failure occurred">Failure info</failure>
<system-out>[[ATTACHMENT|C:/file1.png]]</system-out>
</testcase>
</testsuite>


Hopefully someone can help me out, I've been struggling for hours and cant get it to work.

Michael.


Replies

Asha99 on Wed, 30 Mar 2016 07:09:18


Hi Michael,
 Thank you for posting here

I would request you to send the build logs to v hiphen ashas at microsoft dot com,So that it will help us to answer your query better.

Thanks for your understanding.

Regards,
Asha

Michaelw85 on Wed, 30 Mar 2016 09:09:50


Hi Asha,

I've send you an e-mail containing the build logs.

Kind Regards,
Michael.

Asha99 on Wed, 30 Mar 2016 11:00:59


Hi Michael,

Greetings

The test tab you are seeing shows attachments of each test result, while the attachment in publish test result task is made at run level. To see run level attachment go to runs hub in test (beside build you find a testà runs).

Hope it helps!

Regards,

Asha

---------------------------------------------------------------------------------------------------

If a post answers your question, please click Mark As Answer on that post and Vote as Helpful.

Michaelw85 on Wed, 30 Mar 2016 11:28:26


Hi Asha,

Thank you for your reply. I’ve seen the tab you are referring to, this shows my results.xml as attachment but I can’t seem to get any other files (.png screenshots) to be picked up.
What I’m trying to accomplish is to get a screenshot to go with a failed test result in the test result tab, is this possible using the xml in JUnit format? 

Kind Regards,
Michael


Ron van Pol on Tue, 11 Oct 2016 11:34:04


Did you manage to find a solution this problem? I too am experiencing the exact same problem.

Regards,
Ron

Michaelw85 on Tue, 11 Oct 2016 13:28:38


Hi Ron,

No unfortunately I did not. I just gave up. I ended up taking my screenshots and adding them as artifacts with a decent naming convention. This is ok for our situation but not optimal of course. 

Kind Regards,

Michael.


Ron van Pol on Wed, 12 Oct 2016 09:12:06


Hi Michael,

Thank you for your response. Publishing the screenshots as artifacts is far from optimal but I guess that's all we can do at the moment. I did read on https://github.com/Microsoft/vsts-tasks/issues/2058 that support for JUnit attachments is in the backlog but unfortunately there's no ETA yet.

Furthermore I have no clue whatsoever how to add attachments to tests. It seems that there is support for this when I drill into the details of a test run on the team services website. Attachments, requirements and bugs can be linked to a test but I have no idea how to do that. See screenshot


Regards,
Ron

Michaelw85 on Wed, 12 Oct 2016 11:14:14


Hi Ron,

Thanks for the info. This explains why its not working.

For the attachments, I can see my junit xml file as attachment. I think this is being picked up because I have a build step to publish the test results. Apart from that I could not get a attachment to show up. Look at your build definition and go to "Add step" category "Utility" and use "Publish Build Artifacts" you can use this to take a file or multiple files from your build output and store it. This way you can at least have some form of attachments which are available in the results under the "Artifacts" tab. You can have multiple. This is how I store browser logs and screenshots from my selenium test run.

For the requirements and bugs I don't know how to link those, I would assume a bug will be linked if you create one from the page you are looking at. When we create a bug we manually add a link to the test case in the task or refer to it in text.

Hope this helps a bit.

Kind Regards,

Michael.

Ron van Pol on Wed, 12 Oct 2016 12:57:37


Hi Michael,

Could you possibly share a few screenshots of your build config? I have added the "Publish Build Artifacts" as you suggested. The files are published indeed but none of the files are attached to the test results. 

Regards,
Ron

Michaelw85 on Wed, 12 Oct 2016 13:41:31


Hi Ron,

The artifacts are located in the build overview. I might be looking at a different screen than you are, but here are some screenshots.

This is from the artifacts build step for my screenshots:

The build overview:

Artifacts tab:

Artifacts explorer:

Kind Regards,

Michael.

Ron van Pol on Wed, 12 Oct 2016 13:52:50


Hi Michael,

Thanks for the screenshots. That looks similar to what I have. I was looking at the test results screen as I posted previously and hoping that the artifact would magically be added to the attachments. But I guess I was hoping for too much there. I guess this is the best we can do at the moment.

Regards,
Ron