YAML/Excel/CSV? Automated test test data management application, test veteran summary...


foreword

Whether it is interface automation or UI automation, automated testing should encapsulate data modules and config modules, that is, test data and configuration files.

Python automated testing: https://www.bilibili.com/video/BV16G411x76E/

With the continuous increase of automation use cases, more and more test data needs to be maintained, and the maintenance cost is getting higher and higher. How to effectively manage test data is also a problem worth exploring in the practice of automated testing. And with the development of technology and the continuous innovation of tools, the accumulation of methodology and practical experience, the management of test data in automated testing is also constantly iterating and evolving.

Script and Data Bundle

In the early days of learning automated testing, linear scripts were basically used, that is, test data and test scripts were bundled together.

This is also the stage that every beginner will go through. The advantage of this is that a demo can be quickly implemented to better help beginners advance from manual testing to automated testing. For example, UI automation is to simulate human operations on the browser. A series of operations such as opening the browser, locating elements, operating elements, simulating page actions, asserting results, etc., the linear script corresponds to this series of operations, which helps beginners to better understand and get a positive feedback.

However, in practical applications, this method will not be used.

Because it may be easy to maintain a small number of test cases at the beginning, but as time migrates, product iterations, and test suites grow, the scripts will become more and more bloated, with poor maintainability and heavy workload, which is contrary to the improvement of automated testing. The essence of productivity.

configuration file

Write some public data into the configuration file in the form of key-value pairs, and use related APIs to read the configuration information. The format of the configuration file can be yaml, json, xml, properties, ini, toml, etc.

The configuration files here are mainly used to manage some public, frequently used, and small-scale test data.

For example:
1. In the interface automation test, the domain name is relatively fixed, but the request paths of different interfaces (such as: /register, /login) are different, then the domain name (such as: https://xxxxxxx .com) into the configuration file. During the test, you only need to splice the instantiated domain name with the request path (thus saving maintenance costs and improving test efficiency to a certain extent.

2. In the UI automation test, to test the business of each module of a website, the premise is that the user logs in. At this time, the test account used to log in is often fixed, so this set of user names and passwords can be written into the configuration quoted directly in the document. Compared with using a dedicated file or database to manage this set of data, it is more efficient and convenient to write in the configuration file.

3. Database configuration information, including: host, port, username, password, charset, etc.

test file

The data module in the test framework uses special files to manage test data, realizes the separation of data and scripts, reduces maintenance costs, and improves portability. The file format can be yaml, json, xml, excel, csv, etc.

The test file here is slightly different from the configuration file mentioned above. The configuration file is mainly used to store the configuration items needed for the entire project, such as URL, database information, etc., and the test file here is more related to the test case. Correspondence, applies to the same operation with different inputs to get different or the same result.

For example:
To test the login function, you need to use different accounts and passwords. Different combinations need to be tested for login scenarios. Multiple use cases may be generated under normal permutations and combinations.

In this case, multiple sets of account data can be stored in the test file, and then read in a parameterized manner (for example: use TestNG's @DataProvider annotation plus Excel data source file to realize data drive), and perform subsequent operations .

According to different business scenarios, the data magnitude and usage frequency are also different. Based on the idea of ​​separating data and scripts, the test data is stored in a special test file.

A large amount of test data, hundreds or even thousands of test data, for scenarios with a large amount of test data, the data can also be written into Excel, CSV and other files for storage and management.

file format advantage shortcoming
Excel Easy to generate data Binary files are not conducive to version management; a worksheet has a maximum of 256 columns and 65536 rows; only single transactions are supported, and there will be bottlenecks if multi-threaded reading is required
CSV Simple structure, can be edited by Excel, can be converted with Excel The file format is convenient for version management, and it is not easy to describe complex hierarchical structures
YAML Complete format, good readability, can be commented simple format
XML Well formatted Long and complicated
JSON Well formatted and readable Can't write comments, the format is rigid

To sum up, YAML and JSON have better support and writing for data structures, but YAML writing is more concise and can add comments, so the most recommended is the YAML file format.

database management

In order to facilitate the unified management of test data and consider the problem of data persistence, the test data can be stored in the database, and a database management system (such as: MySQL, SqlServer, Oracle, etc.) can be used to manage and maintain the data. The test script can be Using SQL query statements to retrieve data further reduces the coupling between scripts and data.

For example: For some basic data, such as product information on e-commerce websites, this kind of data often has a large base and its own update frequency is low, so it can be stored in the database for persistence.

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)

Everyone has unlimited potential, as long as they are willing to explore and challenge. Only by constantly striving and pursuing excellence can we achieve a great career and our own life. Believe in yourself, go forward bravely, the road will be paved step by step.

Only through constant struggle can dreams come true. When encountering setbacks and difficulties, don't be discouraged. Believe in your own abilities and persevere in pursuing your goals, and you will surely reap the joy of success.

Life lies in constantly challenging yourself, no matter what difficulties and setbacks you encounter, don't give up easily. Believe in your own ability and potential, persist in pursuing your dreams, and only then can you win your own glory on the road of life.

Guess you like

Origin blog.csdn.net/m0_70102063/article/details/130268436