差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 下次修改 Both sides next revision | ||
rf:rf:best_practice [2016/12/08 15:20] tony [Test Structure] |
rf:rf:best_practice [2017/08/19 23:33] 127.0.0.1 外部編輯 |
||
---|---|---|---|
行 39: | 行 39: | ||
* 當Test第一層Keyword夠淺顯易懂後,Test本身應不需特別寫文件的。 | * 當Test第一層Keyword夠淺顯易懂後,Test本身應不需特別寫文件的。 | ||
* 在寫測試時,常會把相關的assertion放在同一個testcase中,這會因前面的錯而無法得知後面的是否正確。Data-Driven的方式也許可以解決這問題,但在keyword的設計上,就要仔細思考了;另外個方法就是一個測試驗證一個主要目標,但Testsuite的粒度就很重要了,否則會讓測試數量變得非常龐大。 | * 在寫測試時,常會把相關的assertion放在同一個testcase中,這會因前面的錯而無法得知後面的是否正確。Data-Driven的方式也許可以解決這問題,但在keyword的設計上,就要仔細思考了;另外個方法就是一個測試驗證一個主要目標,但Testsuite的粒度就很重要了,否則會讓測試數量變得非常龐大。 | ||
- | * Gherkin Style的作法會產生大量的新keyword,要怎麼整理還在思考中。 | + | * Gherkin Style的作法會產生大量的新keyword,Robotframework本身提供兩個方法可減少此問題([[http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#behavior-driven-style|reference]]): |
+ | - Ignoring Given/When/Then/And/But prefixes: 舉例來說,keyword名稱假設為User login,你可以寫成Given User Login,也可以寫成When User Login。 | ||
+ | - Embedding data to keywords: 舉例來說,通常都是以參數型式寫成Click Element | ${link},現在也可以寫成Click ${link}。這讓你keyword更像是一個句子。 | ||
=== 練習 === | === 練習 === | ||
<code> | <code> | ||
行 58: | 行 60: | ||
- 共用的行為該如何放置到Setup或Teardown中? [[http://morelia.readthedocs.io/en/latest/gherkin.html|參考此篇]] | - 共用的行為該如何放置到Setup或Teardown中? [[http://morelia.readthedocs.io/en/latest/gherkin.html|參考此篇]] | ||
- data-driven方式該如何撰寫? [[https://blog.codecentric.de/en/2009/11/givenwhenthen-and-example-tables-using-the-robot-framework/|參考此篇]] | - data-driven方式該如何撰寫? [[https://blog.codecentric.de/en/2009/11/givenwhenthen-and-example-tables-using-the-robot-framework/|參考此篇]] | ||
- | data-driven可搭配tempalte: | + | data-driven可搭配tempalte寫成以下形式: |
<code> | <code> | ||
*** Test Case *** | *** Test Case *** | ||
行 67: | 行 69: | ||
About about content | About about content | ||
EMail email@hotmail.com | EMail email@hotmail.com | ||
+ | |||
*** Keyword *** | *** Keyword *** | ||
WebLink is clickable | WebLink is clickable |