Adding Design Step via Workflow
The majority of my tests begin with logging in to the AUT. So I would like to have that design step automatically inserted when I create a new test in Test Lab. I added the following script in Workflows Test Plan module script\Test_New:
But this just generates an error with no useful information. Anyone have an idea on how to do this?
Step_Fields("ST_STEP_NAME").Value = "Login"
Step_Fields("ST_DESCRIPTION").Value = "Enter user name and password"
What is the error?
I believe that the problem is related to the context of Test_New having no knowledge of what a design step is so references to Step_Fields have no meaning. (And, on a side note, Step is the steps in an executed test in the Test Lab. DesignStep is the step in a Test Case in the Test Plan. So, if this would work, you would need to reference DesignStep_Fields anyhow.)
Another problem is that when Test_New is called, the Test Case has not yet been saved to the database. So, if there is no Test Case yet, then you can't add design steps to it.
You need to add the design step during the Test_AfterPost workflow. The custom subrouting below (AddDesignStep) and the modifications shown to Test_AfterPost work on an ALM 11.0 patch 15 system, in a project that does not have version control enabled.
Sub AddDesignStep(TestId, in_ds_name, in_ds_description)
'msgbox "TestId = " & TestId
'msgbox "in_ds_name = " & in_ds_name
'msgbox "in_ds_description = " & in_ds_description
' Retrieve the Test Case just added
set tdc = TDConnection
set TestFact = tdc.TestFactory
set TestFactFilter = TestFact.Filter
TestFactFilter.Filter("TS_TEST_ID") = TestId
set TestList = TestFact.NewList(TestFactFilter.Text)
if TestList.Count <> 1 then
' should've retrieved 1 and only 1 test case
' if not, quit
msgbox "TestList.Count = " & TestList.Count
set aTest = TestList.Item(1)
' add a new, blank design step to the test
set DesStepFact = aTest.DesignStepFactory
set DesStep = DesStepFact.AddItem(NULL)
' set the values of the desgin step
DesStep.StepName = in_ds_name
DesStep.StepDescription = in_ds_description
' post the design step to the database
set DesStep = nothing
set DesStepFact = nothing
set aTest = nothing
set TestFactFilter = nothing
set TestFact = nothing
set tdc = nothing
' On Error Resume Next
' After posting a test case to the database
' if it has 0 design steps, then call routine to add one default step
Msgbox "after test post"
msgbox "TS_Steps = " & Test_Fields("TS_STEPS").Value
if (Test_Fields("TS_STEPS").Value) = 0 then
' On Error GoTo 0
(Opinions and information contained in this post are wholly my own and do not reflect the opinions of my employer.)
Post Thanks / Like - 1 Thanks, 0 Likes, 0 Dislikes
Thanks Trudy. I appreciate the clear explanation and your code worked flawlessly. Thanks again.