私は以下のコードを持っています:
*** Settings ***
Library OperatingSystem
Library Process
Library String
*** Variables ***
@{MyList}= item items items2
${LogStr1} *HTML*
*** Test Cases ***
#Start Test#
[xxxxx] My tests
FOR ${item} IN @{MyList}
General test.out testProfile ${item}
[Template] Run Test
[Tags] TestTags
END
*** Keywords ***
Run Test
[Documentation] Run the test
[Arguments] ${type} ${profile} ${file} ${test}
When suite config is updated
And updated the config in directory ${test}
Then publish test status
suite config is updated
[Documentation] Get the variables list
Log to Console "Updating get suite config file"
updated the config in directory ${test}
[Documentation] Get the variables list
Run keyword if "${test}" == "items" Stop Test "This is stop called"
publish test status
[Documentation] Create and check if any issue found
${LogStr}= Catenate Test Passed : Log created: <a href="Hello.txt">Hello</a>
Log to Console ${LogStr}
${LogStr1}= Catenate ${LogStr1} ${LogStr}\n
Set Test Variable ${LogStr1}
Set Test Message ${LogStr1}
Stop Test
[Documentation] Stop Execution
[Arguments] ${FIALUREMSG}
Log To Console ${FIALUREMSG}
${LogStr1}= Catenate ${LogStr1} ${FIALUREMSG}
Fail ${LogStr1}
コードに従って、テストは1回目の2回目または3回目の実行で実際に失敗するようにすることができます。だから私が次のようなコードを持っているとき:
Run keyword if "${test}" == "item" Stop Test "This is stop called"
上記のキーワードには、スイートに合格する2つのテストケースがありますが、レポートには次のように記載されています。
2番目のテストケースを失敗させると、以下のテストメッセージログが表示されます。
Run keyword if "${test}" == "items" Stop Test "This is stop called"
上記のキーワードには、スイートに合格する2つのテストケースがありますが、レポートには次のように記載されています。
同様に
Run keyword if "${test}" == "items2" Stop Test "This is stop called"
など-したがって、テストケースが失敗としてマークされている場合、「テストメッセージの設定」ログ値はレポートメッセージで無視されるようです。以下は、最初のテストケースを失敗としてマークするコードを実行したときのlog.htmlコンテンツであることに注意してください。
Run keyword if "${test}" == "item" Stop Test "This is stop called"
したがって、私の質問はすべて、report.htmlファイルにすべての失敗したテストケースと合格したテストケースのログを表示したい場合、どうすればそれを達成できるかということです。
If you check the documentation of the Set Test Message keyword it says that any failure will override the messages, but you have the option to override the failure message from the teardown.
In test teardown this keyword can alter the possible failure message, but otherwise failures override messages set by this keyword. Notice that in teardown the message is available as a built-in variable
${TEST MESSAGE}
.
So what you can do is instead of calling Set Test Message, you could just save the messages into a test variable. Then you should add a teardown in which you call the Set Test Message and concatenate your test variable with the ${TEST MESSAGE}
. For example:
*** Test Cases ***
Test
[template] Template
[setup] Set Test Variable ${MSG} ${EMPTY} # create empty test variable to store messages
1
3
2
5
6
4
6
[teardown] Set Test Message ${MSG}\n${TEST MESSAGE} # concatenate failure messages to normal test messages
*** Keywords ***
Template
[arguments] ${number}
No Operation
Run Keyword If ${number} == 2 Fail fail message ${number}
Run Keyword If ${number} == 4 Fail fail message ${number}
Set Test Variable ${MSG} ${MSG}\nMy test message ${number} # concatenate next test message
This example produces the following report:
このアプローチでは、テストケースの表にリストされているすべてのテストがテンプレートを呼び出すため、特定のロボットスイートでテンプレートテストのみを行うことができます。
他の完全に異なる解決策はFOR
、の要素@{MyList}
が静的であるため、ループを取り除くことです。テンプレートを[設定]テーブルに移動してから、すべての反復を手動で一覧表示すると、それぞれを独立したテストケースに分けることができます。このように、1回の反復で失敗しても、他の反復で設定されたテストメッセージには影響しません。例えば:
*** Settings ***
Test Template Template
*** Test Cases ***
Test1 1
Test2 2
Test3 3
Test4 4
Test5 5
Test6 6
*** Keywords ***
Template
[arguments] ${number}
No Operation
Run Keyword If ${number} == 2 Fail fail message ${number}
Run Keyword If ${number} == 4 Fail fail message ${number}
Set Test Message My test message ${number}
これにより、次のレポートが生成されます。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加