Interface testing method and device, electronic equipment and storage medium
By introducing control switches and calibration parameters into the interactive interface to be tested, the target function of the first software is simulated, the problem of low testing efficiency in the prior art is solved, and the real value is directly obtained, and the testing efficiency is improved.
Patent Information
- Application Number
- CN202411223930.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2025-01-17
AI Technical Summary
The existing software interactive interface testing methods are inefficient in testing and require additional construction of test code to simulate the behavior of other software modules.
By introducing control switches into the interactive interface to be tested, the target function of the first software is simulated using calibration parameters, and the real value is directly obtained, reducing the need to build additional code.
It improves the efficiency of software interactive interface testing, saves time to build additional test codes, and directly obtains the real value of the target function of the first software.
Smart Images

Figure CN119322740A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software testing, and more specifically, to an interface testing method, device, electronic device, and computer-readable storage medium. Background Art
[0002] For software module development, the development and verification of software interaction interfaces are essential. Currently, before testing the software interaction interface to be tested, additional test code can be added to simulate other software modules using the software interaction interface, and then the test code is run to implement the test of the software interaction interface to be tested.
[0003] However, when using this testing method to test the software interaction interface, the testing efficiency is low. Summary of the invention
[0004] The present application proposes an interface testing method, device, electronic device and computer-readable storage medium to improve the above-mentioned defects.
[0005] In a first aspect, an embodiment of the present application provides an interface testing method, the method comprising:
[0006] Obtain a test case corresponding to the interactive interface to be tested; the interactive interface to be tested is used to realize data interaction between the first software and the second software; the interactive interface to be tested includes a control switch; the test case includes a calibration interface input value of the interactive interface to be tested when the control switch is in an on state and an expected interface output value corresponding to the calibration interface input value; when the control switch is in an on state, the calibration interface input value is a calibration value of a calibration parameter; the calibration parameter is used to indicate each target function in the first software;
[0007] Test the interactive interface to be tested according to the test case, and obtain the test interface output value corresponding to the interface to be tested;
[0008] According to the test interface output value, the test result of the interactive interface to be tested is obtained.
[0009] In a second aspect, an embodiment of the present application further provides an interface testing device, the device comprising:
[0010] An acquisition module is used to acquire a test case corresponding to the interactive interface to be tested; the interactive interface to be tested is used to realize data interaction between the first software and the second software; the interactive interface to be tested includes a control switch; the test case includes a calibration interface input value of the interactive interface to be tested when the control switch is in an on state and an expected interface output value corresponding to the calibration interface input value; when the control switch is in an on state, the calibration interface input value is a calibration value of a calibration parameter; the calibration parameter is used to indicate each target function in the first software;
[0011] The test module is used to test the interactive interface to be tested according to the test case and obtain the test interface output value corresponding to the interface to be tested;
[0012] The result acquisition module is used to obtain the test result of the interactive interface to be tested according to the output value of the test interface.
[0013] In a third aspect, an embodiment of the present application further provides an electronic device, characterized in that the electronic device comprises: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above method.
[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the above method.
[0015] The present application provides an interface testing method, device, electronic device and computer-readable storage medium. In the present application, the interactive interface to be tested includes a control switch, and the test case corresponding to the interactive interface to be tested includes a calibrated interface input value of the interactive interface to be tested when the control switch is in an on state and an expected interface output value corresponding to the calibrated interface input value, and when the control switch is in an on state, the calibrated interface input value is a calibrated value of a calibration parameter, and the calibration parameter is used to indicate each target function in a first software. Therefore, when the first software is not obtained, the target functions of the first software are simulated by the calibration parameters, and the control switch of the interactive interface to be tested in the test case is in an on state. Therefore, when the interactive interface to be tested is tested through the test case, the interactive interface to be tested can directly obtain the calibrated value of the calibration parameter as the true value of each target function of the first software, so that when the interactive interface to be tested is tested, it is no longer necessary to construct additional code to simulate the first software, which saves the time for constructing additional code, thereby improving the testing efficiency of the interactive interface to be tested.
[0016] Other features and advantages of the embodiments of the present application will be described in the subsequent description, and partly become apparent from the description, or can be understood by practicing the embodiments of the present application. The purposes and other advantages of the embodiments of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A flow chart of an interface testing method proposed according to an embodiment of the present application is shown.
[0019] Figure 2 A schematic diagram showing the operation process of a control switch in an embodiment of the present application is shown.
[0020] Figure 3 Show Figure 1 The corresponding step S120 of the embodiment is a flowchart in an embodiment.
[0021] Figure 4 Show Figure 1 The corresponding step S130 of the embodiment is a flowchart in an embodiment.
[0022] Figure 5 A schematic diagram of an interface testing process in an embodiment of the present application is shown.
[0023] Figure 6 A structural block diagram of an interface testing device proposed in an embodiment of the present application is shown.
[0024] Figure 7 A structural block diagram of an electronic device provided according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0025] In order to make those skilled in the art better understand the present application scheme, the technical scheme in the present application embodiment will be clearly and completely described below in conjunction with the drawings in the present application embodiment. Obviously, the described embodiment is only a part of the present application embodiment, rather than all the embodiments. The components of the present application embodiment usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0026] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0027] See also Figure 1 , Figure 1 A flow chart of an interface testing method proposed according to an embodiment of the present application is shown, which is used for electronic equipment. The method includes:
[0028] S110: Obtain a test case corresponding to the interactive interface to be tested.
[0029] Among them, the interactive interface to be tested is used to realize data interaction between the first software and the second software; the interactive interface to be tested includes a control switch; the test case includes the calibrated interface input value of the interactive interface to be tested when the control switch is in the on state and the expected interface output value corresponding to the calibrated interface input value; when the control switch is in the on state, the calibrated interface input value is the calibrated value of the calibration parameter; the calibration parameter is used to indicate each target function in the first software.
[0030] In this embodiment, the first software and the second software may be software running in the device to be tested, and the device to be tested may be a smart phone, a tablet computer, a laptop computer, a desktop computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, a smart TV, an intelligent service terminal, etc. For example, the device to be tested may refer to a domain controller on a vehicle, that is, the first software and the second software are software running on the domain controller on the vehicle.
[0031] The executor of the interface testing method of the present application is an electronic device, which is communicatively connected to the device to be tested, and the connection method can be wired or wireless; the sub-device can be a smart phone, tablet computer, laptop computer, desktop computer, intelligent voice interaction device, and intelligent service terminal, etc.
[0032] The interactive interface to be tested is an interface for realizing data interaction between the first software and the second software. The interactive interface to be tested is used to process the data output by the first software for each target function to obtain data for input into the second software; that is, the interactive interface to be tested is used to receive the true value of each target function of the first software as the interface input value, and process the true value of each target software to obtain the interface output value, and output the interface output value to the second software.
[0033] The interactive interface to be tested includes a control switch, and the interactive interface to be tested also includes an interface body, wherein the interface body refers to the main part used to realize the data interaction function between the first software and the second software; the control switch corresponds to two switch states: an on state and a off state; when the control switch is in the on state, the interactive interface to be tested obtains the calibration value of the calibration parameter as the interface input value of the interactive interface to be tested; when the control switch is in the off state, the interactive interface to be tested obtains the real value output by the first software for each target function as the interface input value of the interactive interface to be tested. Among them, the default switch state of the control switch is the off state, that is, in the default switch state, the interactive interface to be tested obtains the real value output by the first software for each target function as the interface input value of the interactive interface to be tested.
[0034] The target function may refer to a function in the first software that is used to interact with the second software. For example, the first software includes function a1, function a2, and function a3, wherein function a2 and function a3 are used to interact with the second software (that is, the values of function a2 and function a3 are used to input the interaction interface to be tested). In this case, function a2 and function a3 are used as target functions.
[0035] The calibration parameters may include calibration parameters corresponding to each target function. A target function is indicated by a corresponding calibration parameter: the calibration value of a calibration parameter is the true value of the target function indicated by the calibration parameter.
[0036] like Figure 2 As shown, the control switch is in the on state, the interactive interface to be tested obtains the calibration value from the calibration parameter as the input of the interactive interface to be tested, which is used for processing by the interface body of the interactive interface to be tested; the control switch is in the off state, the interactive interface to be tested obtains the real value of each target function from the first software as the input of the interactive interface to be tested, which is used for processing by the interface body of the interactive interface to be tested.
[0037] Exemplarily, the control switch is named TestBaseOnCalib CfgEnable, and the corresponding values of the control switch TestBaseOnCalibCfgEnable are Enable and Disable. The target functions in the first software include RealInputInterface1, ..., RealInputInterfacex, and the calibration parameters include TestBaseOnCalibInputInterface1, ..., TestBaseOnCalibInputInterfAcex; TestBaseOnCalibInputInterfacex indicates RealInputInterfacex; when TestBaseOnCalibCfgEnable is equal to Enable, it indicates that the control switch is in the on state, and the input of the interactive interface ReadInputInterface to be tested is the calibration value of the calibration parameters TestBaseOnCalibInputInterface1, ..., TestBaseOnCalibInputInterfacex; when TestBaseOnCalibCfgEnable is equal to Disable, it indicates that the control switch TestBaseOnCalibCfgEnable is in the off state, and the input of the interactive interface ReadInputInterface to be tested is the real value of RealInputInterface1, ..., RealInputInterfacex. When TestBaseOnCalibCfgEnable is equal to Enable, the calibration values of TestBaseOnCalibInputInterface1, ..., TestBaseOnCalibInputInterfacex can be changed by calibration method to simulate the change of each target function of the first software to obtain the real value of each target function.
[0038] Based on the logic of the aforementioned control switch, when the first software does not exist, each target function ReadInputInterfacex of the first software is void (invalid), and the target function ReadInputInterfacex is indicated by the set calibration parameter TestBaseOnCalibInputInterfacex. At this time, the pseudo code of the control switch is as follows:
[0039]
[0040]
[0041] Based on the function of the aforementioned control switch, a test case can be constructed for the interactive interface to be tested, wherein the test case includes the calibrated interface input value of the interactive interface to be tested when the control switch is in the on state and the expected interface output value corresponding to the calibrated interface input value; wherein the calibrated interface input value refers to the input value used to input the interactive interface to be tested in the test case, involving the real value corresponding to each target function (in this embodiment, the real value corresponding to each target function is also indicated by the calibrated value of the corresponding calibration parameter); the expected interface output value refers to the ideal value that should be output by the interactive interface to be tested after accurate calculation and processing based on the calibrated interface input value when the interactive interface to be tested operates normally and the interactive interface to be tested has no erroneous calculation logic.
[0042] In the test case, the control switch is in the on state, so that the interactive interface to be tested obtains the calibration value from the calibration parameter as the true value of each target function, thereby achieving the purpose of obtaining the true value of each function of the first software without building additional code corresponding to the first software.
[0043] Exemplarily, when the target function includes function 1 and function 2, function 1 is indicated by parameter 1, and function 2 is indicated by parameter 2, the constructed test example is shown in Table 1, which is as follows:
[0044] Table 1
[0045] Use Case Number Control switch Parameter 1 Parameter 2 Expected interface output value 1 0x1 0x1 0x0 0x0 2 0x1 0x1 0x1 0x1 3 0x1 0x0 0x0 0x0 4 0x1 0x0 0x1 0x0
[0046] Among them, Table 1 illustrates 4 test cases, the value 0x1 of the control switch indicates that the control switch is in the on state, the calibration values of parameter 1 and parameter 2 are 0x1 and 0x0 respectively, that is, the actual values of function 1 and function 2 are also 0x1 and 0x0 respectively.
[0047] It is understandable that Table 1 is only an example, and for different first software, different target functions are involved and the actual values of each target function are different, and the constructed test cases are also different.
[0048] S120 , testing the interactive interface to be tested according to the test case, and obtaining a test interface output value corresponding to the interface to be tested.
[0049] After obtaining the test case, the interactive interface to be tested can be tested according to the test case. The interactive interface to be tested is processed based on the calibrated interface input value in the test case to obtain the interface output value output by the interactive interface to be tested as the test interface output value corresponding to the interface to be tested.
[0050] S130. Obtain a test result of the interactive interface to be tested according to the test interface output value.
[0051] After obtaining the test interface output value corresponding to the interface to be tested, the test result of the interactive interface to be tested can be determined according to the difference between the test interface output value corresponding to the interface to be tested and the expected interface output value.
[0052] For example, if the test interface output value corresponding to the interface to be tested is consistent with the expected interface output value, the test result of the interactive interface to be tested is determined to be passed; for another example, if the test interface output value corresponding to the interface to be tested is inconsistent with the expected interface output value, the test result of the interactive interface to be tested is determined to be failed.
[0053] In the present embodiment, the interactive interface to be tested includes a control switch, and the test case corresponding to the interactive interface to be tested includes a calibrated interface input value of the interactive interface to be tested when the control switch is in the on state and an expected interface output value corresponding to the calibrated interface input value; and when the control switch is in the on state, the calibrated interface input value is a calibrated value of a calibration parameter, and the calibration parameter is used to indicate each target function in the first software. Therefore, in the case where the first software is not obtained, the target functions of the first software are simulated by the calibration parameters, and the control switch of the interactive interface to be tested in the test case is in the on state. Therefore, when the interactive interface to be tested is tested through the test case, the interactive interface to be tested can directly obtain the calibrated value of the calibration parameter as the true value of each target function of the first software, so that when the interactive interface to be tested is tested, it is no longer necessary to construct additional code to simulate the first software, which saves the time for constructing additional code and improves the testing efficiency of the interactive interface to be tested.
[0054] In one embodiment, if Figure 3 As shown, S120 includes:
[0055] S210: Obtain address file.
[0056] The address file includes the address of the calibration value of the calibration parameter, the address of the switch state of the control switch, and the address of the expected interface output value.
[0057] The address file may be pre-stored in the electronic device or stored in the device to be tested, and the electronic device of the execution subject obtains the address file from the device to be tested. For example, when the device to be tested is a domain controller of a vehicle, the address file is a map file in the domain controller.
[0058] S220. Generate a test script according to the test case and the address file.
[0059] Compilation processing can be performed based on the test case and the address file to obtain a test script for testing the interface to be tested.
[0060] The address of the calibration value of the calibration parameter, the address of the switch state, and the address of the expected interface output value can be obtained from the address file; a first message of a first format is generated according to the address of the calibration value of the calibration parameter and the address of the switch state; the first message is used to rewrite the calibration value and the switch state of the calibration parameter according to the address of the calibration value of the calibration parameter and the address of the switch state; a second message of a second format is generated according to the address of the expected interface output value; the second message is used to read the expected interface output value based on the address of the expected interface output value; a test script is obtained based on the first message and the second message. The first instruction format can be the XCP protocol (Explicit Control Protocol) Short Download instruction format, and the second instruction format can be the XCP protocol UPLOAD SHORT instruction format.
[0061] Exemplarily, when the first software includes two functions, and the two functions are respectively indicated by calibration parameters TestBaseOnCalibInputInterface1 and calibration parameters TestBaseOnCalibInputInterface2, a python script can be used to traverse the address file to obtain the address of the control switch TestBaseOnCalibCfgEnable, the calibration parameter TestBaseOnCalibInputInterface1, the calibration parameter TestBaseOnCalibInputInterface2 and the expected interface output value Output1; then, a calibration request message is automatically generated according to the calibration XCP protocol Short Download instruction format to rewrite the calibration values of TestBaseOnCalibCfgEnable, TestBaseOnCalibInputInterface1 and TestBaseOnCalibInputInterface2 according to the address as the first message, and a calibration request message is automatically generated according to the calibration XCP protocol UPLOAD SHORT instruction format to read the value of Output1 based on the address as the second message, and then the first message and the second message are used as the generated test scripts.
[0062] Exemplarily, when the first software includes two functions and the two functions are indicated by calibration parameters TestBaseOnCalibInputInterface1 and calibration parameters TestBaseOnCalibInputInterface2 respectively, the address file may be as follows:
[0063] TestBaseOnCalibCfgEnable addr 0x12345671
[0064] TestBaseOnCalibInputInterface1 addr 0x12345672
[0065] TestBaseOnCalibInputInterface2 addr 0x12345673
[0066] Output1 addr 0x12345674
[0067] Among them, addr refers to the address.
[0068] Based on the aforementioned address file, the test script including the first message and the second message is as follows:
[0069] Req:ED 01 00 00 71 56 34 12 01
[0070] Req:ED 01 00 00 72 56 34 12 01
[0071] Req:ED 01 00 00 73 56 34 12 00
[0072] Req:F4 01 00 00 74 56 34 12 00
[0073] Req:ED 01 00 00 72 56 34 12 01
[0074] Req:ED 01 00 00 73 56 34 12 01
[0075] Req:F4 01 00 00 74 56 34 12 00
[0076] Req:ED 01 00 00 72 56 34 12 00
[0077] Req:ED 01 00 00 73 56 34 12 00
[0078] Req:F4 01 00 00 74 56 34 12 00
[0079] Req:ED 01 00 00 72 56 34 12 00
[0080] Req:ED 01 00 00 73 56 34 12 01
[0081] Req:F4 01 00 00 74 56 34 12 00
[0082] Among them, ED 01 00 00 71 56 34 12 refers to addr 0x12345671, ED 01 00 00 72 56 3412 refers to addr 0x12345672, ED 01 00 00 73 56 34 12 refers to addr 0x12345673, F4 01 00 0074 56 34 12 refers to address addr 0x12345674, and the "00" and "01" after the address refer to setting the calibration value or reading the value at the address, among which, the calibration value is set for addresses addr 0x12345671, addr 0x12345672 and addr0x12345673, and the value is read for address addr 0x12345674.
[0083] S230: Test the interactive interface to be tested based on the test script to obtain a test interface output value corresponding to the interface to be tested.
[0084] After obtaining the test script, the test script can be run using the interactive interface to be tested to obtain the test interface output value corresponding to the interface to be tested.
[0085] In some embodiments, the interactive interface to be tested is an interactive interface located in the target controller, and the address file is also obtained from the target controller, so that S330 may include: sending the test script to the target controller, so that the target controller tests the interactive interface to be tested based on the first message and the second message in the test script, obtains a first reply message corresponding to the first message and a second reply message corresponding to the second message, and returns a target reply message obtained based on the first reply message and the second reply message; parses the target reply message to obtain the test interface output value corresponding to the interface to be tested.
[0086] The target controller refers to the controller where the interactive interface to be tested is located. At this time, the first software and the second software also run on the target controller, and the address file used to construct the test script also exists in the target controller. Since the target controller runs the interactive interface to be tested, the calibration parameters, the switch state of the control switch, and the address of the expected interface output value involved in testing the interactive interface to be tested can all be addresses in the target controller, so that the target controller obtains the address file based on the calibration parameters, the switch state of the control switch, and the address of the expected interface output value.
[0087] For example, the target controller is the domain controller of the vehicle, the first software and the second software are software running on the domain controller, and the interactive interface to be tested is an interactive interface running on the domain controller. At this time, the address file used to construct the test script also exists in the domain controller.
[0088] After obtaining the test script, the test script is sent to the target controller, and the target controller executes the test script: based on the first message and the second message in the test script, the interactive interface to be tested is tested, thereby obtaining a first reply message corresponding to the first message and a second reply message corresponding to the second message, and then the target controller merges the first reply message and the second reply message into one message as the target reply message, and returns the target reply message to the electronic device, and the electronic device uses python programming to automatically parse the target reply message to obtain the test interface output value corresponding to the interface to be tested.
[0089] Exemplarily, in the case where the test script is as in the example in S320 above, the target reply message is as follows:
[0090] Req:ED 01 00 00 71 56 34 12 01
[0091] Res:FF
[0092] Req:ED 01 00 00 72 56 34 12 01
[0093] Res:FF
[0094] Req:ED 01 00 00 73 56 34 12 00
[0095] Res:FF
[0096] Req:F4 01 00 00 74 56 34 12 00
[0097] Res:FF 00
[0098] Req:ED 01 00 00 72 56 34 12 01
[0099] Res:FF
[0100] Req:ED 01 00 00 73 56 34 12 01
[0101] Res:FF
[0102] Req:F4 01 00 00 74 56 34 12 00
[0103] Res:FF 01
[0104] Req:ED 01 00 00 72 56 34 12 00
[0105] Res:FF
[0106] Req:ED 01 00 00 73 56 34 12 00
[0107] Res:FF
[0108] Req:F4 01 00 00 74 56 34 12 00
[0109] Res:FF 00
[0110] Req:ED 01 00 00 72 56 34 12 00
[0111] Res:FF
[0112] Req:ED 01 00 00 73 56 34 12 01
[0113] Res:FF
[0114] Req:F4 01 00 00 74 56 34 12 00
[0115] Res:FF 00
[0116] Here, FF refers to the test interface output value output by the interactive interface to be tested.
[0117] In this embodiment, a test script is automatically generated based on the address file and the test case, and the test script is automatically executed to test the interactive interface to be tested, thereby eliminating the need to manually construct the test script, improving the efficiency of obtaining the test script, and thus improving the testing efficiency of the interactive interface to be tested.
[0118] In addition, in this embodiment, a python automation script can be used to generate calibration values for batch changing calibration parameters, so that the test can be automatically performed only when the tester triggers the test. At the same time, a python automation script can be used to perform batch target reply message parsing, and the test results can be recorded only when the tester triggers it to obtain a test report, thereby solving the problems of low testing efficiency and easy errors when manually analyzing data and manually testing the interactive interface to be tested.
[0119] In one embodiment, if Figure 4 As shown, S130 includes:
[0120] S310: Generate a test report based on the test case and the test interface output value.
[0121] The test cases and test interface output values can be summarized to obtain the summarized results as a test report.
[0122] It is worth mentioning that when there are multiple test cases, each test case will correspond to a test interface output value. Each test case and the corresponding test interface output value can be summarized into one piece of data, so that in the case of multiple test cases, multiple pieces of data can be obtained, and the multiple pieces of data are used as test reports.
[0123] For example, when the test example is shown in Table 1, the test report is shown in Table 2. Table 2 is as follows:
[0124] Table 2
[0125]
[0126] S320: Determine the test result of the interactive interface to be tested according to the test report.
[0127] After obtaining the test report, the data in the test report can be analyzed to obtain the test result of the interactive interface to be tested.
[0128] Exemplarily, the test result of the interactive interface to be tested may be determined based on a comparison result between a test interface output value and an expected interface output value in a test report.
[0129] For example, if the test interface output value corresponding to the interface to be tested is consistent with the expected interface output value, the test result of the interactive interface to be tested is determined to be passed; for another example, if the test interface output value corresponding to the interface to be tested is inconsistent with the expected interface output value, the test result of the interactive interface to be tested is determined to be failed.
[0130] In this embodiment, the interface test process is as follows: Figure 5 As shown, including:
[0131] S1. Define an interactive interface to be tested in a specific format. That is, create an interactive interface to be tested including a control switch, so as to obtain a calibration value from a calibration parameter through the control switch.
[0132] S2. Write test cases. Write test cases for the interactive interface to be tested, which can be written manually by technicians.
[0133] S3, automatically generate a test script based on the calibration XCP protocol. Based on the CXP protocol, generate a first message and a second message, and obtain a test script based on the first message and the second message.
[0134] S4. Automatically run the test script to implement the test. Send the test script to the target controller, which automatically performs the test based on the test script to obtain a target reply message.
[0135] S5. The test results are automatically sorted to obtain a test report. The test report is generated based on the test interface output value and the test case in the target reply message.
[0136] In this embodiment, a test report is automatically generated and then analyzed to obtain the test results of the interactive interface to be tested, thereby realizing automatic generation of the test report. The test report displays the test interface output value and the expected interface output value corresponding to the interface to be tested, thereby facilitating intuitive observation of the difference between the test interface output value and the expected interface output value corresponding to the interface to be tested, thereby quickly determining the test result based on the difference between the test interface output value and the expected interface output value corresponding to the interface to be tested.
[0137] In one embodiment, after S130, the method may further include: if the test result indicates that the test of the interactive interface to be tested has passed, setting the control switch in the interactive interface to be tested to a closed state to obtain the target interactive interface; wherein, when the control switch is in the closed state, the interface input value of the interactive interface to be tested is the true value of each target function in the first software.
[0138] That is to say, when the test of the interactive interface to be tested passes, it indicates that the interactive interface to be tested can be used for data interaction between the first software and the second software. At this time, the interactive interface to be tested needs to obtain the real value of each target function from the first software during use as the interface input value of the interactive interface to be tested. Therefore, it is necessary to set the control switch in the interactive interface to be tested to the closed state. The interface to be tested with the control switch set to the closed state is used as the target interaction interface. The target interaction interface can be used as a published interaction interface to realize data interaction between the first software and the second software. At this time, the interface input value of the target interaction interface comes from the real value of each target function of the first software.
[0139] As mentioned above, the default switch state of the control switch is the off state, therefore, the switch state of the control switch can be adjusted to the default switch state to achieve setting the control switch in the interactive interface to be tested to the off state.
[0140] In this embodiment, when the test of the interactive interface to be tested passes, the switch state of the control switch of the interactive interface to be tested is adjusted to the closed state to obtain the target interactive interface, so that the input of the target interactive interface is the true value of each target function in the first software, ensuring that the target interactive interface can smoothly realize the data interaction between the first software and the second software.
[0141] See attached Figure 6 , Figure 6 The structure block diagram of an interface testing device proposed in one embodiment of the present application is shown. For electronic equipment, the device 800 includes:
[0142] The acquisition module 810 is used to acquire a test case corresponding to the interactive interface to be tested; the interactive interface to be tested is used to realize data interaction between the first software and the second software; the interactive interface to be tested includes a control switch; the test case includes a calibration interface input value of the interactive interface to be tested when the control switch is in the on state and an expected interface output value corresponding to the calibration interface input value; when the control switch is in the on state, the calibration interface input value is a calibration value of a calibration parameter; the calibration parameter is used to indicate each target function in the first software;
[0143] The testing module 820 is used to test the interactive interface to be tested according to the test case and obtain the test interface output value corresponding to the interface to be tested;
[0144] The result obtaining module 830 is used to obtain the test result of the interactive interface to be tested according to the test interface output value.
[0145] Optionally, the test module 820 is also used to obtain an address file; the address file includes the address of the calibration value of the calibration parameter, the address of the switch state of the control switch, and the address of the expected interface output value; a test script is generated according to the test case and the address file; the interactive interface to be tested is tested based on the test script to obtain the test interface output value corresponding to the interface to be tested.
[0146] Optionally, the test module 820 is also used to obtain the address of the calibration value of the calibration parameter, the address of the switch state and the address of the expected interface output value from the address file; generate a first message in a first format according to the address of the calibration value of the calibration parameter and the address of the switch state; the first message is used to rewrite the calibration value and the switch state of the calibration parameter according to the address of the calibration value of the calibration parameter and the address of the switch state; generate a second message in a second format according to the address of the expected interface output value; the second message is used to read the expected interface output value based on the address of the expected interface output value; and obtain a test script based on the first message and the second message.
[0147] Optionally, the interactive interface to be tested is an interactive interface located in the target controller; the address file is obtained from the target controller; the test module 820 is also used to send the test script to the target controller, so that the target controller tests the interactive interface to be tested based on the first message and the second message in the test script, obtains a first reply message corresponding to the first message and a second reply message corresponding to the second message, and returns a target reply message obtained based on the first reply message and the second reply message; the target reply message is parsed to obtain the test interface output value corresponding to the interface to be tested.
[0148] Optionally, the result acquisition module 830 is further used to generate a test report based on the test case and the test interface output value; and determine the test result of the interactive interface to be tested according to the test report.
[0149] Optionally, the result obtaining module 830 is further used to determine the test result of the interactive interface to be tested according to the comparison result between the test interface output value and the expected interface output value in the test report.
[0150] Optionally, the device further comprises a configuration module, which is used to set the control switch in the interactive interface to be tested to a closed state if the test result indicates that the interactive interface to be tested passes the test, so as to obtain a target interactive interface; wherein, when the control switch is in the closed state, the interface input value of the interactive interface to be tested is the real value of each target function in the first software.
[0151] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0152] In addition, each function in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of software function module.
[0153] In addition, each function in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of software function module.
[0154] Please refer to Figure 7, which shows a structural block diagram of an electronic device provided according to an embodiment of the present application. The electronic device 500 can be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, and a vehicle. The electronic device 500 in the present application may include one or more of the following components: a processor 510, a memory 520, and one or more applications. One or more applications may be stored in the memory 520 and configured to be executed by one or more processors 510, and one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0155] The processor 510 may include one or more processing cores. The processor 510 uses various interfaces and lines to connect various parts of the entire electronic device 500, and executes various functions and processes data of the electronic device 500 by running or executing instructions, programs, code sets or instruction sets stored in the memory 520, and calling data stored in the memory 520. Optionally, the processor 510 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 510 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 510, but may be implemented separately through a communication chip.
[0156] The memory 520 may include a random access memory (RAM) or a read-only memory (ROM). The memory 520 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 520 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 500 during use.
[0157] In addition, each function in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of software function module.
[0158] On the other hand, the present application also provides a computer-readable storage medium, in which program code is stored. The program code can be called by a processor to execute the method described in the above method embodiment.
[0159] The computer readable storage medium may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a cluster of ROMs. Optionally, the computer readable storage medium comprises a non-transitory computer-readable storage medium. The computer readable storage medium has storage space for program codes that execute any of the method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code can be compressed, for example, in an appropriate form.
[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An interface testing method, characterized in that: The method comprises: Obtain a test case corresponding to the interactive interface to be tested; the interactive interface to be tested is used to realize data interaction between the first software and the second software; the interactive interface to be tested includes a control switch; the test case includes a calibrated interface input value of the interactive interface to be tested when the control switch is in an on state and an expected interface output value corresponding to the calibrated interface input value; when the control switch is in an on state, the calibrated interface input value is a calibrated value of a calibration parameter; the calibration parameter is used to indicate each target function in the first software; Testing the interactive interface to be tested according to the test case to obtain a test interface output value corresponding to the interface to be tested; The test result of the interactive interface to be tested is obtained according to the test interface output value.
2. The method according to claim 1, characterized in that The step of testing the interactive interface to be tested according to the test case to obtain a test interface output value corresponding to the interface to be tested includes: Acquire an address file; the address file includes the address of the calibration value of the calibration parameter, the address of the switch state of the control switch, and the address of the expected interface output value; Generate a test script according to the test case and address file; The interactive interface to be tested is tested based on the test script to obtain a test interface output value corresponding to the interface to be tested.
3. The method according to claim 2, characterized in that The generating of the test script according to the test case and the address file comprises: Acquire the address of the calibration value of the calibration parameter, the address of the switch state, and the address of the expected interface output value from the address file; Generate a first message in a first format according to the address of the calibration value of the calibration parameter and the address of the switch state; the first message is used to rewrite the calibration value of the calibration parameter and the switch state according to the address of the calibration value of the calibration parameter and the address of the switch state; generating a second message in a second format according to the address of the expected interface output value; the second message is used to read the expected interface output value based on the address of the expected interface output value; The test script is obtained based on the first message and the second message.
4. The method according to claim 2, characterized in that: The interactive interface to be tested is an interactive interface located in the target controller; the address file is obtained from the target controller; The testing the interactive interface to be tested based on the test script to obtain a test interface output value corresponding to the interface to be tested includes: Sending the test script to the target controller, so that the target controller tests the interactive interface to be tested based on the first message and the second message in the test script, obtains a first reply message corresponding to the first message and a second reply message corresponding to the second message, and returns a target reply message obtained based on the first reply message and the second reply message; The target reply message is parsed to obtain a test interface output value corresponding to the interface to be tested.
5. The method according to claim 1, characterized in that The step of obtaining the test result of the interactive interface to be tested according to the test interface output value includes: Generate a test report based on the test case and the test interface output value; According to the test report, a test result of the interactive interface to be tested is determined.
6. The method according to claim 5, characterized in that Determining the test result of the interactive interface to be tested according to the test report includes: The test result of the interactive interface to be tested is determined according to the comparison result between the test interface output value and the expected interface output value in the test report.
7. The method according to claim 1, characterized in that After obtaining the test result of the interactive interface to be tested according to the test interface output value, the method further includes: If the test result indicates that the test of the interactive interface to be tested has passed, the control switch in the interactive interface to be tested is set to a closed state to obtain a target interactive interface; wherein, when the control switch is in a closed state, the interface input value of the interactive interface to be tested is the true value of each target function in the first software.
8. An interface testing device, characterized in that: The device comprises: An acquisition module, used for acquiring a test case corresponding to an interactive interface to be tested; the interactive interface to be tested is used to realize data interaction between a first software and a second software; the interactive interface to be tested includes a control switch; the test case includes a calibrated interface input value of the interactive interface to be tested when the control switch is in an on state and an expected interface output value corresponding to the calibrated interface input value; when the control switch is in an on state, the calibrated interface input value is a calibrated value of a calibration parameter; the calibration parameter is used to indicate each target function in the first software; A testing module, used to test the interactive interface to be tested according to the test case, and obtain a test interface output value corresponding to the interface to be tested; The result obtaining module is used to obtain the test result of the interactive interface to be tested according to the output value of the test interface.
9. An electronic device, characterized in that: include: one or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the method according to any one of claims 1 to 7.