current position:Home>Construction and development of automatic test platform based on HTTP runner

Construction and development of automatic test platform based on HTTP runner

2022-04-29 09:53:55Incoming Thor

Objective record
1 Preface
1.1 Purpose of the document
1.2 Terminology
2 Implementation principle of interface automation test
2.1 Principles of implementation
2.2 Advantages and disadvantages of implementing interface automation test
3 Implementation scope and objectives
3.1 Scope of implementation
3.2 Implementation objectives
3.3 Overall implementation strategy
4 Implementation content of the technical scheme
4.1 httprunner Features and advantages :
4.2 httprunner How it works :
4.2.1 First step : Environment building
4.2.2 The second step : Write a script
4.2.3 The third step : Perform the test
4.3 Jenkins Installation, deployment and configuration of
4.3.1 First step : Code upload svn
4.3.2 The second step :jenkins Deploy
4.3.2.1 jenkins New project
4.3.2.2 jenkins Description of the project
4.3.2.3 jenkins Code configuration for
4.3.2.4 Select Delete workspace before build
4.3.2.5 perform windows Batch command
4.3.2.6 Test report css Rendering
4.3.2.7 Configuration of test report
4.3.3 The third step : View test report
4.3.3.1 Open the project directory , Click on HTML_Report
4.3.3.2 Select... Under the corresponding timestamp .html file
4.3.3.3.1 Request
4.3.3.3.2 Validators
4.3.3.3.3 Staristics
5 Implement management recommendations
5.1 Implementation strategy suggestions
5.2 Staffing
5.3 Implementation plan

Preface

Purpose of the document

The interface automation test scheme is to use the automation framework for the interface test of Lama system , The technology and implementation scheme written to achieve the goal of automatic interface testing .
The main purpose of the document is to provide the technical scheme of interface automatic test 、 Implementation content 、 Implementation steps , As well as the key technical implementation means .

Terminology

  • Httprunner: It is an interface automation framework developed by Dajiang company , be based on http agreement
  • Hrun:httprunner Start command for executing interface test under the framework
  • Validate: Assertion , To verify whether the returned data is consistent with the passed in parameters

Implementation principle of interface automation test

Principles of implementation

In the process of interface automation testing, it is impossible for tools to complete all the work , Tools are still an aid in the testing process . For tools, it is mainly to solve the repetitive tasks in the testing process . In addition, implement automated testing , There are also higher requirements for the tested system , The implementation principles of interface automation test are summarized as follows :

  1. Use automated tools to test , The development of the tested system is required to be relatively stable , Less functional changes ;
  2. Before writing automated test scripts , The interface of the tested system is relatively stable ;
  3. Interface test automation requires that the test data in the test data environment is relatively independent , Meet the requirements of complete control data test ;
  4. The version of the tested system is required to run stably , Fewer test aborts occur ;
  5. Perfect 、 Reusable data parameters , Script library is a long-term accumulation process .

Advantages and disadvantages of implementing interface automation test

Although there are many limitations between automatic test and manual test of interface , But it also has its advantages , With the development of automatic testing technology and tools , For the stable function of the product under test , Automated testing plays a more and more important role . Using interface testing can speed up the whole testing process , After the release of the product version , Test scripts can be reused for testing , say concretely :
The advantages of automated testing :

  • Improve test efficiency , Reduce the cost of testing ;
  • Manual labor with strong repeatability can be realized independently by automation ;
  • Rapid regression testing , Improve the speed and quality of new version release ;
  • Avoid mistakes easily made by manual testing , Such as : Error testing , Leak test , More tests, etc ;
  • It's easy to implement concurrency testing ;
  • Test reusability , Reusing scripts and data is easy .

The disadvantages of automated testing :

  • Standardized test management , Test requirements , The test case ;
  • Can't creatively find the defects that the test script has no design ;
  • High quality test cases ;
  • High quality automation test engineer ;
  • The requirements for the test environment are relatively strict ;
  • Changes in test requirements may cause a large number of test cases , Automatic test script modification 、 maintain .

Implementation scope and objectives

