RST
Introduction
Tests can be written in the reStructuredText format. That is, the same document, for example like
QuickStart.rst
in the project
QuickStart
serves both as documentation, like, for example,
README.md files
and as tests, like a normal .robot file.
It looks like this
Text text text .. code:: robotframework code code Text text text
Convenient for writing documentation. Extremely inconvenient when you need to read code. Perhaps those who use this format know some tricks unknown to me. If you are one of them, write to Telegram .
Below is a code excerpt QuickStart.rst
Data-driven tests ----------------- Quite often several test cases are otherwise similar but they have slightly different input or output data. In these situations *data-driven tests* allows varying the test data without duplicating the workflow. With Robot Framework the `[Template]` setting turns a test case into a data-driven test where the template keyword is executed using the data defined in the test case body: .. code:: robotframework *** Test Cases *** Invalid password [Template] Creating user with invalid password should fail abCD5 ${PWD INVALID LENGTH} abCD567890123 ${PWD INVALID LENGTH} 123DEFG ${PWD INVALID CONTENT} abcd56789 ${PWD INVALID CONTENT} AbCdEfGh ${PWD INVALID CONTENT} abCD56+ ${PWD INVALID CONTENT} In addition to using the `[Template]` setting with individual tests, it would be possible to use the `Test Template` setting once in the settings table like `setups and teardowns`_ defined later in this guide. In our case that
For writing documentation this is quite convenient, but reading tests in a document full of text paragraphs is much harder than in a regular .robot file
Example
Demo of rst .. code:: robotframework *** Variables *** ${WEBSITE} www.devhops.ru Some text that explains how you can write docs between robot code lines .. code:: robotframework *** Test Cases *** My Test [Documentation] Logs Website URL Log To Console ${WEBSITE}x Final words about placing Settings at the end of the file .. code:: robotframework *** Settings *** Documentation reStructuredText demo Thanks for your attention
Article author: Andrei Olegovich