4

ドキュメントに表示されるテスト レベル変数を取得できません。

私がこのテストスイートを持っているとしましょう:

| *Variables* |
| ${SystemUnderTest} = | Staging

| *testcase* |
| Device Test |
| | Set Test Variable   | ${device}      | iPhone
| | [Documentation]     |  Device is: ${device} |
| | ...                 |  System is: ${SystemUnderTest} |
| | No Operation

これにより、次のログが生成されます。

TEST CASE: Device TestExpand All
Full Name:  T.Device Test
Documentation:  
Device is: ${device} System is: Staging

スイート レベルの変数は適切に処理されていますが、テスト レベルの変数は正しく処理されていないことに注意してください。
すべての変数を同等に扱うにはどうすればよいですか?

4

2 に答える 2

4

robotframework 2.7 から、 という名前の組み込みキーワードがSet test documentationあり、既存のドキュメントを置換または追加するために使用できます。これはコンソールの出力には影響しませんが、変更ログとレポートに反映されます。

例えば:

| *Variables* |
| ${SystemUnderTest} = | Staging

| *testcase* |
| Device Test |
| | Set Test Variable   | ${device}      | iPhone
| | [Documentation]     |  Device is: ${device} |
| | ...                 |  System is: ${SystemUnderTest} |
| | Substitute vars in documentation
| | No Operation

| *Keywords* |
| Substitute vars in documentation
| | ${doc}= | replace variables | ${test documentation}
| | set test documentation | ${doc}

詳細については、 http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html?r=2.7.7# Set%20Test%20Documentationを参照してください。

于 2013-06-17T13:04:04.773 に答える
1

このソリューションは、私には少しハッカーっぽい気がしますが、必要な機能が提供されます。

Test.txt

| *Setting*   | *Value*            |
              # This should start as the value for your first test
| Suite Setup | Set Suite Variable | ${device} | foo

| *Test Case* | *Action* | *Argument*
#
| T100 | [Documentation] | Should be foo: ${device}
       # Do some stuff
|      | No Operation
       # This setups the device name for the next test.
|      | Set Suite Variable | ${device} | bar 
#
| T101 | [Documentation] | Should be bar: ${device}
       # Do some stuff
|      | No Operation
|      | Set Suite Variable | ${device} | bing
#
| T102 | [Documentation] | Should be bing: ${device}
       # Do some stuff
|      | No Operation

スイートを実行すると、次の出力が得られます。

==============================================================================
Test                                                                          
==============================================================================
T100 :: Should be foo: foo                                            | PASS |
------------------------------------------------------------------------------
T101 :: Should be bar: bar                                            | PASS |
------------------------------------------------------------------------------
T102 :: Should be bing: bing                                          | PASS |
------------------------------------------------------------------------------
Test                                                                  | PASS |
3 critical tests, 3 passed, 0 failed
3 tests total, 3 passed, 0 failed
==============================================================================

前のテストの最後にデバイス変数が設定されているのは少し汚れていますが、コメントを残す限り、まったく不明確になることはありません。

于 2013-06-13T14:49:02.563 に答える