cancel
Showing results for 
Search instead for 
Did you mean: 

Clone test Step to test case using java in soap ui

ankush
Occasional Contributor

Clone test Step to test case using java in soap ui

Hi

 

I am trying to clone all test steps in all test cases in a suite to a particular test case in the same project.

 

I am reading the entire list of test cases and their steps in a suite, saving these steps in a list.

Now i want to add or clone these steps to a specific test case . 

 

An ideas here on how to proceed now ? @nmrao  any champion advice  ?

 

WsdlProject project = new WsdlProject(path);
// get a list of all test suites on the project
List<TestSuite> suiteList = project.getTestSuiteList();

for (int i = 0; i < suiteList.size(); i++) {
TestSuite suite = suiteList.get(i);

String suiteName = suite.getName();
System.out.println("Test suite - " + suiteName + " , Enabled :" + !suite.isDisabled());



// empty List for all test steps from Test case
List<com.eviware.soapui.model.testsuite.TestStep> tsToBeAdded = new ArrayList<TestStep>();

if (suiteName.equals("Sometestsuite")) {

// read the test cases in each suite
List<com.eviware.soapui.model.testsuite.TestCase> caseList = suite.getTestCaseList();
System.out.println("test cases in suite - " + caseList.size());
for (int k = 0; k < caseList.size(); k++) {
com.eviware.soapui.model.testsuite.TestCase testCase = caseList.get(k);
System.out
.println("Test Case - " + testCase.getName() + " , Enabled :" + !testCase.isDisabled());

// dont pick up load test
if (!testCase.getName().equals("LoadTest")) {

if (!testCase.isDisabled()) {

// find all test steps
List<com.eviware.soapui.model.testsuite.TestStep> stepList = testCase.getTestStepList();
System.out.println("test steps in test case - " + stepList.size());
for (int j = 0; j < stepList.size(); j++) {
com.eviware.soapui.model.testsuite.TestStep step = stepList.get(j);
System.out.println("Test step added - " + step.getName() + " , Enabled :"
+ !step.isDisabled());
tsToBeAdded.add(step);

}

}

}

}

// check if test step list not empty
if (tsToBeAdded.size() > 0) {
// add the steps to Load test test case
com.eviware.soapui.model.testsuite.TestCase loadTestCase = suite.getTestCaseByName("LoadTest");

for (TestStep testStep : tsToBeAdded) {
System.out.println("Test step List - " + testStep.getName());

//TODO - somehow clone or add these test steps to this test case } } } }

 

Tags (1)
2 REPLIES 2
nmrao
Community Hero

Re: Clone test Step to test case using java in soap ui

Could not go thru the code posted. Does it work with above? or what is the exact issue?


Regards,
Rao.
ankush
Occasional Contributor

Re: Clone test Step to test case using java in soap ui

basically i need a way to insert or clone an existing test step to another test case programmatically.

 

com.eviware.soapui.impl.wsdl.actions.teststep.CloneTestStepAction
 
CloneTestStepAction cloneTS = new CloneTestStepAction();
cloneTS.perform((WsdlTestStep) step, new String(step.getName()));
 

The code above ia m trying is not working . any ideas here? 
New Here?
Join us and watch the welcome video:
Top Kudoed Authors