Excel VBA to purge test runs with a status of ”No Run”
Question ID: 108015
0
0

Hello. I am wanting to delete all of the test runs with a status of "No Run" using Excel VBA. Can you assist me with this? Thanks in advance!

Marked as spam
Posted by (Questions: 239, Answers: 31)
Asked on November 27, 2017 4:16 pm
79 views
Answers (1)
0
Private answer

I will be glad to assist you with this. The script below will delete all of the test runs from the specified testset folder. Make sure you have the correct Excel add-in installed on your machine. You will also need to make sure you install the Connectivity addin and register the ALM Client on your machine as well. If you have any questions or concerns, please let me know.

Sub PurgeTestRuns()

Dim TSetFact
Dim tsFilter
Dim KeepLast
Dim DateUnit
Dim UnitCount
Dim StepsOnly
Dim runFact
Dim runFilter
Dim tsTest

Set tdc = CreateObject(''TDApiOle80.TDConnection'')
tdc.InitConnectionEx ''http://your_alm_server_name:8080/qcbin''
tdc.Login ''your_alm_username'', ''your_alm_password''
tdc.Connect ''your_alm_domain'', ''your_alm_testset_folder''

'Set filter for tests in folder specified.
Set TSetFact = tdc.TestSetFactory
Set tsFilter = TSetFact.Filter
'If project name contains any spaces, use 3 sets of double quotes (i.e. ''''''My Test Project'''''').
'If there are no spaces, use a single set of double quotes instead (i.e. ''My_Test_Project'')
tsFilter.Filter(''CY_CYCLE'') = ''Your_ALM_TestSet_Folder''

'Set filter for tests with a No Run status.
Set runFact = tdc.RunFactory
Set runFilter = runFact.Filter
'If the test status contains any spaces, use 3 sets of double quotes (i.e. ''''''No Run'''''').
'If there are no spaces, use a single set of double quotes instead (i.e. ''Passed'')
'runFilter.Filter(''RN_STATUS'') = ''''''No Run''''''

'KeepLast will keep the amount of test runs with the status type that was selected to be deleted in the
'runFilter.Filter line above. Example - If there are three test runs with the status of Failed,
'and you set KeepLast to 2, it will only delete one of those test runs.
KeepLast = 0 'Keeps the set amount of status types not to be deleted
DateUnit = 1 'Days
UnitCount = 0 'Purge starting 0 days ago (as I was testing with today's Runs)
StepsOnly = False ' Purge both the runs and steps.

'Purge the runs.
tdc.PurgeRuns2 tsFilter.Text, runFilter.Text, CInt(KeepLast), CInt(DateUnit), CInt(UnitCount), StepsOnly

MsgBox ''Purge Completed!''

'Disconnect from the project and dispose all objects to free memory and the session
tdc.Disconnect
tdc.Logout
Set tdc = Nothing
Set TSetFact = Nothing
Set tsFilter = Nothing
Set runFact = Nothing
Set runFilter = Nothing

End Sub

Marked as spam
Posted by (Questions: 2, Answers: 300)
Answered on November 27, 2017 4:18 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top