Extend the TestResultsDeletionTool more for advanced deletion customization such as test plan folder/sub folder deletion, test result count constraint deletion etc by using OTA API with VB scripting
Problem
Test executing via Quality Center, 250 testsets, 400 manual scripts which run bi-weekly, and 1000 automated scripts which run nightly leads to tons of test results (since 2010) has been generated and this has indirectly consumes up to GBs of disk spaces in the running environment.HP's TestResultsDeletionTool can be use to clean up the mess, however I wish to do something more advances like
- Batch cleaning
- Test Plan folder/sub folder cleaning
- Clean up the test result if it has more than 100 counts (to keep results for low frequent execution test cases)
Solution
By using OTA API with VB scripting. VB script can be downloaded by clicking on vbscript.As TestResultsDeletionTool is using test case as the primary source to delete its run history, hence we need a way to navigate from [Test Case -> Test Set (Test Lab) -> Test Instance -> Run History] to find its way for the clean up
Explanation 1: Below codes is needed to do a cross filter from Test Set to Test Case in order to list out all Test Set that has an instance of Test Case being assigned to.
'filter by test case idSet TestFilter = TestFact.FilterTestFilter.Filter("TS_TEST_ID") = Chr(34) & oTest.ID & Chr(34) 'setup to retrieve test set listSet TestSetFact = objTDConnection.TestSetFactorySet TestSetTreeManager = objTDConnection.TestSetTreeManagerSet TestSetFilter = TestSetFact.Filter 'Set cross filter to filter by test case idTestSetFilter.SetXFilter "TESTSET-TEST", True, TestFilter.TextExplanation 2: Below code is needed to retrieve the Run History count from each test instance in each test of the selected Test Set
'retreive testset listSet TestSetList = TestSetFact.NewList(TestSetFilter.Text)
For Each itemTestSet In TestSetList 'print("TestID[" & oTest.ID & "], TestSetName[" & itemTestSet.Name & "], TestSetID[" & itemTestSet.ID & "]") strTestSetName = itemTestSet.Name Set TSTestFact = itemTestSet.TSTestFactory Set TestSetTestsList = TSTestFact.NewList("") 'print(TestSetTestsList.Count) 'Get the total count for the particular test case 'In case total count > 100 (as per define in variable), proceed with the deletion 'Else keep the record, as it is not regularly run For Each testInstanceItem In TestSetTestsList If StrComp(testInstanceItem.TestID, oTest.ID, vbTextCompare)=0 Then Set runFactory = testInstanceItem.RunFactory Set runFactoryList = runFactory.NewList("") 'print("TestSetName[" & itemTestSet.Name & "], TestID[" & testInstanceItem.TestID & "], Instances[" & testInstanceItem.Instance & "], runFactoryList.Count[" & runFactoryList.Count & "]" ) intTotalCount = intTotalCount + runFactoryList.Count End If NextNextExplanation 3: Code to trigger TestResultsDeletionTool silently. TestResultsDeletionTool will only works if it is running from the QC Server machine. From observation, if you run from remote machine, nothing will be clean up. Please be aware
The VB script has to call from the machine where the QC
Set wcshell = WScript.CreateObject("WScript.Shell")'Call TestResultsDeletionTool.exestrExeTest = " -Test " & Chr(34) & "[QualityCenter] " & oSubjectNode.Path & "\" & oTest.Name & Chr(34)'print("Deleting test results for --> " & oSubjectNode.Path & "\" & strTestSetName)wcshell.Run strExeDefault & strExeTest, 1, True
Lesson learnt
N/AHappy testing!
No comments:
Post a Comment