Ali test engineer teaches you how to prepare test data for automated testing

Everyone knows that most of the tests need to prepare test data. For example, manual testing requires some basic data, such as configuration data, etc., which needs to be prepared; and automated testing and performance testing, the basics need to be prepared. , The data generated during dynamic operation is also needed. This involves the concept of data.
Ali test engineer teaches you how to prepare test data for automated testing
1. Classification of test data

We can divide the test data into some categories:

Basic data: For example, some content management systems will configure the basic configuration data such as the title of the site and friendly links;

Stock data: that is, existing data. For example, when testing some e-commerce sites, some commodity information, category information, logistics information, etc. will be inserted in advance;

Dynamic data: It can also be called session data. For example, when testing the function of publishing commodities on e-commerce sites, they often create some new commodities.

We can imagine that the basic data can be easily consistent with the production environment. The inventory data of the test environment will be less than the online environment, and the dynamic data of the test environment may not be as real as the online environment.

Here we need to discuss the magnitude and authenticity of the test data.
Ali test engineer teaches you how to prepare test data for automated testing
Second, the magnitude of the test data

In most cases, the magnitude of the test data is not much generated in the environment. So the test data can be a subset of the real data.

If you have a production-like environment or a pre-release environment, you can try to keep it on the order of the online data. Such problems caused by the amount of data that are not easily measured in the test environment can be measured in the pre-release environment.

3. The authenticity of the test data

The data in our test environment is often different from the data generated by real users. For example, when testing the forum system, we may have so few stickers in the post, and the size is also just right, while the online users may have a variety of stickers, which leads to unexpected problems.
Ali test engineer teaches you how to prepare test data for automated testing
4. How to prepare basic and stock data

The more consistent the base and inventory data are with the online environment, the higher the probability of finding problems in the test. Generally speaking, you can have the following strategies

1. Full volume + desensitization strategy: directly and regularly desensitize online data and import it into the test environment. Desensitization is a must here, and the severity of problems caused by data leaks is often much more serious than ordinary online bugs.

2. Quantitative + desensitization strategy: only upload some online data, for example, only pull 1000 products online and 1000 user information, and then do desensitization. The technical implementation difficulty here will be relatively high, after all, it is necessary to straighten out the association table.

3. Crawler strategy: If it is a new project / product, there is no online inventory data to guide, then you may have to go to a friend to crawl some data and lead to the test environment for testing. For example, to make a travel site, there is no user's travel notes at the beginning, at this time it is necessary to go to a similar site to crawl a little to test.

4. Generate dynamic data: If there is no data online and no friends or businessmen crawl, then it is necessary to generate some data in a human or automated manner. If the system is simple, you can use sql to run. If it is more complicated, you may need to call the interface or generate it in an automated way. You can also manually create some data when there is no difference.
Ali test engineer teaches you how to prepare test data for automated testing
V. About dynamic data

After doing automation or interface testing, people often generate large amounts of dynamic data. Then the question is coming.

Where does this data exist? What does that mean? If we need to create a product in an automated way, where should the product information and image address be placed? In fact, this is a persistent problem.

1. Put in the file: There are many file formats to choose from, such as xml / csv / json / yaml, etc. However, excel is not recommended, after all, it is a proprietary format, which is not too extensible. And once excel is upgraded, your parsing code and library may also need to be changed once, um, strongly not recommended.

2. Put it in the database: Crawl some commodity information into the database, and then read the database is also a good way, but also familiar with the usage of SQL, often asked in interviews, in addition, you can use the database transaction mechanism to clean up the test data

3. Dynamically generated in the code: such as dynamically randomly generating the user's name, gender, and age

After the data is generated, there is a problem of cleaning up. Cleaning up the problem is actually a problem of the data life cycle, the test data should have the following life cycle

1. Short-term data: data deleted after the use case is over. Generally, the data for performance testing online is such short-term data

2. Long-term data: The data from the use cases is okay to put there, and can always exist. Too much data can sometimes affect the performance of the test environment

It is recommended to make short-term data for the data ran out of automated testing, and come out and find a way to clear it, because the frequency of automated running can actually be very high. If a bunch of data is generated every time, the magnitude of the data may become very large in the short term The performance of the test environment has an impact.

From the above, I have roughly understood how to prepare test data. I hope to bring you good suggestions. If you have any good suggestions, please feel free to comment in the comment area.

Guess you like

Origin blog.51cto.com/14797788/2489162