Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How do I create a Test Definition using the SilkCentral Test Manager Web Services?

How do I create a Test Definition using the SilkCentral Test Manager Web Services?

Problem:

How do I create a Test Definition using the SilkCentral Test Manager Web Services?

Resolution:

To create a new Test Definition via the SilkCentral Web Services we need to make use of the following Class stubs:

  • SccsystemSoapBindingStub
  • TmplanningSoapBindingStub
  • TestPlanningNode
  • PropertyValue

Before we can begin interacting with SilkCentral Test Manager we must first login and obtain a session id, all interactions with the SilkCentral Test Manager Web Services require that we provide a session id. To login we create an instance of the class "SccsystemSoapBindingStub" which provides us with a method to login to SilkCentral and obtain a session id:

//Variables

SccsystemSoapBindingStub bind;
long sessionID;

....

....

public void GetSessionID(){

//Generate the session ID
try{
bind = (SccsystemSoapBindingStub)new SystemServiceServiceLocator().getsccsystem();
logonUser("admin","admin");
}
catch(Exception e){
e.printStackTrace();
}
}

public void logonUser(String username, String password){

try{
sessionID = bind.logonUser(username, password);
}
catch(Exception e){
e.printStackTrace();
}

}

When the above method, GetSessionID, is executed it calls the local logonUser function which uses the Web Service function logonUser to login to SilkCentral Test Manager using the provided credentials and obtain a session id. This session id is stored in the variable sessionID which is available to all methods in our Java class. Now that we have generated our session id we can now use the test planning Web Service to create our Test Definition, let us firstly retrieve the test planning Web Service which will provide with all the required functionality that we require:

//Variables

SccsystemSoapBindingStub bind;
TmplanningSoapBindingStub plnBind;
long sessionID;

....

....

public void GetPlanningService(){

//Generate the test planning service
try{
plnBind = (TmplanningSoapBindingStub) new PlanningServiceServiceLocator().gettmplanning();
}
catch(Exception e){
e.printStackTrace();
}
}

Now that we have access to the test planning service we can proceed with the creation of our Test Definition. When creating a Test Definition using the Web Services we use the class TestPlanningNode to store the information with regards to the Test Definition we wish to create. Let us look at the code for creating a Test Definition via the Web Services:

....

....

public void createTD(){
try{
TestPlanningNode newTestDef = new TestPlanningNode();
newTestDef.setKind(3); //3 represents a node which is a Test Definition
newTestDef.setPropertyValues(getTestDefProps());
plnBind.addNode(sessionID, , newTestDef, false);
}
catch(Exception e){
e.printStackTrace();
}
}

In the above code excerpt we make use of the method getTestDefProps which will be demonstrated later and which should be replaced with the ID of the Test Container or folder to which this new Test Definition should be added. The getTestDefProps method is quite important as this will set all the relevant information with regards to your Test Definition, it also important as most errors that occur when creating a Test Definition arise due to some missing property information. The method getTestDefProps below will demonstrate how to set and return the relevant properties for a SilkTest Test Definition:

public PropertyValue[] getTestDefProps(){
PropertyValue pvName, pvDesc, pvTestType,pvScript,pvTestCase,
pvDataDriven,pvTestData,pvOptionSet,pvInherit;

pvName = new PropertyValue();
pvName.setName("Name");
pvName.setPropertyTypeID("_node_properties_");
pvName.setPropertyID("_node_properties_Name");
pvName.setValue("SilkTest Web Services");

pvDesc = new PropertyValue();
pvDesc.setPropertyTypeID("_node_properties_");
pvDesc.setPropertyID("_node_properties_Description");
pvDesc.setValue("SilkTest Web Services Description");

pvTestType = new PropertyValue();
pvTestType.setPropertyTypeID("_test_def_type_");
pvTestType.setPropertyID("_test_def_type_st_");
pvTestType.setValue("_st_");

pvScript = new PropertyValue();
pvScript.setPropertyTypeID("_st_");
pvScript.setPropertyID("Script File");
pvScript.setValue("MyTest.t");

pvTestCase = new PropertyValue();
pvTestCase.setPropertyTypeID("_st_");
pvTestCase.setPropertyID("TestCase");
pvTestCase.setValue("testcaseOne");

pvDataDriven = new PropertyValue();
pvDataDriven.setPropertyTypeID("_st_");
pvDataDriven.setPropertyID("DataDriven");
pvDataDriven.setValue("true");

pvTestData = new PropertyValue();
pvTestData.setPropertyTypeID("_st_");
pvTestData.setPropertyID("TestData");
pvTestData.setValue("\"arg1\",\"arg2\",\"arg3\"");

pvOptionSet = new PropertyValue();
pvOptionSet.setPropertyTypeID("_st_");
pvOptionSet.setPropertyID("OptionSet");
pvOptionSet.setValue("MyOpt.t");

pvInherit = new PropertyValue();
pvInherit.setPropertyTypeID("_node_properties_");
pvInherit.setPropertyID("InheritAttributes");
pvInherit.setValue("true");

return new PropertyValue[]{pvName, pvDesc,pvTestType,pvScript,
pvTestCase,pvDataDriven,pvTestData,pvOptionSet,pvInherit};
}


Old KB# 25093

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:52
Updated by:
 
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.