

Since this string is rendered as the test is written, to the test runner it’s the same normal string it would expect. Then, instead of our args being a static string, it’s an f-string. We import the choice function from the random module so we can grab a random entry from our taco_types list. create_keyword ( "Log", args = [ f " -log.html" ) Let’s review a trivial example of a Robot Framework test suite:įrom robot.api import TestSuite, ResultWriter from random import choice OUTPUT_PATH_PREFIX = "./output/03-dynamic-test-args" taco_types = best_taco = choice ( taco_types ) suite = TestSuite ( name = "My Very Simple Test Suite" ) test = suite.

Let’s get started with setting up our test suite and getting it to run: 01 - Core Concept If you are using 3.x and are having significant challenges writing your own tests, feel free to open issues on the example repo above. body of the test versus it being an attribute on the keyword added. Most IDEs should provide some hinting for the version you are using, but the biggest change to note is the migration to creating keywords on. So if you’re using 3.x, some of the syntax below will be different. In the example repo above we use Poetry, however you can use pip if you’d like.Īdditionally, we are using version 4.x of Robot Framework, which made some API changes.
Generate random string robot framework install#
The source code for the examples in each section of these posts can be found on GitHub.īefore getting started, be sure to install the robotframework package via your package manager of choice. In Part 2, I will build upon these foundations and generate a dynamic test suite, including generating our own keywords. By the end of Part 1, you should be able to generate dynamic test contents. I will explain what each line means so that you can know where to augment for your use case. Part 1 (this post) will cover getting our tests running without using any. I will be covering these concepts in a layered approach, consisting of two major parts. Thankfully since Robot Framework’s DSL must be parsed, the package exposes a full API to directly trigger this parsing through the robot.api modules.
Generate random string robot framework update#
For a lot of use cases, these can be sufficient although both can quickly become tedious to update or can obscure exactly what is being tested. Using templating tools like Jinja can also help create a more varied test suite between runs. Frequently, people drop into Python code or scripts to do more custom tests of their code or infrastructure. However, one complexity to using Robot Framework is that currently there is no way to generate your test cases dynamically. Additionally, their domain-specific language (DSL) is one that can be written by both engineers and non-engineers alike. Robot Framework is a useful testing tool that generates a great human-readable report of your tests.
