CN115525561A - Protocol interface testing method, device, terminal equipment and storage medium - Google Patents

Protocol interface testing method, device, terminal equipment and storage medium Download PDF

Info

Publication number
CN115525561A
CN115525561A CN202211239504.XA CN202211239504A CN115525561A CN 115525561 A CN115525561 A CN 115525561A CN 202211239504 A CN202211239504 A CN 202211239504A CN 115525561 A CN115525561 A CN 115525561A
Authority
CN
China
Prior art keywords
test
protocol interface
interface module
module
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211239504.XA
Other languages
Chinese (zh)
Inventor
蒋诗敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Hangsheng Electronic Co Ltd
Original Assignee
Shenzhen Hangsheng Electronic Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Hangsheng Electronic Co Ltd filed Critical Shenzhen Hangsheng Electronic Co Ltd
Priority to CN202211239504.XA priority Critical patent/CN115525561A/en
Publication of CN115525561A publication Critical patent/CN115525561A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Maintenance And Management Of Digital Transmission (AREA)

Abstract

The application discloses a protocol interface test method, a device, a terminal device and a storage medium, wherein the protocol interface test method comprises the following steps: compiling a corresponding test case according to a protocol interface module, wherein the protocol interface module is obtained by introducing a pre-established compression packet into a preset background service; and calling the protocol interface module to test based on the test class and the test case to obtain a test report, and compiling the test class according to the preset annotation to obtain the test report. The test method corresponding to the test class is automatically generated by compiling the annotation, so that when the test case is compiled, only the corresponding test class object needs to be created according to the rule of the interface module, the problem that the interface test of the Android application layer cannot generate a detailed test report can be solved, and the usability of test compiling is improved.

Description

