The most detailed interface automated testing yaml framework, super detailed explanation, an article to get through...


foreword

YAML file introduction
YAML is a very readable, very close to the program language data structure. At the same time, it has rich expressiveness and scalability, and is an easy-to-use data markup language.

The full name of YAML is actually a recursive abbreviation of "YAML Ain't a Markup Language" (YAML is not a markup language), so it emphasizes the data itself rather than the markup

Why use YAML files?
In fact, YAML files are also a kind of configuration files, but compared with ini and conf configuration files, they are more concise, easy to operate, and can store different types of data; while the values ​​stored in ini are all string types, read manual conversion after fetching

Basic grammatical rules
are case-sensitive;
use indentation to represent hierarchical relationships;
tab keys are not allowed for indentation, only spaces are allowed. (You can replace the tab key output of your ide with 4 spaces);
the number of spaces for indentation is not important, as long as the elements of the same level are aligned to the left;
# indicates a comment;

Supported data structures
Object: a collection of key-value pairs, also known as mapping/hashes/dictionary;
array: a set of values ​​arranged in order, also known as sequence/list (list);
scalars: a single, indivisible value;

YAML, object data type
A set of key-value pairs of an object, represented by a colon structure.

animal: dogs

Convert it to a Python data structure, as follows:

{
    
    'animal': 'dogs'}

Assign all key-value pairs.

hash: {
    
     name: Steve, foo: bar }

Convert it to a Python data structure, as follows:

{
    
    'hash': {
    
    'name': 'Steve', 'foo': 'bar'}}

assign the list

lists : [1,2,3]

Convert it to a Python data structure, as follows:

{
    
    'lists': [1, 2, 3]}

assign the tuple

tuples : (1,2,3)

Convert it to a Python data structure, as follows:

{
    
    'tuples': '(1,2,3)'}

When assigning lists and key-value pairs, converting them into Python data structures can be directly used as lists and dictionaries;
when assigning tuples, they are also strings after conversion;
the final output is a dictionary type, which can be obtained by key value;

YAML, array
The array structure mentioned here is different from [1,2,3,4], as follows:

cool_list:
  - 10
  - 15
  - 12

hard_list:
  - {
    
    key: value}
  - [1,2,3]
  - test:
      - 1
      - 2
      - 3

twice_list:
  -
    - {
    
    a: b}
    - {
    
    c: d}
    - {
    
    e: f}

Convert it to a Python data structure, as follows:

'cool_list': [10, 15, 12], 
'hard_list': [
    {
    
    'key': 'value'}, 
    [1, 2, 3], 
    {
    
    
        'test': [1, 2, 3]
    }
],
'twice_list': [
    [
        {
    
    'a': 'b'}, 
        {
    
    'c': 'd'}, 
        {
    
    'e': 'f'}
    ]
]

When you write the following data structure, it will also be automatically converted into a dictionary type, such as: {'key': 'value,val2'}

key:
    value,val2

YAML, scalar
A scalar is the most basic, indivisible value; similar to primitive data types

String; Boolean; Integer; Float; Time; Date; Null

int: 12
float: 12.3
string: pets
bool: true
None: null
time: 2001-12-14t21:59:43.10-05:00
date: 2023-06-27

Results of the

{
    
    
   'int': 12, 
   'float': 12.3, 
   'string': 'pets', 
   'bool': True, 
   'None': None, 
   'time': datetime.datetime(2001, 12, 14, 21, 59, 43, 100000, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=68400))), 
   'date': datetime.date(2023, 6, 27)
}

The time uses the ISO 8601 format, and T is used to connect the time and date, and finally use + to represent the time zone; the
date must use the ISO 8601 format, that is, yyyy-MM-dd;
bool type: true, True, false, False are all available;
can be used ~ means null;

YAML, String Details
String is the most complex, but most common data type.
By default, strings do not use quotation marks '' "" wrapped in
basic writing

str: 这是一行字符串

Convert it to a Python data structure, as follows:

{
    
    'str': '这是一行字符串'}

When should quotation marks be used? When the string contains spaces or special characters, etc.

str_s: "字符串包含 空格&特殊字符!@#$%^&*()"

Convert it to a Python data structure, as follows:

{
    
    'str_s': '字符串包含 空格&特殊字符!@#$%^&*()'}

Note that double quotes "" do not escape special characters

str1: 'test\n1'
str2: "test\n2"

Convert it to a Python data structure, as follows:

{
    
    'str1': 'test\\n1', 'str2': 'test\n2'}

Multiple lines can be split, and each line is a space, but it should be noted that their levels must be consistent

st_string: hello
           world

Convert it to a Python data structure, as follows:

{
    
    
   'st_string': 'hello world'
}

YAML, type coercion
YAML allows the use of two exclamation marks to coerce the data type

is: !!str 123
sf: !!float '12.22'
si: !!int '222'

The execution results are as follows

{
    
    
  'is': '123', 
  'sf': 12.22, 
  'si': 222
}
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)

Strive hard and keep surpassing your own limits; Perseverance and courageous steps forward; Enthusiasm, never give up belief; Dreams in mind, chasing a brilliant future; Only by working hard all the time can we reap infinite possibilities. Believe in yourself, you can do it!

Only struggle can let dreams light up the road to the future. Don't be afraid of difficulties, but meet challenges with courage and perseverance. Every step is an opportunity for growth. If you keep working hard, you will surely reap a brilliant life. Believe in yourself and move forward firmly!

As long as you work hard, success will be inevitable; if you persist in pursuing, your dreams will come true; every setback is a stepping stone for growth, and you will discover your inner strength when you face difficulties bravely. Believe in yourself and keep fighting!

Guess you like

Origin blog.csdn.net/csdnchengxi/article/details/131439538