table of Contents
Affirmation
Sandbox
UI testing
Request method
cookie
Authentication
collection
variable
Execute postman script with command
Export puthon script for data-driven interface testing
Export java code to implement data-driven interface
I will ignore the basics of getting started here. You can take a look at my other case, and you will get started soon: https://blog.csdn.net/bbs11007/article/details/99703527
Assert
Need to understand the knowledge of JavaScript, because it uses many JS statements
Where are the assertions written? It must be an assertion response, that is, if we send a request and the returned value meets expectations, this is the assertion we have to do
Write a case:
: If this returns it will pass
Among them: this key represents the name of the checkpoint (not the name of the use case), this expression is assigned , this key is evaluated, and true means the test passed
: This is judged to be less than 200 milliseconds, so this can be a simple performance test.
According to the API documentation, run through, and then write assertions,
Find the template:, and then as shown below:
After clicking Send to run:
Let's count, the result is that there are no 10 data
Bugs can be mentioned at this time. Haha!
Sandbox
Refer to the official document API
You can use this chai syntax in Sandbox
Use Postman for UI testing
This interaction is very weak and unprofessional. Selenium is recommended
Briefly, this knowledge is too much.
Case:
First visit this page with postman to find the element
Writing assertion
operation result:
This is the static detection of the interface. To use this postman as a UI, you must have the front-end skills.
Request methods
GET: Get resources, you can get a resource/a group of resources
POST: Means to create a resource, create a resource/a group of resources, generally one
PUT/PATCH: Both can mean to update some resources
DELETE: delete a resource
The included example is as follows:
Cookie
This one
Open the template, pay attention to the set and get methods
How to adjust and print:
Print options
How to get cookie
Print out as shown below
Authentication:
As shown below:
Do it with postman
2.0: It is a third-party login method, such as selecting third-party QQ or WeChat to log in when logging in, without registration!
To configure first:
These texts are developed together with verification 2.0
collection container
There are several modules, each module has an interface, and there are interfaces between these modules
Each folder is the module to be tested
Script to be done before request sending, initialization
Must have, to write a script to judge
Save and run the project
edit:
Export: Common
: Publish documents
: Paid function, slightly
Import data to create collection
variable
Before
Variables, the two curly braces are to take its value chai value
E.g:
: Don’t write the value of name hard, it’s hard to write here
Take a look at the example, this shows an error message: variable name is not defined
We add an environment
Define a variable = python
There is this production variable
No error is reported after the variable is created, run and see
We can also set up other environments, first select the following picture
Add other environment, same as above!
Add a new variable to test, set the new variable = php
After running, the variable changed
If you set the same variable (similar to the default value of jmeter), you can define it once in the global variable.
Execute the postman script with the command:
Domestic npm is not easy to use, go to Taobao to search cnpm, domestic use cnpm
After executing Run
installation
1. Input:
2. Input:
The installation is successful when you see this information
Export results
Copy the test data
Test Data
Test script
Press Enter to run and see the comparison of format reports:
CLI report format:
See html test report
Looking at json, open it with notepad, more than 2600 lines
Export puthon script for data-driven interface testing
Export multiple scripts, see what you are good at, such as java tesrNG, python unittest
Export python here. Support 2 and 3
I install python3.6
Install this requests
Export
Create a new file called
Use a text editor to open it (IDE is not necessary)
Copy in the code just now, the red line is newly added (routine)
Simplify the code:
Modification: Transfer the return out of the dictionary, and add an assertion
Run this script from the command line:
Ran successfully in 0.7 seconds
Hard-coded, no data-driven, just postman our variables are not hard-coded
Then write down data-driven, and make an assertion in the loop
Run from the command line
5.46 seconds to run successfully
Export java code to implement data-driven interface
More troublesome than others, define objects and classes yourself
New Project
3 dependencies to modify the content of the xml file
This IDE is downloaded automatically.
Just build a new project in these two files (the previous engineer in the picture)
: On behalf of postman
Field deserialization in java is the same as the following, define the object yourself
The fields are the same as above
Both get and set methods are automatically generated by IDE (Baidu).
Copy from code, compare
Right-click to run the result
Summary review java:
1. Create a new project first and add dependencies
2. Definition
3. Write the script