Enterprise-class interface automation test solution landing, with this Httprunner series!!

purpose

In order to quickly realize interface automation, production environment monitoring and other requirements in the actual work, as a tester, it is very important to skillfully use an interface testing tool/framework, which is also one of the embodiment of ability and value.

research

Whether online and offline everywhere are able to do interface testing tools, popular tools to choose are: Postman + Newman, Jmeter, RF, Httprunner, etc., can meet the needs, since it is to combat, and to fast, accurate, efficient, from the selection of httprunner framework to understand.

To understand

Httprunner framework fully conforms to requests+ Unittest +HTMLTestRunner interface automation test framework; Principle: Using the Requests third-party library to send HTTP/HTTPS requests to the server, the UnitTest framework organizes test cases, executes and receives returned results, and produces HTML test reports based on the Jinja2 template.

Reason:

  • Support Charle/Fiddler recording scripts to quickly generate JSON/YAML test cases

  • Supports dynamic parameter association and parameterization

  • Support for debugtalk.py hot loading mechanism

  • Support for environment preprocessing, hooks mechanism

  • Support HTML report output

  • Support CLI mode to facilitate Jenkins CI/CD

  • Easy to learn, quick to learn, have some python code base

The body of the

1. Back to one technique/tool to learn: how to automate interface testing quickly?

The key is fast, accurate and timely;

Therefore, the cost of learning must be the lowest, and individuals and even teams need to have a deep understanding of the implementation of automation.

  • After investigation, httprunner is selected as an interface automation tool

  • Reasons above: support recording, quick generation of use cases, just perfect

  • The test results then need to be shared, reported, and emailed to stakeholders

2, why to choose the Httprunner framework as the implementation of interface automation testing scheme?

First, if you just use its recording function to generate scripts, it is no different from JMeter and Postman.

Second: if the business logic does not conform to the script design, then it needs to use its debugtalk mechanism, which is coding in plain English.

Thirdly, all the automation we use ultimately needs to realize continuous integration with the help of some platforms. It is also convenient to support CLI and integrate Jenkins.

3. Next, disassemble the use process of Httprunner framework

Based on the previous general advantage: out of the box! Solve the time cost! Because of the limited time, the company requires more rapid completion of the interface automation test!

  • Har data packets were recorded by the packet capture tool (Fiddler/Charles), and test cases in JSON/YAML format were generated by har2Case command.

  • Usage: har2Case demo.har generates test cases in JSON format by default. The -y/–to-yml parameter means to generate test cases in YAML format.

  • Then you can run happily: hrun demo.json; Default output test report to reports folder, can integrate Jenkins to send email.

4, this framework as a series, there will be more chapters to introduce its use, first Po a picture to see the engineering structure:

So don’t just think of it as a tool/framework, because one day you’ll get tired of it and want to refactor it yourself.

So don’t write dead here, will change in the future!

So don’t write dead here, will change in the future!

So don’t write dead here, will change in the future!

This article uses the article synchronization assistant to synchronize