Polarion Test record

Usage

Set the test case status:

# get a record from the test run
test_record = test_run.records[0]
#set status
test_record.setResult(Record.ResultType.PASSED, 'some optional comment')

An exception is raised if the test run is not marked as automatic. Manual test cases require signing via Polarion web interface.

zeep.exceptions.Fault: java.lang.IllegalStateException: It is not allowed to sign on behalf of another user.

Set the status of an individual test case step:

# get a record from the test run
test_record = test_run.records[0]
#set status
test_record.setTestStepResult(step_index, Record.ResultType.PASSED, 'See attachment')

Where step_index is a valid range for the current test case.

It is possible to use the context manager with a record. This is useful, when updating all test steps in a record. Execution speed increases, because the record is only updated once, when exiting the context manager.

with test_run.records[0] as test_record:
    for step_index in range(5):
        _record.setTestStepResult(step_index, Record.ResultType.PASSED, 'See attachment')

Attachments

To prove a test case, a attachment may be uploaded to test records and test case steps. An example for the record attachments:

test_record = test_run.records[0]
#upload a file
test_record.addAttachment(path_to_file, 'file title')
test_record.hasAttachment() # now true
#download a file
attachment_name = test_record.attachments.TestRunAttachment[0].fileName
test_record.saveAttachmentAsFile(attachment_name, path_to_new_file)
#deleting attachment
test_record.deleteAttachment(attachment_name)

Note

Attachments to the record can only be uploaded if the record result has been set

An example for step attachments:

test_record = test_run.records[0]
#upload a file
test_record.addAttachmentToTestStep(step_index, path_to_file, 'file title')
test_record.testStepHasAttachment(step_index) # now true
#download a file
attachment_name = test_record.testStepResults.TestStepResult[step_index].attachments.TestRunAttachment[0].fileName
test_record.saveAttachmentFromTestStepAsFile(step_index, attachment_name, path_to_new_file)
#deleting attachment
test_record.deleteAttachmentFromTestStep(step_index, attachment_name)

Note

Attachments to the test steps can only be uploaded if the test step result has been set.

List of available attributes

The attributes are set in the record 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.

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

Attribute

Type (when not None)

getter

setter

attachments

hasAttachment

saveAttachmentAsFile

testStepHasAttachment

saveAttachmentFromTestStepAsFile

deleteAttachment

addAttachment

updateAttachment

deleteAttachmentFromTestStep

addAttachmentToTestStep

comment

getComment

setComment

defectURI

No

No

duration

No

No

executed

No

No

executedByURI

getExecutingUser

No

iteration

No

No

result

getResult

setResult

signed

No

No

testCaseRevision

No

No

testCaseURI

No

testcase_id

testParameters

No

No

testStepResults

No

setTestStepResult

Test record class

class polarion.record.Record(polarion, test_run, polarion_record, index)

Create a Polarion test record,

Parameters:
  • polarion – Polarion client object

  • test_run – Test run instance

  • polarion_record – The data from Polarion of this testrun

  • index – The index of this record in the test run

class ResultType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Record result enum

addAttachment(file_path, title)

Upload an attachment

Parameters:
  • file_path – Source file to upload

  • title – The title of the attachment

addAttachmentToTestStep(step_index, file_path, title)

Upload an attachment to a test step

Parameters:
  • step_index – The test step index

  • file_path – Source file to upload

  • title – The title of the attachment

deleteAttachment(file_name)

Delete an attachment.

Parameters:

file_name – The attachment file name

deleteAttachmentFromTestStep(step_index, file_name)

Delete an attachment from a test step

Parameters:
  • step_index – The test step index

  • 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[]

getAttachmentFromTestStep(step_index, file_name)

Get the attachment data from a test step

Parameters:
  • step_index – The test step index

  • file_name – The attachment file name

Returns:

list of bytes

Return type:

bytes[]

getComment()

Get a comment if available. The comment may contain HTML if edited in Polarion!

Returns:

Get the comment, may contain HTML

Return type:

string

getExecutingUser()

Gets the executing user if the test was executed

Returns:

The user

Return type:

User/None

getResult()

Get the test result of this record

Returns:

The test case result

Return type:

ResultType

getTestCaseName()

Get the test case name including prefix

Returns:

The name

Return type:

string

hasAttachment()

Checks if the Record has attachments

Returns:

True/False

Return type:

boolean

save()

Saves the current test record

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

saveAttachmentFromTestStepAsFile(step_index, file_name, file_path)

Save an attachment to file from a test step

Parameters:
  • step_index – The test step index

  • file_name – The attachment file name

  • file_path – File where to save the attachment

setComment(comment)

tries to get the severity enum of this workitem type When it fails to get it, the list will be empty

Parameters:

comment – Comment string, may contain HTML

setResult(result: ResultType = ResultType.FAILED, comment=None)

Set the result of this record and save it.

Parameters:
  • result – The result of this record

  • comment – Comment string, may contain HTML

setTestStepResult(step_number, result: ResultType, comment=None)

” Set the result of a test step

Parameters:
  • step_number – Step number

  • result – The result fo the test step

  • comment – An optional comment

testStepHasAttachment(step_index)

Checks if the a test step has attachments

Parameters:

step_index – The test step index

Returns:

True/False

Return type:

boolean

property testcase_id

The test case name including prefix