Scope of implementation

  1. Tool range : At present, we are considering using svn As a remote code warehouse ,httprunner As the main framework ,jenkins As a continuous integration tool
  2. System scope : Locate the system in the basic test environment of the test center ;
  3. Scope of the test phase : New functional testing 、 regression testing 、 And functional regression test after going online

Implementation objectives

  1. The interface automation test system should be able to complete the integration test 、 And the regression test of the function after the launch ;
  2. The interface automation test scheme can test most of the current application systems ;
  3. Realize automatic scripting 、 Automate script execution 、 Automated defect reporting and management .

Overall implementation strategy

  1. First, select the items and functions suitable for automatic testing from the current system ;
  2. Secondly, determine the stage of interface automation test ;
  3. The interface functions are combined to form a complete system test

Implementation content of the technical scheme

Httprunner Features and advantages

  • Inherit  Requests  All characteristics , Make it easy HTTP(S) All kinds of testing requirements
  • use  YAML/JSON  Describe the test scenario in the form of , Guarantee the uniformity and maintainability of test case description
  • With the aid of auxiliary functions (debugtalk.py), It is easy to implement complex dynamic computing logic in test scripts
  • Support perfect test case layering mechanism , Fully realize the reuse of test cases
  • Support perfect before and after the test hook Mechanism
  • The response results support rich verification mechanisms
  • be based on HAR Realize interface recording and use case generation (har2case
  • combination  Locust  frame , No extra work is needed to implement distributed performance testing
  • The way of execution is CLI call , But with Jenkins And continuous integration tools
  • The statistical report of test results is concise and clear , With detailed statistics and log records
  • Extremely scalable , Easy to implement secondary development and Web platform

Httprunner How it works

  • Clear test purpose (achieve a particular software testing objective)
  • Clear input (inputs)
  • Clear operating environment (execution conditions)
  • Clear description of test steps (testing procedure)
  • Clear expected results (expected results)

First step : Environment building

  1. Install... On the server python Environmental Science
  2. perform pip install httprunner
  3. Run the following command , If the version number is displayed normally , shows HttpRunner Installation successful

$ hrun -V
2.0.2
$ har2case -V
0.2.0

The second step : Write a script


Name: api Description of
Base_url: Basic website
Request:http Form of request
Method: Request mode
Url: Name of spliced interface
Json: The ginseng
Validate: Assertion

 

The third step : Perform the test

Carry out orders : hrun + api(path)

Jenkins Installation, deployment and configuration of

First step : Code upload svn

The second step :jenkins Deploy

Jenkins New project

 

Jenkins Description of the project

 

 

Jenkins Code configuration for

 

Select Delete workspace before build

 

perform windows Batch command

 

Test report css Rendering

 

Configuration of test report

 

The third step : View test report

Open the project directory , Click on HTML_Report

 

Select... Under the corresponding timestamp .html file

 

The content of the test report

Request

 

 

 

Validators

Staristics

 

 

Implement management recommendations

Implementation strategy suggestions

The strategy has the following suggestions :

  • Data coverage from the bottom up , Solve the dependency of test data , Control the correctness of the whole interface test data
  • Review coverage of test cases
  • Prepare the corresponding api file

Staffing

In the process of automatic test implementation , The following staffing is required :

  • Test Manager : Be responsible for the coverage review of test cases
  • Developer : Preparation and communication of interface documents
  • Script writer : Need to have http The basis of the agreement , as well as python The basis of language

Implementation plan

Stage

Time

Stage key tasks / Milestone goals

Plan preparation stage

Determine the objectives and scope of the project ;
Determine the implementation plan of the project ;
Determine the personnel requirements for project implementation ;
The interface automation test scheme passed the review .

Environment construction and preparation

Build an automated test environment ;
Be familiar with and understand the functional requirements of the tested system .

Test requirements analysis stage

Analyze the requirements of the tested system ;
Analyze the data requirements of the test system ;
Requirements test data , Preliminary completion of main test data .

Test script development

Complete the script framework ;
Complete the script writing and debugging of the tested function ;
Complete the parameter setting and test data of the tested script ;
Release the baseline version of the test script .

The test execution

The test execution 、 Report a problem .

Test analysis summary

test result ;
Test summary .

copyright notice
author[Incoming Thor],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290811054269.html

Random recommended