Super Contributor.
Super Contributor.

Test Case status change to '1-Design' when copy pasted

Requirement is, if any tester copy paste test case, then the newly created Test Case design status should be set to '1-Design'

I am using below code in ActionExecuted function under common script

if ActionName = "TestPlanTree.Paste" and ActiveModule = "Test Plan" then
'test case if which is copied and pasted
oldTestId = Test_Fields("TS_TEST_ID").Value
Set tdc = TDConnection
Set testfact = tdc.TestFactory
Set tfilter = testfact.Filter
tfilter.Filter("TS_NAME") = testfact.Item(oldTestId).Name & "*"
Set tlist = testfact.NewList(tfilter.Text)
if tlist.Count > 0 then
msgbox "total tests with the same name=" & tlist.Count
Set pastedtest = tlist.Item(tlist.Count)
pastedtest.Field("TS_STATUS") = "1-Design"
End If
Set pastedtest = nothing
Set tlist = nothing
Set tfilter = nothing
Set testfact = nothing
Set tdc= nothing
End If

I am getting filter text as testcasename* which is correct

but when trying to get the list count, I am getting a very high value as 1830 like.

But it should be around 4 only as only 4 test cases are similar to that name.

Can you please let me know if there is anything wrong with this code.

Any help would be highly appreciated.

1 Reply
Micro Focus Expert
Micro Focus Expert

I guess the filter doesn't work as per the old test case name contains space.
Try using tfilter.Filter("TS_NAME") = "'" & testfact.Item(oldTestId).Name & "*'" instead.
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.