Protocol interface testing method, device, terminal equipment and storage medium
Technical Field
The present application relates to the field of protocol interface testing technologies, and in particular, to a protocol interface testing method and apparatus, a terminal device, and a storage medium.
Background
Currently, android automated testing is widely used to improve software quality and reduce risks. The Android automatic test has many frames and schemes, but has the following problems:
1. the correctness needs to be judged artificially and subjectively, and the generated test report cannot be customized, for example, the expected value and the actual value related to the method parameter executed by the test and whether the test is correct are printed, and the related class methods are classified and counted;
2. some existing automatic test tools or schemes cannot test interface methods and call backs of the CAN protocol in a targeted mode.
Disclosure of Invention
The application mainly aims to provide a protocol interface testing method, a protocol interface testing device, a terminal device and a storage medium, and aims to solve the problem that a detailed test report cannot be generated in an interface test of an Android application layer and improve the usability of test writing.
In order to achieve the above object, the present application provides a protocol interface testing method, where the protocol interface testing method includes:
compiling a corresponding test case according to a protocol interface module, wherein the protocol interface module is obtained by introducing a pre-established compression packet into a preset background service;
and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report.
Optionally, before the step of writing the corresponding test case according to the protocol interface module, the method further includes:
importing a pre-created decompression packet into the background service to obtain the protocol interface module, wherein the decompression packet at least comprises one protocol interface module;
corresponding annotations are added based on the protocol interface module to generate corresponding test classes.
Optionally, the step of adding corresponding annotations based on the protocol interface module to generate corresponding test classes includes:
defining a corresponding method class and a callback class according to the protocol interface module to obtain a class to be tested;
adding corresponding annotations in the class to be tested;
and compiling the annotation through a preset annotation processor to generate a corresponding test class.
Optionally, after the step of introducing a pre-created decompressed packet into the background service to obtain the protocol interface module, the step of decompressing the packet including at least one protocol interface module further includes:
judging whether the protocol interface module belongs to a test module;
if yes, executing the steps: corresponding annotations are added based on the protocol interface module to generate corresponding test classes.
Optionally, the step of calling the protocol interface module to perform a test based on the test class and the test case to obtain a test report includes:
generating a corresponding task queue according to the test case;
and sequentially carrying out simulation test on each protocol interface module based on the expected value of the test case and the task queue to obtain the test report.
Optionally, the step of sequentially performing simulation tests on the protocol interface modules based on the expected values of the test cases and the task queue to obtain the test report includes:
sequentially carrying out serial port communication test on each protocol interface module according to the task queue to obtain a corresponding actual value;
comparing the actual value to the expected value;
and if the actual value is matched with the expected value, the corresponding protocol interface module passes the test.
Optionally, the test report includes one or more of a detailed report, a module report, and a general report.
An embodiment of the present application further provides a protocol interface testing apparatus, where the protocol interface testing apparatus includes:
the system comprises a compiling module, a testing module and a processing module, wherein the compiling module is used for compiling a corresponding test case according to a protocol interface module, and the protocol interface module is obtained by leading in a pre-established compression packet in a preset background service;
and the test module is used for calling the protocol interface module to test based on a test class and the test case to obtain a test report, and the test class is compiled according to a preset annotation to obtain the test report.
The embodiment of the present application further provides a terminal device, where the terminal device includes a memory, a processor, and a protocol interface test program that is stored in the memory and can be run on the processor, and the protocol interface test program implements the steps of the protocol interface test method described above when executed by the processor.
An embodiment of the present application further provides a computer-readable storage medium, where a protocol interface test program is stored on the computer-readable storage medium, and the protocol interface test program, when executed by a processor, implements the steps of the protocol interface test method described above.
According to the protocol interface testing method, the protocol interface testing device, the terminal equipment and the storage medium, the corresponding test case is compiled according to the protocol interface module, and the protocol interface module is obtained by introducing a pre-established compression packet into a preset background service; and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report. The test method corresponding to the test class is automatically generated by compiling the annotation, so that when the test case is compiled, only the corresponding test class object needs to be created according to the rule of the interface module, the problem that the interface test of the Android application layer cannot generate a detailed test report can be solved, and the usability of test compiling is improved. Based on the scheme of the application, a corresponding test class is generated aiming at the annotation from the rule of automatic test in the computer industry, so that the test class is started according to the test case, the interface module is tested, and a detailed test report is generated, thereby verifying the effectiveness of the protocol interface test method provided by the application.
Drawings
Fig. 1 is a schematic diagram of functional modules of a terminal device to which a protocol interface testing apparatus of the present application belongs;
FIG. 2 is a flowchart illustrating a first exemplary embodiment of a protocol interface testing method according to the present application;
FIG. 3 is a flowchart illustrating a second exemplary embodiment of a protocol interface testing method according to the present application;
FIG. 4 is a flowchart illustrating a third exemplary embodiment of a protocol interface testing method according to the present application;
FIG. 5 is a flowchart illustrating a fourth exemplary embodiment of a protocol interface testing method according to the present application;
FIG. 6 is a schematic diagram of a test report generated by the protocol interface test method of the present application;
FIG. 7 is a flowchart illustrating a fifth exemplary embodiment of a protocol interface testing method according to the present application;
FIG. 8 is a flowchart illustrating a sixth exemplary embodiment of a protocol interface testing method according to the present application;
fig. 9 is a schematic diagram of an environment simulation related to the protocol interface testing method of the present application.
The implementation, functional features and advantages of the object of the present application will be further explained with reference to the embodiments, and with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The main solution of the embodiment of the application is as follows: compiling a corresponding test case according to a protocol interface module, wherein the protocol interface module is obtained by introducing a pre-established compression packet into a preset background service; and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report. The test method corresponding to the test class is automatically generated by compiling the annotation, so that when the test case is compiled, only the corresponding test class object needs to be created according to the rule of the interface module, the problem that the interface test of the Android application layer cannot generate a detailed test report can be solved, and the usability of test compiling is improved. Based on the scheme of the application, a corresponding test class is generated aiming at the annotation from the rule of automatic test in the computer industry, so that the test class is started according to the test case, the interface module is tested, and a detailed test report is generated, thereby verifying the effectiveness of the protocol interface test method provided by the application.
The embodiment of the application considers that at present, android automatic testing is widely used for improving software quality and reducing risks. There are many frames and schemes for Android automated testing, but the following problems exist:
1. the correctness needs to be judged manually and subjectively, and the generated test report cannot be customized, for example, whether an expected value, an actual value and a test related to a method parameter executed by the test are correctly printed, and a related class method is classified and counted;
2. some existing automatic test tools or schemes cannot test interface methods and call backs of the CAN protocol in a targeted mode.
Therefore, according to the embodiment of the application, a method for testing the CAN protocol by the Android application layer interface is designed based on the actual problem of the protocol interface test, namely, a detailed test report is obtained by importing the protocol interface module and automatically generating the test class, the problem that the detailed test report cannot be generated by the interface test of the Android application layer CAN be solved, and the usability of test writing is improved.
Specifically, referring to fig. 1, fig. 1 is a schematic diagram of a functional module of a terminal device to which the protocol interface testing apparatus of the present application belongs. The protocol interface testing device can be a device which is independent of the terminal equipment, can write use cases and test interface modules, and can be borne on the terminal equipment in a hardware or software mode. The terminal device can be an intelligent mobile terminal with a data processing function, such as a mobile phone and a tablet personal computer, and can also be a fixed terminal device or a server with a data processing function.
In this embodiment, the terminal device to which the protocol interface testing apparatus belongs at least includes an output module 110, a processor 120, a memory 130, and a communication module 140.
The memory 130 stores an operating system and a protocol interface test program, and the protocol interface test device can introduce a pre-created compression packet into a preset background service according to a corresponding test case compiled by a protocol interface module; based on the test class and the test case, the called protocol interface module performs testing, and the obtained test report is compiled according to the preset annotation to obtain information such as the test class and the like, and is stored in the memory 130; the output module 110 may be a display screen or the like. The communication module 140 may include a WIFI module, a mobile communication module, a bluetooth module, and the like, and communicates with an external device or a server through the communication module 140.
Wherein, the protocol interface test program in the memory 130 realizes the following steps when being executed by the processor:
compiling a corresponding test case according to a protocol interface module, wherein the protocol interface module is obtained by introducing a pre-established compression packet into a preset background service;
and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report.
Further, the protocol interface test program in the memory 130 when executed by the processor further implements the steps of:
importing a pre-created decompression packet into the background service to obtain the protocol interface module, wherein the decompression packet at least comprises one protocol interface module;
corresponding annotations are added based on the protocol interface module to generate corresponding test classes.
Further, the protocol interface test program in the memory 130 when executed by the processor further implements the steps of:
defining a corresponding method class and a callback class according to the protocol interface module to obtain a class to be tested;
adding corresponding annotations in the class to be tested;
and compiling the annotation through a preset annotation processor to generate a corresponding test class.
Further, the protocol interface test program in the memory 130 when executed by the processor further implements the steps of:
judging whether the protocol interface module belongs to a test module;
if yes, executing the steps: corresponding annotations are added based on the protocol interface module to generate corresponding test classes.
Further, the protocol interface test program in the memory 130 when executed by the processor further implements the steps of:
generating a corresponding task queue according to the test case;
and sequentially carrying out simulation test on each protocol interface module based on the expected value of the test case and the task queue to obtain the test report.
Further, the protocol interface test program in the memory 130 when executed by the processor further implements the steps of:
sequentially carrying out serial port communication test on each protocol interface module according to the task queue to obtain a corresponding actual value;
comparing the actual value to the expected value;
and if the actual value is matched with the expected value, the corresponding protocol interface module passes the test.
According to the scheme, the corresponding test case is specifically compiled according to the protocol interface module, and the protocol interface module is obtained by leading in a pre-established compression packet in the preset background service; and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report. The test method corresponding to the test class is automatically generated by compiling the annotation, so that when the test case is compiled, only the corresponding test class object needs to be created according to the rule of the interface module, the problem that the interface test of the Android application layer cannot generate a detailed test report can be solved, and the usability of test compiling is improved. Based on the scheme of the application, a corresponding test class is generated aiming at the annotation from the rule of automatic test in the computer industry, so that the test class is started according to the test case, the interface module is tested, and a detailed test report is generated, thereby verifying the effectiveness of the protocol interface test method provided by the application.
Based on the above terminal device architecture but not limited to the above architecture, embodiments of the method of the present application are provided.
Referring to fig. 2, fig. 2 is a flowchart illustrating a first exemplary embodiment of a protocol interface testing method according to the present application. The protocol interface testing method comprises the following steps:
step S210, compiling a corresponding test case according to a protocol interface module, wherein the protocol interface module is obtained by introducing a pre-established compression packet into a preset background service;
the execution subject of the method of this embodiment may be a test apparatus of a protocol interface, and may also be a test terminal device or a server of a protocol interface.
Because the test cases can make the test smoother and improve the test efficiency, the corresponding test cases need to be compiled. It should be noted that, in this embodiment, the protocol interface module includes at least one protocol interface. In addition, before the step of writing the test case, a test compression packet (jar packet, compression packet related to Java) can be imported, that is, a plurality of protocol interfaces to be tested are packed to obtain and import the test compression packet; the test classes are then automatically generated by the annotation processor (apt) to implement the protocol interface test.
Step S220, based on the test class and the test case, calling the protocol interface module to test to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report.
Specifically, the annotation processor compiles the annotations in the test classes to automatically generate the test method corresponding to the test classes, so that when writing the test case, a user only needs to create a corresponding test class object according to rules and call a scheme with the same name by using the object to participate in automatic test items, and the test writing usability is improved.
According to the scheme, the corresponding test case is specifically compiled according to the protocol interface module, and the protocol interface module is obtained by introducing the pre-created compression packet into the preset background service; and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report. The test method corresponding to the test class is automatically generated by compiling the annotation, so that when the test case is compiled, only the corresponding test class object needs to be created according to the rule of the interface module, the problem that the interface test of the Android application layer cannot generate a detailed test report can be solved, and the usability of test compiling is improved.
Referring to fig. 3, fig. 3 is a flowchart illustrating a second exemplary embodiment of a protocol interface testing method according to the present application. Based on the embodiment shown in fig. 2, in step S220, based on the test class and the test case, the method calls the protocol interface module to perform a test to obtain a test report, and before the test class is compiled according to a preset annotation, the method further includes:
step S310, a pre-established decompression packet is led into the background service to obtain the protocol interface module, and the decompression packet at least comprises one protocol interface module;
specifically, a pre-created decompression packet is led into the background service to obtain the protocol interface module, where the decompression packet includes at least one protocol interface module, and the specific steps may include: and transplanting the compressed packets (jar packets) into a background service (CarService file) to exist in a group of modules. It should be noted that, because some configurations belong to the dependency of the relative path, the engineering directory needs to be recorded and played in the same-level directory, including but not limited to ApiTest directory, cardadapterservice directory, cardodyctrlservice directory, carHvacService directory, and CarService directory. The ApiTest directory serves as an association management module, and does not store codes.
In this embodiment, the project is constructed by Gradle in this embodiment. Further, since a plurality of directories need to be compiled simultaneously, setings. Wherein, gradle is a JVM-based construction tool, is a universal flexible construction tool, supports maven and Ivy warehouses, and supports transitive dependency management.
In addition, 6 modules are arranged in the CarService and ApiTest, including a test module, a test _ annotation module, a test _ api module, a test _ builder module, a test _ serial module and a module _ ipc module. Wherein, test needs to add dependency to external dependency, for example, in the build of application (app); the test _ annotation _ api test _ compiler belongs to internal module calling and does not need external reference; test _ serial is a test module aiming at the IPC module to simulate the serial communication of hidl; a build in module _ ipc, for example, requires masking hidl libraries and adding test _ serial dependencies; test _ module requires an entry to add a Test api.
Step S320, adding corresponding annotations based on the protocol interface module to generate corresponding test classes.
Specifically, a class to be tested may be added to the Java package, and then an annotation may be added to the class to be tested, so that the annotation may be compiled by an annotation processor (apt), thereby automatically generating a corresponding test class.
Further, step S320, adding corresponding annotations based on the protocol interface module to generate corresponding test classes, including:
step S321, defining a corresponding method class and a callback class according to the protocol interface module to obtain a class to be tested;
in particular, since the test class in Java is used to test functional components that have already been written. In this way, method invocation testing and method callback testing may be supported. For example, vehicle may be added to the com.
Step S322, adding corresponding annotations in the class to be tested;
in particular, since Java annotations are some meta-information attached to the code, they are used for compiling and runtime parsing and usage, and they serve as description and configuration functions. Therefore, in this embodiment, the annotation of the test class is added to the class to be tested, so that the program identifies the test class to be tested by the user according to the annotation. For example, the annotations are set to Fun, cbk.
And step S323, compiling the annotation through a preset annotation processor to generate a corresponding test class.
Specifically, the annotation is compiled by a preset annotation processor, and the compiling item is started, so that the FunVehicleManager and the cbkcommon cardstat callback class can be automatically generated, that is, the test class is automatically generated by the annotation processor (apt).
According to the scheme, the protocol interface module is obtained by specifically introducing a pre-created decompression packet into the background service, wherein the decompression packet at least comprises one protocol interface module; defining a corresponding method class and a callback class according to the protocol interface module to obtain a class to be tested; adding corresponding annotations in the class to be tested; and compiling the annotation through a preset annotation processor to generate a corresponding test class. The annotation processor compiles the annotations, so that corresponding test classes are automatically generated, one-key automatic operation, method calling test and method callback test are supported, report results are printed, test steps are simplified, single operation and result checking are not needed, and convenience of protocol interface test is improved.
Referring to fig. 4, fig. 4 is a flowchart illustrating a third exemplary embodiment of a protocol interface testing method according to the present application. Based on the embodiment shown in fig. 3, in step S310, a pre-created decompressed packet is introduced into the background service to obtain the protocol interface module, where the decompressed packet includes at least one protocol interface module, and the method further includes:
step S410, judging whether the protocol interface module belongs to a test module;
step S420, if yes, step S320 is executed to add corresponding annotations based on the protocol interface module to generate corresponding test classes.
Specifically, it may be determined whether the protocol interface module belongs to the test module through the test module in the apitest directory in step S310, and if the protocol interface module belongs to the test module, step S320 is executed to add corresponding annotations based on the protocol interface module to generate a corresponding test class; if the protocol interface module does not belong to the test module, the program carries out early warning prompt, so that loss and influence caused by test errors can be avoided in time.
According to the scheme, whether the protocol interface module belongs to the test module is judged; if yes, executing the steps: corresponding annotations are added based on the protocol interface module to generate corresponding test classes. By judging whether the protocol interface module belongs to the test system, the test effectiveness can be improved, and the loss and the influence caused by test errors can be avoided in time.
Referring to fig. 5, fig. 5 is a flowchart illustrating a fourth exemplary embodiment of a protocol interface testing method according to the present application. Based on the embodiment shown in fig. 2, in step S220, the protocol interface module is called to perform a test based on a test class and the test case, so as to obtain a test report, where the test class is compiled according to a preset annotation, and the method includes:
step S510, generating a corresponding task queue according to the test case;
specifically, according to the test case, a corresponding task queue is generated, and the task queue is sequentially executed according to the arrangement of the test items, namely, first-in first-out, so that the earliest task is processed first.
And step S520, sequentially carrying out simulation test on each protocol interface module based on the expected value of the test case and the task queue to obtain the test report.
Specifically, referring to fig. 6, fig. 6 is a schematic diagram of a test report generated by the protocol interface test method of the present application. The protocol interface module (ApiModule) represents a method to be tested and callback functions (FunTask and CbkTask), and the method and the callback functions are sequentially placed into a queue according to a numbering sequence, such as 0 to 5 task tasks in the figure, the task queue is sequentially executed from zero according to the sequence, a passing result (pass) or a failing result (fail) is obtained, and finally a corresponding report file (test _ report.csv) is generated. The test report comprises one or more of a detailed report, a module report and a total report.
According to the scheme, the corresponding task queue is generated according to the test case; and sequentially carrying out simulation test on each protocol interface module based on the expected value of the test case and the task queue to obtain the test report. And generating a queue, executing in sequence according to the arrangement of the test items, and simultaneously automatically printing a test report, wherein the test report comprises one or more of a detailed report (detail report), a module report (module report) and a total report (total report). By embodying the detailed report, the module report and the total report in a file, the test content can be summarized and summarized better, thereby improving the readability.
Referring to fig. 7, fig. 7 is a flowchart illustrating a fifth exemplary embodiment of a protocol interface testing method according to the present application. Based on the embodiment shown in fig. 5, in step S520, according to the serial number and the expected value of the test case, serial port communication simulation is performed sequentially for each protocol interface module to obtain the test report, including:
step S710, sequentially carrying out serial port communication test on each protocol interface module according to the task queue to obtain a corresponding actual value;
further, the actual value obtained by the serial port communication test is printed in a test report (test _ report. Csv) and compared with the expected value, so as to directly obtain the result of passing or failing the test. The test report comprises one or more of a detailed report (detail report), a module report (module report) and a total report (total report).
The detail report (detail report) includes, but is not limited to, generating the following: class (Class path), method (Method name), expect (Expect), input (Input parameter), output (return Output value), result field;
the module report (module report) includes, but is not limited to, generating the following: class path, number Of Methods (Number Of Methods tested by Class), pass (several passes), fail (several fails), timeout (several times out) fields;
the total report (total report) includes, but is not limited to, generating the following: total (Total number of tests), pass (several passes), fail (several fails), timeout (several times out), unknown (several unknown) fields.
Step S720, comparing the actual value with the expected value;
specifically, an expected value is written in when a test case is compiled, then the interface module is tested to obtain an actual value, the actual value is compared with the expected value, and if the actual value is matched with the expected value, the test of the corresponding protocol interface module is passed; if the actual value does not match the expected value, it indicates that the corresponding protocol interface module test fails. The correctness is not judged in a man-made subjective way, and the usability of the test is improved.
And step S730, if the actual value is matched with the expected value, the corresponding protocol interface module passes the test.
According to the scheme, serial port communication tests are sequentially carried out on the protocol interface modules according to the task queues to obtain corresponding actual values; comparing the actual value to the expected value; and if the actual value is matched with the expected value, the corresponding protocol interface module passes the test. By writing the expected parameters and the expected return values in advance as the judgment passing conditions in the test, namely, by comparing the actual values with the expected values, the test result is directly obtained, and the test boundary range can be improved.
Referring to fig. 8, fig. 8 is a flowchart illustrating a sixth exemplary embodiment of a protocol interface testing method according to the present application. Firstly, importing a test compression package (jar package), and then automatically generating a test class through an annotation processor (apt); then, compiling case; then, running a test class according to the case; finally, the required report can be generated.
Referring to fig. 9, fig. 9 is a schematic diagram illustrating an environment simulation related to the protocol interface testing method of the present application. The left side represents normal communication with the can, and the right side represents the simulated can message during the automatic test as the feedback mechanism to be used as the judgment basis during the automatic test.
Shown in the figure, application (App): normal applications call the compressed packet of carepi to access can data. Compressed package (jar package): java related compression packets, in this embodiment, compression packets for protocol interface automation testing. Android background service (Carservice): background services for android. Analysis module (mcompare): the parsing module of the can data of the mcu can provide get, set and listener interfaces. Single chip microcomputer (mcu): the single chip microcomputer on the vehicle is used for communicating with the can and the upper soc; automated test engineering application (ApiTest): the method is used for compiling test cases (cases) and simulating can data interaction of the single chip microcomputer. An interface display (UI) of data. Analog single chip microcomputer (Emula tomer mcu): and simulating the mcu for simulating can data interaction, and directly providing the data to a parsing module (mcmpare).
According to the scheme, the test method corresponding to the test class is automatically generated through compiling annotations, when the test case is compiled, the corresponding test class object is only needed to be created according to the rule, the object calls the scheme with the same name to participate in the automatic test item, and the test compiling usability is improved.
In addition, an embodiment of the present application further provides a protocol interface testing apparatus, where the protocol interface testing apparatus includes:
the system comprises a compiling module, a testing module and a processing module, wherein the compiling module is used for compiling a corresponding test case according to a protocol interface module, and the protocol interface module is obtained by leading in a pre-established compression packet in a preset background service;
and the test module is used for calling the protocol interface module to test based on a test class and the test case to obtain a test report, and the test class is compiled according to a preset annotation to obtain the test report.
For the principle and implementation process of implementing the protocol interface test in this embodiment, please refer to the above embodiments, which are not described herein again.
In addition, the embodiment of the present application further provides a terminal device, where the terminal device includes a memory, a processor, and a protocol interface test program that is stored in the memory and is executable on the processor, and when the protocol interface test program is executed by the processor, the method for testing a protocol interface as described above is implemented.
Since the protocol interface test program is executed by the processor, all technical solutions of all the foregoing embodiments are adopted, so that at least all the beneficial effects brought by all the technical solutions of all the foregoing embodiments are achieved, and details are not repeated herein.
In addition, an embodiment of the present application further provides a computer-readable storage medium, where a protocol interface test program is stored on the computer-readable storage medium, and when the protocol interface test program is executed by a processor, the steps of the protocol interface test method described above are implemented.
Since the protocol interface test program is executed by the processor, all technical solutions of all the foregoing embodiments are adopted, so that at least all the beneficial effects brought by all the technical solutions of all the foregoing embodiments are achieved, and details are not repeated herein.
Compared with the prior art, the protocol interface testing method, the protocol interface testing device, the terminal equipment and the storage medium provided by the embodiment of the application compile a corresponding test case according to the protocol interface module, wherein the protocol interface module is obtained by introducing a pre-created compression packet into a preset background service; and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report. The test method corresponding to the test class is automatically generated by compiling the annotation, so that when the test case is compiled, only the corresponding test class object needs to be created according to the rule of the interface module, the problem that the interface test of the Android application layer cannot generate a detailed test report can be solved, and the usability of test compiling is improved. Based on the scheme of the application, a corresponding test class is generated aiming at the annotation from the rule of automatic test in the computer industry, so that the test class is started according to the test case, the interface module is tested, and a detailed test report is generated, thereby verifying the effectiveness of the protocol interface test method provided by the application.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application or portions contributing to the prior art may be embodied in the form of a software product, where the computer software product is stored in a storage medium (such as a ROM/RAM, a magnetic disk, and an optical disk) as above, and includes several instructions to enable a terminal device (which may be a mobile phone, a computer, a server, a controlled terminal, or a network device) to execute the method of each embodiment of the present application.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all the equivalent structures or equivalent processes that can be directly or indirectly applied to other related technical fields by using the contents of the specification and the drawings of the present application are also included in the scope of the present application.

