Interface interview questions
What is an interface
An interface is a standard for the ability to call or connect internal modules to modules and external systems to other services
Webservice and HTTP API interfaces
- The WebService interface uses THE SOAP protocol and HTTP to transmit the request packets and return packets in XML format
- HTTP API is a method to distinguish calls based on HTTP paths. Request packets are in key-value format and return packets are usually JSON strings
What is an interface test
Interface test is a test to test the indirect interface of a system component. Interface testing is mainly used to detect the interaction points between external systems and internal subsystems. The focus of the test is to check the data exchange, transfer and control management process, as well as the mutual logical dependence between systems.
Interface Test Process
Requirements discussion, requirements review, scenario design, use case writing, data preparation, test execution
- Requirements review, familiar with business and requirements
- Develop and provide interface documentation (interface description, URL, request method, request parameters, parameter types, request parameter description, and return parameter description must be provided)
- Write interface test cases
- Conduct use case reviews
- Start the test after lifting 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 feedback from the background does not meet the needs, that is the background problem; If the front end doesn’t have a request interface, or if the request doesn’t send the required data, then the front end has a problem
What are the interface test points?
- Objective: To test the correctness and stability of interfaces
- Principle: The client sends a request packet to the server. The server processes the corresponding packet after receiving the request packet and returns a response to the client. The client receives the response
- Key points: check the data exchange, transfer and control management process, including the number of processing
- Core: Continuous integration is the core of interface testing
- Advantages: Efficient defect monitoring and quality monitoring capabilities for highly complex platforms. The more complex the platform and the larger the system, the more obvious the effect of interface testing
- Key points of use case design: The outermost two types of interfaces are mainly tested in the case of pass, data entry system interface and data outflow system interface
What does the back-end interface measure?
- Service functions: Normal scenario, abnormal scenario
- Boundary analysis test:
- Boundary analysis of input and output parameters: covering all required parameters and combining prior parameters; Parameter yes, none, or NULL; The order, number and type of parameters; Parameter type The size of the value and the range of the input value; The parameter contains special characters
- Parameter combination test
- Abnormal case testing: idempotent (repeated submission), concurrent testing, transaction measurement, large number of tests (tests that deal with a large number of data at the same time, test DB operation when DB data is large)
- Performance tests: Response time, throughput, concurrency, server resource utilization (CPU, memory, IO)
- Safety test:
- Whether sensitive information is encrypted: Whether data transmission at the front and back ends is encrypted; Whether log information is encrypted
- SQL injection
The back-end interface is tested once, the front end is tested again, is it repeated test
- Basic functional testing
- Boundary analysis test
- Storage tests: screen rotation, continuous page loading, open multiple Windows, application type call, multithreading download
- Performance test:
- Response time: install, start, jump
- Memory, CPU, FPS, power, flow rate, temperature
- Stability test
- Compatibility test:
- Network (2G, 3G, 4G, 5G, wifi, disconnected, weak network)
- Points and variable ratio
- models
- platform
- Interrupt tests (e.g., incoming calls, text messages, or alarm clocks)
- Interaction test (call camera, share function)
- UI testing consists of two testing activities: functional testing, boundary analysis testing, and performance testing, while the other parts have their own characteristics or concerns that require special testing.
Interface testing can focus on verifying with server logic, while UI testing can focus on verifying page display logic and interface front end integration with server
Interface testing quality valley standards
- Whether service function coverage is complete
- Whether business rule coverage is complete
- Parameter verification meets requirements (boundaries, business rules)
- Whether the coverage of interface exception scenarios is complete
- Whether the interface coverage meets the requirements
- Whether the performance indicators meet the requirements
- Check whether safety specifications meet requirements
Why do interface tests
Whether the information such as transmission, log promise is encrypted transmission also needs to be verified, especially involving the user’s privacy information, such as ID card, bank card and so on
- The more low-level a bug is found, the cheaper it is to fix
- Front-end plait casually, interface test good, back-end need not change.
- Check the security and stability of the system. The front-end parameter transmission is not credible. For example, jingdong Shopping, the front-end price cannot be passed -1, but the interface can pass -1.
- Interface testing can provide a solution to the increasing complexity of the system and the sharp increase in the cost and decrease in the efficiency of traditional testing methods
- There are a lot of systems today where the front and back end architectures are separated, from a security perspective:
- From the perspective of security, only relying on the front end to limit has completely failed to meet the security requirements of the system, it needs to be controlled by the back end, in this case, it needs to verify from the interface level.
- It is also necessary to verify whether the information transmitted at the front and back ends and log printing is encrypted, especially the privacy information of users, such as ID cards and bank cards
Jmeter
Through BeanShell script, the interface input parameter SHA256 is encrypted
- Preparation: look for sha256.js for development
- Windows: Put sha256 and JS in the bin directory of JMeter
- MAC: Put sha256.js in a root directory
- Operation steps:
- Sampler – “Dug sample”
- Dug Sampler – “JSP223 Precessor –
load("sha256.js");
var amdin_password=sha256("${password}");
log.info("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
log.info(amdin_password);
log.info("* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
vars.put("password",amdin_password)
Copy the code
- After execution, the encrypted parameters are printed in the log
The return value of the previous interface is the input parameter of the next interface
- steps
- Add HTTP Request – select regular expression Extractor in the back processor (JSON Extractor)
- In json Extractor, enter the fields that need to be fetched and pay the extracted results to the variable
- Create a new HTTP request and pass in the request parameters
Jmeter connects to the Mysql database
If you get the data of a particular value from the data returned by the previous request and output it as an array
- Prerequisites:
- Download jsonbj.jar and place the JAR package in the lib folder
- steps
- Add HTTP Request – Adds the post-processor Beanshell PostProcessor
log.info("~~~~~~~~~~~~~~~~~~~~~~~~~json~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); import net.sf.json.*; / / interface object returned String String jsonStr = prev. GetResponseDataAsString (); // Convert string to object JSONObject JSONObject = jsonObject.fromobject (jsonStr); DataStr = jsonObject.get(dataStr = jsonObject.get)"data").toString(); DataArray = jsonArray.fromobject (dataStr); // Convert string to array object JSONArray dataArray = jsonarray.fromobject (dataStr); String str= new String("B");
log.info("str:"+str); 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)){ res.add(obj); }} // The collated array log.info(res.tostring ()); String Str1=res.toString(); vars.put("data",Str1);
Copy the code