Interface and interface testing tool jmeter

Interface and interface testing tool jmeter

Interface interview questions

What is an interface

The interface is a standard of the ability to call or connect to other services provided by the internal module to the module, and the external system

webservice and HTTP api interface

  1. The webservice interface is transmitted through the soap protocol through HTTP, and the request message and the return message are both in XML format
  2. The http api interface is a method of distinguishing calls by path through the HTTP protocol. The format of the request message is in the form of key-value, and the return message is generally a json string.

What is interface testing

Interface testing is a test for testing the interface between system components. Interface testing is mainly used to detect the interaction points between external systems and systems and between various internal subsystems. The focus of the test is to check the data exchange, transmission and control management process, as well as the mutual logical dependence between the systems.

Interface test process

Requirements discussion, requirements review, scenario design, writing use cases, preparing data, and executing tests

  1. Requirements review, familiar with business and requirements
  2. Develop and provide interface documents (interface description, URL, request method, request parameter, parameter type, request parameter description and return parameter description must be provided)
  • Write interface test cases
  • Conduct a use case review
  • Start the test after the test
  • Price increase test report

How to analyze whether the problem is front-end or back-end

If the data sent is correct, but the data fed back by the backend does not meet the needs, it is a backend problem; if the frontend does not request an interface, or the data sent at the time of the request does not match the requirements, then it is a frontend problem at this time

What are the test points for interface testing?

  • Purpose: Test the correctness and stability of the interface
  • Principle: Simulate the process in which the client sends a request message to the server. After the server receives the request message, the server processes the corresponding message and returns a response to the client, and the client receives the response.
  • Focus: Check the data exchange, transfer and control management process, including the number of processing
  • Core: Continuous integration is the core of interface testing
  • Advantages: Bring efficient defect monitoring and quality supervision capabilities to highly complex platforms. The more complex the platform, the larger the system, and the more obvious the effect of interface testing.
  • The focus of use case design: mainly test the outermost two types of interfaces in the case of passing, data entering the system interface and data out of the system interface

What are the back-end interfaces tested?

  1. Business function: normal scene, abnormal scene
  2. Boundary analysis test:
  • Boundary analysis of input and output parameters: cover all required parameters, the combination can be the first parameter; parameter has, no or null; parameter order, number, type; parameter type value size, input value range; parameter contains special characters
  1. Parameter combination test
  2. Abnormal situation test: idempotent (repetitive submission), concurrent test, transaction test, large number test (tests that process large amounts of data at the same time, and when the amount of DB data is large, test DB operations)
  3. Performance testing: response time, throughput, concurrency, server resource usage (CPU, memory, io)
  4. Safety test:
  • Whether sensitive information is encrypted: whether the front-end and back-end data transmission is encrypted; whether the log information is encrypted
  • sql injection

The back-end interface is tested once, and the front-end is tested again. Is the test repeated?

  1. Basic function test
  2. Boundary analysis test
  3. Storage test: screen rotation, continuous loading of pages, opening multiple windows, user-type calling, multi-threaded download
  4. Performance Testing:
  • Response time: install, start, jump
  • Memory, CPU, fps, power, flow, temperature
  1. Stability test
  2. Compatibility test:
  • Network (2G, 3G, 4G, 5G, wifi, disconnected network, weak network)
  • Fractional change rate
  • model
  • platform
  1. Interrupt the test (such as: incoming call, text message or alarm clock)
  2. Interactive test (call camera, share function)
  3. UI testing includes functional testing, boundary analysis testing, and performance testing from the two testing activities of the system. The other parts have their own characteristics or different concerns and require special testing.

Interface testing can focus on server logic verification, while UI testing can focus on page display logic and interface front-end and server integration verification

Interface test quality valley standard

  • Whether the business function coverage is complete
  • Whether the business rule coverage is complete
  • Whether the parameter verification meets the requirements (boundary, business rules)
  • Is the coverage of abnormal interface scenarios complete?
  • Whether the interface coverage meets the requirements
  • Whether the performance index meets the requirements
  • Whether the safety index meets the requirements

Why do interface tests

Whether the front-end and back-end transmission, log promises and other information are encrypted and transmitted also needs to be verified, especially when it comes to user privacy information, such as ID cards, bank cards, etc.

  1. The lower the bug is found, the lower the repair cost
  2. The front end is edited casually, the interface is tested, and the back end does not need to be changed.
  3. Check the security and stability of the system. The front-end parameters are not credible. For example, in JD Shopping, the front-end price cannot be passed in -1, but the interface can be passed in -1.
  4. Today s system complexity continues to rise, the cost of traditional test methods has increased sharply and the test efficiency has dropped significantly. Interface testing can provide a solution in this situation
  5. There are many systems that have separate front-end and back-end architectures. From a security perspective:
  • From a security perspective, relying only on the front-end for restrictions can no longer meet the security requirements of the system. The back-end needs to be controlled as well. In this case, verification from the interface level is required.
  • Whether the front-end transmission, log printing and other information is encrypted also needs to be verified, especially when it comes to the user s private information, such as ID cards, bank cards, etc.


Realize sha256 encryption of interface input parameters through BeanShell script

  1. Preliminary preparation: find sha256.js for development
  • windows: put sha256,js in the bin directory of jmeter
  • mac: put sha256.js in a root directory
  1. Steps:
  • Add thread group-"sampler-" dug sample (debugging)
  • dug sampler-"pre-processor-"JSP223 Precessor
var amdin_password=sha256("${password}");"************************ *****************");;"******************************************");
  • After execution, print out the encrypted parameters in the log

The return value of the previous interface is the input parameter of the next interface

  1. Steps
  • Add HTTP request-"Select the regular expression extractor in the post processor (json Extractor)
  • In json Extractor, enter the fields that need to be retrieved, and pay the extracted results to variables
  • Create a new http request, and then pass in the request parameters

jmeter connect to Mysql database

If you get the data of a specific value from the data returned by the previous request, and output it as an array

  1. Prerequisite preparation:
  • Download jsonbj.jar and put the jar package in the lib folder
  1. Steps
  • Add HTTP request-"Add post processor Beanshell PostProcessor"~~~~~~~~~~~~~~~~~~~~~~~~~json~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
import net.sf.json.*;
String jsonStr = prev.getResponseDataAsString();

JSONObject jsonObject=JSONObject.fromObject(jsonStr);

String dataStr = jsonObject.get("data").toString();

JSONArray dataArray = JSONArray.fromObject(dataStr);
String str= new String("B");"str:"+str);

// Status 2 list 
JSONArray res = new JSONArray();
for (int len = dataArray.size(), i = 0; i < len; i++) {
JSONObject obj = (JSONObject)dataArray.get(i);
int status = Integer.parseInt(obj.get("Status").toString());
String BuyOrSell = obj.get("BuyOrSell").toString();
if (status == 2 && BuyOrSell.equals(str)){
String Str1=res.toString();