Polarion Test runs

Usage

The test run class provides access to the test records.

Currently the records holds the test records.

Creating a new test run using Project class

new_test_run = project.createTestRun('New-id', 'New test run title', 'template-id')

accessing an existing test run:

existing_test_run = self.checking_project.getTestRun('test-id')

adding a new test case to an existing test run:

test_case = project.getWorkitem('workitem-id')
existing_test_run.addTestcase(test_case)

Set the test run status:

existing_test_run.status.id = 'verifiedPassed'
existing_test_run.save()

Note

There is currently no way to get the possible statuses for test run. Look in your Polarion config to find these values.

Attachments

A test run may have an attachment related to the test run. An example for working with attachments:

existing_test_run = self.checking_project.getTestRun('test-id')
#upload a file
existing_test_run.addAttachment(path_to_file, 'file title')
existing_test_run.hasAttachment() # now true
#download a file
attachment_name = existing_test_run.attachments.TestRunAttachment[0].fileName
existing_test_run.saveAttachmentAsFile(attachment_name, path_to_new_file)
#deleting attachment
existing_test_run.deleteAttachment(attachment_name)

List of available attributes

The attributes are set in the test run when loading it from polarion. An attribute can be None (when it is not set), a string, number or datetime, or another object. When accessing any attribute, a check for None is recommended as the only attributes that are always set are: -Type -Created -ProjectUri

Other attributes that will be available, but could be None, are listed below.

Attribute

Type (when not None)

getter

setter

attachments

No

No

authorURI

No

No

comments

object

No

addComment

created

No

No

customFields

No

No

document

No

No

finishedOn

No

No

groupId

No

No

homePageContent

No

No

id

No

No

idPrefix

No

No

isTemplate

No

No

keepInHistory

No

No

location

No

No

projectSpanURIs

No

No

projectURI

No

No

query

No

No

selectTestCasesBy

No

No

status

No

No

summaryDefectURI

No

No

templateURI

No

No

testParameters

No

No

title

No

No

type

No

No

unresolvable

No

No

updated

No

No

uri

No

No

useReportFromTempla

No

No

Testrun class

class polarion.testrun.Testrun(polarion, uri=None, polarion_test_run=None)

Create a Polarion testrun object from uri or directly with Polarion content

Parameters:
  • polarion – Polarion client object

  • uri – Polarion uri

  • polarion_test_run – The data from Polarion of this testrun

Variables:

records – An array of Record

addAttachment(file_path, title)

Upload an attachment

Parameters:
  • file_path – Source file to upload

  • title – The title of the attachment

addTestcase(workitem)

Add a workitem to the test run. A test case cannot be added to a template. :param workitem: Workitem object

deleteAttachment(file_name)

Delete an attachment.

Parameters:

file_name – The attachment file name

getAttachment(file_name)

Get the attachment data

Parameters:

file_name – The attachment file name

Returns:

list of bytes

Return type:

bytes[]

getTestCase(id)

Get the specified test case record from the test run records

Returns:

Specified record fi ti exists

Return type:

Record

hasAttachment()

Checks if the test run has attachments

Returns:

True/False

Return type:

boolean

hasTestCase(id)

Checks if the the specified test case id is in the records.

Returns:

True/False

Return type:

boolean

save()

Update the testrun in polarion

saveAttachmentAsFile(file_name, file_path)

Save an attachment to file.

Parameters:
  • file_name – The attachment file name

  • file_path – File where to save the attachment

updateAttachment(file_path, title)

Upload an attachment

Parameters:
  • file_path – Source file to upload

  • title – The title of the attachment