Interface test series

Why do you want to do this? Writing a series of articles summarizing my past experience in interface testing is a systematic thinking and knowledge building. At the same time, we also hope to get more opinions and feedback from interested students, so that we can make this part better.

Series entrance:

  • One: What is interface testing
  • Two: simple use of POSTMAN
  • Postman sends post requests in other scenarios
  • Four: Postman environment and use case set
  • Five: Postman assertion
  • Six: Postman runs the use case set
  • Seven: Postman run parametric use case set
  • Eight: Summary POSTMAN

Overview of Interface Testing

What is an interface

Today’s projects are basically built on various apis. You have apis that you provide, you have apis that you call other people. Apis are like keys. Every door needs a key to open. You can’t open the door without a key. So the API is important because it’s a passport to the online world. An API is a way for a program to be called, and it dictates how it should be used. These include: protocol, address, parameter and response, etc.

Why interface tests

Interfaces play a very important role in the popularity of microservices. Because services interact with each other using interfaces. For testing, the UI is volatile, and unit testing is largely the responsibility of development. Interfaces are a more appropriate pointcut and more stable way to test. The advantage of this approach to testing lies in the balance of costs and benefits. There is no need to spend a lot of costs to see the benefits, and it can well reflect the quality control. Therefore, interface testing is in place in the current testing industry.

Classification of interface tests

In terms of protocol, interface tests can be divided into the following categories:

  1. TCP interface
  2. HTTP protocol Interface
  3. The TCP protocol is actually the socket interface, which is seldom encountered in enterprise development. The HTTP protocol, which is the most common and important, involves a lot of usage details, which will be covered later. RPC protocols, such as Dubbo and other self-developed RPC protocols, are generally built on TOP of TCP or HTTP. The characteristic of this protocol is that it has its own set of architectures, which can be used for testing. Many need to write their own code to test.

earnings

The benefits of interface testing can be measured in two ways. One is the coverage of the interface, the other is the effect of the interface test. The degree of coverage is well understood, that is, how many scenes are covered. Measuring effectiveness is not so easy. It is generally measured in terms of code coverage and the degree of automated testing per release.

Introduction to interface test tools

There are basically two kinds of interface testing on the market: interface testing products and interface testing platforms. Interface testing products postman, Jmeter, Charles and so on are currently more mainstream. The interface testing platform is basically self-developed or open source platform products, here I recommend YAPI, can think of interface testing functions are basically.

Tool to compare

Here is a brief overview of the tools we use, not a comprehensive objective evaluation, but a footnote for our own understanding.

  • Postman HTTP interface is a very comprehensive testing tool. There are parameterized, data-driven, batch execution, custom assertions, and multi-endpoint synchronization.
  • Jmeter is biased towards performance testing, also for HTTP interfaces. There are parameterization, Hook, batch execution, etc., basically for the application scenario of stand-alone version. It would be more suitable with performance testing.
  • Charles favors network packet capture, also for HTTP interfaces. Weak interface test function. Not much. As you can see from the above, Postman is a good tool for testing HTTP interfaces. If you have debug requirements you can use Charles, if you have performance requirements you can use JMeter, if you have pure interface testing, I think Postman basically covers all scenarios. Later, I will also make an in-depth analysis of Postman from the perspective of scenes.

Interface test platform

In fact, in the interface testing platform dimension, there are several good products, I personally prefer YAPI. Because his entry point is good, now ecology is also doing more powerful. From the perspective of YAPI product design, the interface test platform needs to solve the following scenarios:

  1. Interface documentation visualization, the need to display interface documentation on the platform, so that development and testing have a unified entry
  2. The platform supports interface testing scenarios: parameterization, data-driven, assertion, and so on
  3. Platforms can provide mock services and debugging tools
  4. Collaborative approach, organizing interfaces and test case collections from a project or application perspective as entry points. Of course, Hitchhiker was a good product besides YAPI.

summary

This article lists some of the tools and platforms that you can use postman if you are a beginner to interface testing. If you want to use a platform approach that allows teams to collaborate on interface testing, try YAPI.