Robot Framework data-driven automation testing: Can data derived from a database be used as a data source for a test template?

你。 提交于 2019-12-04 23:26:44

Unfortunately, the use of test templates more-or-less require that the data is hard-coded in the test case. However, the test template is not much more than a wrapper around a for loop. You could do something like this:

| | ${database_rows}= | Run sql query
| | ... | Select * from the_database where ...
| | 
| | :FOR | ${row} | IN | @{database_rows}
| | | Suspend Region | @{row}

Of course, this requires that you write the "Run sql query" keyword or an equivalent to fetch the data.

The downside of this is that all of the permutations are considered a single test case with multiple keywords, versus multiple test cases with a single keyword.

If you want to have one test case per row in a database, you could write a script that does the query, generates a test suite file using the results of the query, and then runs pybot on the generated file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!