關於這項作業
配置檔包含一些陳述式,用來將「品質管理」構件資訊關聯於資料位置。配置檔中每一個陳述式的兩端用等號鏈結。陳述式左端由關鍵字組成。配置的等號右側可由三個可能的項目組成。
- 直欄或資料格定義,例如 D 或 D4
- 文字字串,例如 "execution"
- 另一個構件的參照(自我參照),例如 testscript.description
如果要定義列或資料格,只要放入直欄 ID 或資料格 ID:
testscript.dc:title=G
如果要定義文字字串,只要用引號括住它:
testscript.steps.type="execution"
如果要定義自我參照,只要放入先前定義的字行中位於等號左側的資訊:
testscript.dc:title=G
testcase.dc:title=testscript.dc:title
註: 使用自我參照所建立的構件,會使用另一個構件已在使用的資料,並且會建立指向該構件的鏈結。自我參照不能與 XLSLink 關鍵字搭配使用。
關鍵字與特殊案例
等號左側有一些關鍵字。它們的開頭全都是 "XLS" 且會取代構件後面的欄位。其定義如下:
- XLSStartRow 定義構件資料起自於哪一列之後。
- XLSDelimeter 定義用來表示下一個構件的元素(目前只支援 \n)。
- XLSLink 指定要將構件鏈結至工作表中指定類型的所有構件。
- XLSLinkReverse 指示匯出公用程式將鏈結 XML 放到構件內,而不是放置建立鏈結的構件。這個關鍵字只能與自我參照鏈結搭配使用。
如果您想建立的構件是以另一個構件為基礎(例如 requirement.dc:title=testcase.dc:title),但是您需要在原本的構件(位於等號右端的構件)中建立鏈結,請使用這個關鍵字。如果指定 requirement.XLSLinkReverse=true,則會將鏈結放在主要構件中,而不是放在指定自我參照鏈結的構件中。
- XLSArtifactID 指定構件的外部 ID。
如果沒有指定構件的外部 ID,則會以下列格式指派一個預設外部 ID:
Excel file name_Excel worksheet name[_artifact_count].xml
其中 artifact_count 是如果單一試算表含有兩個或多個構件時,該試算表中的構件數目。如果試算表只含有一個構件,就不需要這個引數。重要: 如果試算表中有構件的
外部 ID 與另一個構件相同,就會從試算表內容來更新構件。
比方說,如果您多次匯出具有相同配置的相同 Excel 試算表,則每次都會更新
外部 ID。
注意:
如果您使用 artifact.XLSArtifactID="urn:com.ibm.rqm:testplan:2",並將值指定為字串(而不是資料格),請確定沒有空白表單,且沒有使用 artifact.XLSWorksheetID 指定工作表來讀取 XLSArtifactID。
如果要在您將相同的 Excel 檔案匯出至相同的儲存庫時,建立新的構件,請完成下列其中一個步驟:
- XLSWorksheetID 指定要處理的工作表名稱。對於這個關鍵字,您必須使用文字字串。
註: 從 4.0 版開始,
testsuite 與
testcases 鏈結的語法已從
testsuite.testcases=testcase
變更為
testsuite.XLSLink=testcase
- 以下是一些範例:
- testscript.XLSStartRow=7
- testscript.title=B
- testscript.steps.type="execution"
- testscript.steps.description=B
- testscript.steps.title=B
- testscript.steps.name=B
- testscript.steps.expectedResult=F
- testscript.XLSDelimeter=\n
- testcase.dc:title=C1
- testcase.dc:description=C2
- testcase.XLSLink=testscript
- testcase.XLSArtifactID=D1
- testcase.XLSWorksheetID="test_case_1"
Script 步驟、種類、區段、影像匯出、動態搜尋某個單字或詞組,以及試算表內容存取都是特殊情況。Script 步驟要求每一個步驟要有數個欄位。由於 Script 可以有許多步驟,因此會將所有字行視為單一步驟,直到發現空白行之後,才開始下一個步驟。
區段為特殊情況。這是為了簡化它們的使用,並且避免其定義干擾別處所用的句點表示法。如果要更新區段,請使用下列格式:
testcase.Section("myns:com.ibm.rqm.planning.editor.section.testCaseAcceptanceCriteria", "RQM-KEY-TC-ACCEPT-CRITERIA-TITLE")=C
這個範例配置項目會移入建置到「品質管理」應用程式中的驗收準則區段。
- 如果要判斷預先定義之區段的名稱或顯示名稱,請執行下列動作:
- 更新「品質管理」中資源的預先定義區段。
- 在 abbreviate=false 的情況下,讀取
XML 形式的
資源。
- 在 XML 文件中找出含有區段名稱的元素,例如 com.ibm.rqm.planning.editor.section.testCaseAcceptanceCriteria。
- 在元素中找出包含區段顯示名稱的 extensionDisplayName 屬性,例如 RQM-KEY-TC-ACCEPT-CRITERIA-TITLE。
- 如果要定義自訂區段,請用有效的名稱取代第一個參數,以及用顯示名稱取代第二個參數:
testcase.Section("myns:mysection","my custom section")=C
- 如果要定義種類,請使用 category term=category_name.value=category_value 格式:
testcase.category term="Function".value=H
- 如果要將自訂屬性新增至一個構件中,請執行下列動作: 如果一個測試案例中有兩個 customAttributes,即 testcaseCustomAttribute1 和
testcaseCustomAttribute1,應該先在「品質管理」中建立 customAttributes
(testcaseCustomAttribute1 和 testcaseCustomAttribute2),然後再執行「品質管理的 Excel Importer」。
我們可以配置如下的 .cfg 檔:
testcase.customAttributes.type="SMALL_STRING" //set
the custom attribute type (the data type).
testcase.customAttributes.identifier=A //put an
identifier into the A column in Excel. The identifier is the name
of the attribute when you create it. For example, when you create
the customerAttribute with the name "name1" and change it to "name2"
later, the identifier remains "name1" on the Quality Management server.
If you set the custom attribute identifier as Custom_attribute_number_,
and the first attribute is Custom_attribute_0_ and the second is
Custom_attribute_1_ , this identifier will be correct when you put
it into the Excel cell.
testcase.customAttributes.name=B //put attribute name in B column
testcase.customAttributes.value=C //put attribute
value in C column結果會是:
<customAttributes>
<customAttribute type="SMALL_STRING">
<identifier>Custom_attribute_0_</identifier>
<name>testcaseCustomAttribute1</name>
<value>111111111111111111111111111</value>
</customAttribute>
<customAttribute type="SMALL_STRING">
<identifier>Custom_attribute_1_</identifier>
<name>testcaseCustomAttribute2</name>
<value>3333333333333333333333333</value>
</customAttribute>
</customAttributes>
已新增含有自訂 attributes.xls 的新範例 TestCases 001,以及含有自訂 attributes.cfg 的新範例 TestCases 001。
- 如果要存取您正在處理之試算表的內容,請使用下列指令行:
另有其他三個內容可以使用:“Name”、“Full Name”和“Location”。如果未設定內容,或者 Excel 不支援該內容,則內容 ("property name") 會傳回空字串:""。
相關的 .xls 和 .cfg 範例檔稱為 Requirements001 using document properties。
- 如果要從 Excel 匯出影像,請瞭解試算表中下列這些影像層面:
在 Excel 中,影像的位置由含有影像左上角的資料格代表。即使影像佔據多個資料格,您必須指定含有影像左上角的資料格,才能匯出影像。資料格可以包含無數個影像。如果您指定的資料格含有所有影像的左上角,將會匯出所有的影像。
在 Excel 中,匯出影像的方式有兩種。第一種方法是使用影像函數。影像會設定成函數,並且放在配置檔項目中的等號之後。影像可以用資料格或列來指定。影像函數會將影像插入到將具有它的 Rich Text 欄位。如果屬性沒有使用 Rich Text 欄位,就會忽略影像函數。請參閱以下的影像函數範例:
- testscript.steps.expectedResult=image(G)
- testscript.steps.description=image(C4)
第二種方法是使用 attachment 屬性:
- testcase.attachment=C4
- testcase.attachment=C
attachment 屬性會將影像當成附件新增至構件,而不是將影像插入至 Rich Text 欄位。
相關的 .xls 和 .cfg 範例檔分別稱為
Test Cases made from scripts with images 和 Test Cases made from scripts with attachments。