Claims (10)

1. A protocol interface testing method is characterized by comprising the following steps:
compiling a corresponding test case according to a protocol interface module, wherein the protocol interface module is obtained by introducing a pre-established compression packet into a preset background service;
and calling the protocol interface module to test based on a test class and the test case to obtain a test report, and compiling the test class according to a preset annotation to obtain the test report.
2. The protocol interface testing method of claim 1, wherein before the step of writing the corresponding test case according to the protocol interface module, further comprising:
importing a pre-created decompression packet into the background service to obtain the protocol interface module, wherein the decompression packet at least comprises one protocol interface module;
corresponding annotations are added based on the protocol interface module to generate corresponding test classes.
3. The protocol interface testing method of claim 2, wherein the step of adding corresponding annotations based on the protocol interface module to generate corresponding test classes comprises:
defining a corresponding method class and a callback class according to the protocol interface module to obtain a class to be tested;
adding corresponding annotations in the class to be tested;
and compiling the annotation through a preset annotation processor to generate a corresponding test class.
4. The protocol interface testing method of claim 2, wherein after the step of importing the pre-created decompressed packet into the background service to obtain the protocol interface module, the step of decompressing the packet including at least one protocol interface module further comprises:
judging whether the protocol interface module belongs to a test module;
if yes, executing the steps: corresponding annotations are added based on the protocol interface module to generate corresponding test classes.
5. The protocol interface testing method of claim 1, wherein the step of calling the protocol interface module for testing based on the test class and the test case to obtain a test report comprises:
generating a corresponding task queue according to the test case;
and sequentially carrying out simulation test on each protocol interface module based on the expected value of the test case and the task queue to obtain the test report.
6. The protocol interface testing method of claim 5, wherein the step of sequentially performing simulation testing on each protocol interface module based on the expected value of the test case and the task queue to obtain the test report comprises:
sequentially carrying out serial port communication test on each protocol interface module according to the task queue to obtain a corresponding actual value;
comparing the actual value to the expected value;
and if the actual value is matched with the expected value, the corresponding protocol interface module passes the test.
7. The protocol interface testing method of claim 5, wherein the test report comprises one or more of a detailed report, a module report, and a general report.
8. A protocol interface testing apparatus, comprising:
the system comprises a compiling module, a testing module and a processing module, wherein the compiling module is used for compiling a corresponding test case according to a protocol interface module, and the protocol interface module is obtained by leading in a pre-established compression packet in a preset background service;
and the test module is used for calling the protocol interface module to test based on a test class and the test case to obtain a test report, and the test class is compiled according to a preset annotation to obtain the test report.
9. A terminal device comprising a memory, a processor and a protocol interface test program stored on the memory and executable on the processor, the protocol interface test program when executed by the processor implementing the steps of the protocol interface test method according to any one of claims 1 to 7.
10. A computer-readable storage medium, having a protocol interface test program stored thereon, which when executed by a processor implements the steps of the protocol interface test method of any one of claims 1-7.
CN202211239504.XA 2022-10-11 2022-10-11 Protocol interface testing method, device, terminal equipment and storage medium Pending CN115525561A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211239504.XA CN115525561A (en) 2022-10-11 2022-10-11 Protocol interface testing method, device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211239504.XA CN115525561A (en) 2022-10-11 2022-10-11 Protocol interface testing method, device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115525561A true CN115525561A (en) 2022-12-27

