createTestPlan インターフェイス

createTestPlan インターフェイスは、新しいテストを作成するために使用されます。すべての呼び出しの HTTP の応答には、変更されたテストの XML 構造が含まれます。新しいコードの識別子は、更新された XML テストの構造から取得できます。

次の表は、createTestPlan インターフェイスのパラメータを表しています。

インターフェイス URL パラメータ 説明

http://<front-end URL>/servicesExchange?hid=createTestPlan

sid ユーザー認証用の Web サービス トークンまたはセッション識別子。Web サービス トークンは、Silk Central UI の 設定ページ から生成できます。このページにアクセスするには、Silk Central メニューに表示されているユーザー名にマウス カーソルを移動し、ユーザー設定 を選択します。セッション識別子は、利用可能な Web サービス のうちの logonUser メソッドを呼び出すことで取得できます。
parentNodeID テスト ツリーにおいて新しいテストが追加されるコンテナの ID

例:http://<front-end URL>/servicesExchange?hid=createTestPlan&parentNodeID=<id>&sid=<webServiceToken>

テスト計画を検証するために使用される XML スキーマ定義ファイルは、フロントエンド サーバー URL http://<フロントエンド URL>/silkroot/xsl/testplan.xsd を使用してダウンロードするか、フロントエンド サーバーのインストール フォルダ <Silk Central インストール フォルダ>/wwwroot/silkroot/xsl/testplan.xsd からコピーできます。

createTestPlan Web サービスの例

以下のコードでは、Apache HttpClient を使用して、テストが作成されます。

import org.apache.commons.httpclient.*; // Apache HttpClient

string webServiceToken = "e39a0b5b-45db-42db-84b2-b85028d954d5"; // The token that you have generated in the UI

URL service = new URL("http", mWebServiceHelper.getHost(),
  mWebServiceHelper.getPort(), 
  String.format("/servicesExchange?hid=%s&sid=%s&parentNodeID=%d",
  "createTestPlan", webServiceToken,
  PARENT_NODE_ID));
	
HttpClient client = new HttpClient();
PostMethod filePost = new PostMethod(service.toExternalForm());
String xmlFile = loadTestPlanUtf8("testPlan.xml");
StringPart xmlFileItem = new StringPart("testPlan", xmlFile,
  "UTF-8");
xmlFileItem.setContentType("text/xml");
Part[] parts = {xmlFileItem};

filePost.setRequestEntity(new MultipartRequestEntity(parts,
  filePost.getParams()));
client.getHttpConnectionManager().getParams().setConnectionTimeout(60000);
int status = client.executeMethod(filePost);
System.out.println(filePost.getStatusLine());

リクエスト毎に 1 つの添付ファイルのみアップロードすることができます。Apache HttpComponents をダウンロードするには、http://hc.apache.org/downloads.cgi を参照してください。必要なライブラリについては、コンポーネントのドキュメントを参照してください。

テストの例

次のコードは、createTestPlan サービス、および updateTestPlan サービスを使用して Silk Central へアップロードすることができるテストの例を示しています。

<?xml version="1.0" encoding="UTF-8"?>
  <TestPlan xmlns="http://www.borland.com/TestPlanSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://<front-end URL>/silkroot/xsl/testplan.xsd">

  <Folder name="Folder1" id="5438"> 
    <Description>Description of the folder</Description>
    <Property name="property1">
      <propertyValue>value1</propertyValue>
    </Property>
    <Test name="TestDef1" type="plugin.SilkTest">
      <Description>Description of the test</Description>
      <Property name="property2">
        <propertyValue>value2</propertyValue>
      </Property>
      <Property name="property3">
   	    <propertyValue>value3</propertyValue>
   	    <propertyValue>value4</propertyValue>
      </Property>
      <Parameter name="param1" type="string">string1</Parameter>
      <Parameter name="param2" type="boolean">true</Parameter>
						<Parameter name="paramDate" type="date">01.01.2001</Parameter>
      <Parameter name="paramInherited" type="string"
        inherited="true">
        inheritedValue1
      </Parameter>      
      <Step id="1" name="StepA">
        <ActionDescription>do it</ActionDescription>
        <ExpectedResult>everything</ExpectedResult>
      </Step>
      <Step id="2" name="StepB">
        <ActionDescription>and</ActionDescription>
        <ExpectedResult>everything should come</ExpectedResult>
      </Step>
    </Test>
    <Test name="ManualTest1" id="5441" type="_ManualTestType"
      plannedTime="03:45">
      <Description>Description of the manual test</Description>
      <Step id="1" name="StepA">
        <ActionDescription>do it</ActionDescription>
        <ExpectedResult>everything</ExpectedResult>
      </Step>
      <Step id="2" name="StepB">
        <ActionDescription>and</ActionDescription>
        <ExpectedResult>everything should come</ExpectedResult>
      </Step>
      <Step id="3" name="StepC">
        <ActionDescription>do it now"</ActionDescription>
        <ExpectedResult>
          everything should come as you wish
        </ExpectedResult>
      </Step>
    </Test>
    <Folder name="Folder2" id="5439">
      <Description>Description of the folder</Description>
      <Property name="property4">
        <propertyValue>value5</propertyValue>
      </Property>
      <Parameter name="param3" type="number">123</Parameter>
      <Folder name="Folder2_1" id="5442">
        <Description>Description of the folder</Description>
        <Test name="TestDef2" type="plugin.SilkPerformer">
          <Description>Description of the test</Description>
          <Property name="_sp_Project File">
            <propertyValue>ApplicationAccess.ltp</propertyValue>
          </Property>
          <Property name="_sp_Workload">
            <propertyValue>Workload1</propertyValue>
          </Property>
        </Test>
        <Test name="TestDef3" type="JUnitTestType"
          externalId="com.borland.MyTest">
          <Description>Description of the test</Description>
          <Property name="_junit_ClassFile">
            <propertyValue>com.borland.MyTest</propertyValue>
          </Property>
          <Property name="_junit_TestMethod">
            <propertyValue>testMethod</propertyValue>
          </Property>
          <Step id="1" name="StepA">
            <ActionDescription>do it</ActionDescription>
            <ExpectedResult>everything</ExpectedResult>
          </Step>
          <Step id="2" name="StepB">
            <ActionDescription>and</ActionDescription>
            <ExpectedResult>everything should come</ExpectedResult>
          </Step>
        </Test>
      </Folder>
    </Folder>
  </Folder>
</TestPlan>