Contents: Guide
-
- foreword
- 1. From entry to mastery of Python programming
- 2. Interface automation project actual combat
- 3. Actual Combat of Web Automation Project
- 4. Actual Combat of App Automation Project
- 5. Resume of first-tier manufacturers
- 6. Test and develop DevOps system
- 7. Commonly used automated testing tools
- Eight, JMeter performance test
- 9. Summary (little surprise at the end)
foreword
You may need to use jmeter plug-ins in this section or later, so you need to introduce the plug-in management tool first: plugin-manageI.x...x.jar, and put the jar package in the lib\ext directory of jmeter (because it is not convenient to put files here , you can see the assistant at the bottom)
After putting in the jar package, restart jmeter, and then there will be Plugins Manager at the bottom of the tab
After entering, select Available Plugins, search for the required plugin and click Apply Changes and Restart JMeter in the lower right corner to install the plugin
DDT data driven
Because the performance test uses multi-user concurrency, the request time also varies from several minutes to tens of minutes, so the total request volume is very large, so it is often necessary to prepare test data. The most typical scenario is to use a batch of accounts to continuously perform pressure testing on the login interface. At this time, the concept of DDT needs to be used.
1. CSV data file
By writing the test data in the csv file in advance, cyclically reading the csv file and extracting the data to achieve data drive.
(When using csv to prepare data, when it can be set with csv data files, it is resolutely different from the ${__CSVRead(,)} function, which is a chicken rib)
Add Configuration Element -> CSV Data File Settings
You can check the meaning of the parameters online, and here are a few important ones.
Variable name:
- It is the column of csv, and each column is a parameter.
- When there are multiple parameters, they are fixed to be separated by commas
- If there is an empty column in the middle or a column of data that you do not want to accept, you can use a space in the middle. For example:
user, ,pwd
Thread sharing mode:
- All locales (all threads): When the configuration primitive is outside the thread group, all thread groups share the data.
- Current thread group: The data of each thread group is independent, and each thread group circulates its own data.
- Current thread: The data of each thread (number of concurrent users) is independent, and each loops its own data.
2. Use sqllite to realize data drive
When using the sqlite database, it should be noted that sqlite not only supports multi-threading, so errors may occasionally occur when using multi-threading to write data. Therefore, when writing data, a critical controller needs to be added to allow all users to serialize.
Steps
There are many ways to prepare test data. You can use Python, csv or other methods to generate test data. Here is using JMeter by querying the database. In order to view the results conveniently, you can use the Save to Response File configuration component to save the results to a txt file for viewing.
First write the query sqlselect id, username, password, mobile from cb_account where password
= “e10adc3949ba59abbe56e057f20f883e” and LENGTH(mobile)=11 limit 100 OFFSET 500;
Configure the database information and jdbc request. For the specific configuration method, please refer to the JDBC script in the multi-protocol script. Remember to fill in the Variable names, because you need to return the value in the result.
Add a listener -> save the response to a file (note the order), generally you only need to check/fill in the content in the figure below, and nothing else. After the save is successful, you can find the saved file in the bin directory (this step is not necessary, here is mainly to see the saved result, and introduce the use of this configuration component by the way)
So far, the test data has been generated, but think about it, there are only 100 pieces of data generated this time, if you want to continue to generate more than 200, 300, 400 pieces of data, how do you do it?
It is always impossible to generate N txt files, and then read them in a loop, so it will lead to the next step to store test data in the database. .
A database called sqlite is introduced here. It is a relational database but also an in-memory database. It has no complicated installation and does not require a login account. As long as your operating system is a graphical interface and has a browser, your The computer must have sqlite installed.
Put the sqlite jar package sqlite-jdbc-3.31.1.jar into the lib directory of jmeter
Add another JDBC Connection Configuration configuration element and fill in the Variable Name for created pool
In the underground database configuration information, fill in the Database URL with jdbc:sqlite:sqltest.db, and the latter sqltest.db is actually the file name, and the path can also be written here. Similarly, if you do not write the path, it will automatically generate a db file according to the file name and store it in the bin directory
Select org.sqlite.JDBC for JDBC Driver class, and you don’t need to fill in the rest, there is no account password.
Create a table, create a table can be done through jmeter, or through tools such as Navicat. I use jmeter to create the table
The database is also created, and then the data can be written into the database. Then create a jdbc request sampler and write a sql script to write data
Then add a loop controller to this sampler, because after querying data from mysql, its data format is like this, so it needs to loop, and the number of loops is the value of mb_#
Then add another counter. Just to mention, if you know Python, the current loop controller + counter ≈ for i in len(obj)
Then combine the V function to pass the variable name into the script for writing data, pay attention to the option of query type
After running, go to the database to see the inserted data. At this point, the test data is available.
Incorporate generated data into performance tests
Some people may have doubts here, why is it so troublesome to build another database to store data. Wouldn’t it be good to use it directly after reading the data from MySQL?
This question is actually possible, but only in functional or automated testing! Because in the performance test, requesting MySQL will undoubtedly increase the pressure on MySQL, which will affect the performance test results.
Then why use sqlite? Can't you just pull out another MySQL?
The answer is yes, but not recommended. Because sqlite is a memory database, its reading speed is definitely faster than MySQL, and it is lighter than MySQL, and data files can follow the script.
Then, if you want to use sqlite data for performance testing, you need to consider a question. Is the data used by each thread independent or shared?
The following scenario is that the data used by each thread is independent, and only one controller can be used to control the number of reads.
First query sqlite to get the mobile phone numbers of all users
Put this sampler into a one-time only controller and
at login time, reference the variable
The final result is that each thread will query the sqlite database once, and then loop separately after getting the data.
Another scenario is that all data is shared, in which case the controller cannot be used only once.
The first step is to query the mobile phone number, but it must be put into the setup thread group
Add a loop controller, the loop count is ${mb_#}
Then add a debug sampler inside the loop control, and use the setProperty function to write the parameters to the property.
Finally, in the login script, the attribute can be referenced through the P function
In addition, the above uses the count function to count, but if the number of operations is greater than the data, the value will not be obtained because the subscript is out of bounds. The only thing to be solved is to replace the count function with a counter.
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
2. Interface automation project actual combat
3. Actual Combat of Web Automation Project
4. Actual Combat of App Automation Project
5. Resume of first-tier manufacturers
6. Test and develop DevOps system
7. Commonly used automated testing tools
Eight, JMeter performance test
9. Summary (little surprise at the end)
As long as you are willing to work hard, nothing is impossible. Every struggle and hard work is to achieve a better self. Therefore, please move forward bravely, meet challenges, and constantly surpass yourself!
Believe in yourself and do your best to pursue your dreams. The road will not be smooth, but as long as you are persistent and optimistic, you will be able to overcome difficulties and achieve your goals.
life is long so add oil. No matter what challenges and difficulties we encounter, we must persevere and move forward with perseverance, and use courage and perseverance to meet every sunrise and sunset in the future.