Family

ID=84701904

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211239504.XA Pending CN115525561A (en) 2022-10-11 2022-10-11 Protocol interface testing method, device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115525561A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116543828A (en) * 2023-07-06 2023-08-04 成都佰维存储科技有限公司 UFS protocol testing method and device, readable storage medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140324378A1 (en) * 2013-04-30 2014-10-30 Advantest Corporation Automated generation of a test class pre-header from an interactive graphical user interface
CN109254907A (en) * 2018-08-03 2019-01-22 挖财网络技术有限公司 A kind of interface testing report-generating method and system based on Java
CN111752844A (en) * 2020-06-30 2020-10-09 北京来也网络科技有限公司 Interface testing method and device, computing equipment and storage medium
CN112597052A (en) * 2020-12-29 2021-04-02 深圳Tcl新技术有限公司 Interface testing method and device and computer readable storage medium
CN114217772A (en) * 2021-11-29 2022-03-22 延锋伟世通电子科技(南京)有限公司 Method and software for generating CarService code configuration under android Tree architecture

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140324378A1 (en) * 2013-04-30 2014-10-30 Advantest Corporation Automated generation of a test class pre-header from an interactive graphical user interface
CN109254907A (en) * 2018-08-03 2019-01-22 挖财网络技术有限公司 A kind of interface testing report-generating method and system based on Java
CN111752844A (en) * 2020-06-30 2020-10-09 北京来也网络科技有限公司 Interface testing method and device, computing equipment and storage medium
CN112597052A (en) * 2020-12-29 2021-04-02 深圳Tcl新技术有限公司 Interface testing method and device and computer readable storage medium
CN114217772A (en) * 2021-11-29 2022-03-22 延锋伟世通电子科技(南京)有限公司 Method and software for generating CarService code configuration under android Tree architecture

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116543828A (en) * 2023-07-06 2023-08-04 成都佰维存储科技有限公司 UFS protocol testing method and device, readable storage medium and electronic equipment
CN116543828B (en) * 2023-07-06 2023-09-19 成都佰维存储科技有限公司 UFS protocol testing method and device, readable storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
US20020133807A1 (en) Automation and isolation of software component testing
CN111459821A (en) Software automation unit testing method based on TestNG
US20040054946A1 (en) System and method for assessing compatibility risk
CN101924656A (en) Method and device for realizing network equipment CLI (Command Line Interface for batch scripti) based on dynamic configuration
CN108415826B (en) Application testing method, terminal device and computer readable storage medium
CN111158741A (en) Method and device for monitoring change of dependency relationship of business module on third-party class library
US8661414B2 (en) Method and system for testing an order management system
CN111475390A (en) Log collection system deployment method, device, equipment and storage medium
CN112667287A (en) Method, device and equipment for creating rule file and computer readable storage medium
CN111008017B (en) Oclin-based pre-review method for files to be submitted and related components
Tveito et al. Global Reproducibility Through Local Control for Distributed Active Objects.
CN115525561A (en) Protocol interface testing method, device, terminal equipment and storage medium
CN111752841A (en) Single test simulation method, device, equipment and computer readable storage medium
CN114895935A (en) Method and device for flashing vehicle ECU, electronic equipment and storage medium
CN110826074A (en) Application vulnerability detection method and device and computer readable storage medium
CN114579467A (en) Smoking test system and method based on release subscription mechanism
CN113238739A (en) Plug-in development and data acquisition method, device, electronic equipment and medium
CN115878475A (en) Abnormal scene testing method, device and system
CN112559336B (en) Method, device and system for self-adaptively debugging heterogeneous computing chip and main board chip
CN113778451B (en) File loading method, file loading device, computer system and computer readable storage medium
CN115509913A (en) Software automation test method, device, machine readable medium and equipment
CN114579470A (en) Unit testing method and device, electronic equipment and storage medium
CN109308256B (en) Dynamic analysis method, equipment and storage medium for java program
CN113419738A (en) Interface document generation method and device and interface management equipment
CN113342600A (en) Method and device for monitoring program dependent plug-in

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB03 Change of inventor or designer information
CB03 Change of inventor or designer information

Inventor after: Jiang Shimin

Inventor after: Yin Yutao

Inventor after: Hu Jin

Inventor before: Jiang Shimin