Ultra-fine, RobotFramework automated testing - detailed use of test suites (actual combat)


foreword

Because automation is written based on Pycharm, here we focus on the grammar format and usage of writing RF in Pycharm

We write RF by creating a .robot or .txt file in Pycharm, a .robot file is equal to a test suite

Note:
The encoding format of .robot and .txt files must be utf8 to ensure correct parsing of unicode characters

If it is not utf8, errors may occur when running the use case, as shown in the figure below
insert image description here

Format of RF Test Cases

Each configuration part of the test case can be divided into two parts:
the main part; the configuration part;

The configuration section of the test case

configuration item effect
[Documentation] A text description of the use case, similar to Py comments
[Tags] There can be multiple tags for this use case, remember to have two spaces between the tags
[Setup] Prerequisites for this use case
[Teardown] Post operations for this use case
[Template] Declare that the use case is template keyword driven, this use case only contains test data
[Timeout] Set the timeout period for use case execution

Code example:

C2

The main part of the test case
ignores the role of keywords, which will be introduced in detail later, so get familiar with the structure first

Let’s take a look first, and then analyze it with an example (ignore the popularity)

C3

*** Test Cases *** 

Note that the first letter should be capitalized so that the plug-in can recognize it, and there is a space for the word. It is recommended to use automatic prompts, that is, type a T

Use case name:
It needs to be written in the top grid, and if it is in Chinese, there is no need to add quotation marks

Use case body:
pay attention to the indentation relative to the test case name, indent at least two spaces, it is recommended to press the tab key directly (provided that the tab key is set to be equal to four spaces
)
.

simple example

c4

Note:
log and log to console are keywords.
Printing logs and printing logs to the console are parameters, which are passed to keywords. They are equivalent to Python: log and log to console are used to
call this method, followed by parameters passed to the function [ log("print log")] Note: keywords are case-insensitive, and log and LOG have the same
effect .

Source of keywords
Test library
Resource file
User keyword table of the file where the use case is located

RF execute command

All are executed in cmd
Syntax format

robot --options  datasource

datasource: It can be a file or a folder, both of which represent the data source where the use case set is located. File: The
test suite file where the rf use case is located.
Folder: All files containing rf use cases in the folder [including all subdirectories]

example

robot test.robot
robot testcase

Running results
Three files will be generated in the current directory where the command is executed, mainly to view logs and results

c5

Internal Flow of RF Execution Use Cases

RF reads the test suite file (.robot file) and checks the format.
RF first parses the keyword RF in the test case
and then calls the keyword corresponding to the test library.
The keyword (ie code) completes the specific work.
What really interacts with the system under test is the keyword set in the test library.

The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

Only by facing difficulties bravely can we counterattack the pinnacle of life; only by persevering can we reap brilliant achievements; only by never giving up can we create our own miracles. Come on, in the future you will thank yourself who is working hard now!

Only by putting in the greatest effort can we reap the most fruitful results. No matter how difficult it is, if you persevere in chasing your dreams and move forward bravely, you will eventually sail to the other side of success. Let your struggle light up every corner of your life and achieve a brilliant life stage!

Only perseverance and the courage to face difficulties can create a brilliant future. No matter how difficult the predicament is, the power of struggle will tear open the dark sky and lead us on the road to victory. Believe in yourself, chase your dreams, and achieve unlimited possibilities!

Guess you like

Origin blog.csdn.net/x2waiwai/article/details/131536208