This is the 28th day of my participation in the August Text Challenge.More challenges in August
What is a debugtalk
We’ve covered httprunner’s project structure in previous articles. Debugtalk. py is used to represent the project root directory, and we can also customize some methods in it for API and case use.
Debugtalk used to hook
Httprunner-03-hook For details
Debugtalk is used for data transfer
Httprunner-04-extract (httprunner-04-extract) : Httprunner-04-extract (Httprunner-04-extract) : Httprunner-04-extract (Httprunner-04-extract) : Httprunner-04-extract (Httprunner-04-Extract) : Httprunner-04-Extract (Httprunner-04-Extract) : Httprunner-04-Extract (Httprunner-04-Extract)
Define the function that gets the token
In debugtalk
def get_token() :
return 'xxxtokenxxx'
Copy the code
Reference get_token in case
As follows: In variables in Step2, call the function with token: ${get_token()} and assign the token to the variable token
config:
name: "demo testcase"
variables:
device_sn: "ABC"
username: ${ENV(USERNAME)}
password: ${ENV(PASSWORD)}
base_url: "https://getman.cn/mock"
# setup_hooks:
# - ${hook_print(setup)}
# teardown_hooks:
# - ${hook_print(teardown)}
teststeps:
-
name: demo step 1
api: api/demo_api.yml
variables:
user_agent: 'the Mozilla / 5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'
device_sn: $device_sn
# extract:
# - token: content.name
validate:
- eq: ["status_code".200]
setup_hooks:
- ${hook_print(setup)}
teardown_hooks:
- ${hook_print(teardown)}
-
name: demo step 2
api: api/demo_api2.yml
variables:
token: ${get_token()}
validate:
- eq: [reason.OK]
Copy the code
In the test report
Step2 the headers
You can see throughdebugtalk
In theget_token
Functiontoken
It has been successfully transmittedstep2
Of the callapi
的 headers
In the.
summary
Debugtalk has reserved custom entry points for testers, so you should already feel that HttpRunner is an open testing framework with its own personality. It encapsulates common functions and modules so that you only need to maintain a JSON/YAML copy for reuse. However, for those special scenarios and requirements, you can customize them through DebugTalk, which can meet the integrity of the framework and also connect to other systems. This design is really clever.
HttpRunner is an excellent native developer and we should fully support it, as I do. But as a test developer, I would probably compare it to RF, Pytest, etc. Because HttpRunner test execution is scheduled through UnitTest, and it maintains JSON/YAML, which may not be the most elegant way for some test developers, and each interface needs to be wrapped, of course we can use data-driven. But we have to classify the particularity of each interface and then do data-driven, the workload is relatively large. Pytests for pure code are relatively rare because they can be quickly encapsulated. RF is much easier to use and maintain based on Pytest. Because of this, HttpRunner isn’t widely used, but that doesn’t mean it’s a great framework.
Finally, it is suggested that teams with development ability and funds can develop their own testing framework according to their business needs. For small teams, we can choose an open source testing framework suitable for them. Don’t forget to give back and support the community.
Thank you for reading, don’t forget to follow, like, comment, forward four consecutive yo!