Hi,
Scenario:
I am using Java + TM4J REST API to do a GET request on a test cycle, and test all the test cases that live within that cycle, before then doing a test execution POST to return the results of the tests when they are complete. As part of this, my program captures a screenshot of the browser at point of test failure and stores this locally within the project as a PNG image. All works so far..
Issue:
If you run a test execution through the GUI, you can copy and paste an image in or use the upload file to attach the image.
I cannot seem to work out however, or find any resource on how to use Java to attach an image or to paste in the image as part of the test steps or comments of that test execution. There is no API endpoints (checked with Adaptivist themselves on that) but there must be some way of getting around this problem by passing the image along with the api POST as part of the JSON body.
Thankful for any help regarding this.
TM4J Server API (v1) now has methods to post attachments to test executions and steps within them.
As per the API specification, in order to attach a file to a test execution (which corresponds to clicking on "Drop files here or select files" in TM4J web GUI on an open execution) use a POST call to the following resource: /testresult/{testResultId}/attachments
Mind that the testResultId part is not a test execution key, but the ID returned by the API when creating a test execution with the appropriate call.
The attachment must be passed as a multipart/form-data media type. E.g.:
POST https://jira.server.local/rest/atm/1.0/testresult/65208/attachments HTTP/1.1
Accept-Encoding: gzip,deflate
User-Agent: PostmanRuntime/7.15.0
Content-Type: multipart/form-data; boundary="----=_Part_5_1594638400.9687465465446"
MIME-Version: 1.0
Authorization: Basic PWhgKJHGKjhgkJHGKJHGUYT
Content-Length: 5766
Host: jira.server.local
Connection: Keep-Alive
------=_Part_5_1594638400.9687465465446
Content-Type: application/octet-stream; name=error.log
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="file"; filename="error.log"<FILE CONTENT>
Is this the same when using TM4J for cloud? That is what I am currently using.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't worked with TM4J Cloud API, but judging by the documentation, unfortunately no methods are implemented to work with attachments: https://docs.adaptavist.io/tm4j/cloud/api/v2/#operation/listTestCases.
It has just appeared in TM4J Server and let's hope they're working to add it in the Cloud ))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Scott Maitland, the create attachment request is finally implemented in Zephyr Cloud. Please take a look here: Create Attachment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I could not get it work, somebody can help me ?
Infact I realy wonder why testrun/testcase is not have a attachments ??
I use below to update test result in a cycle
/testrun/{testRunKey}/testcase/{testCaseKey}/testresult
However this form does not have attachment.
And creating testresult id says it doesnt deal with a testrun, then how will I attach a file to test in a cycle then ????
In fact I tried every attachtment in this API but none of them worked for me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can upload a file to test case, test cycle (test run), testresult that I have created but not a test instance in a cycle
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.