Method, device and equipment for testing test suite and computer program product
By automatically processing the test logs of the test suite and identifying natural language descriptions and test intentions, the problem of low efficiency of smart card test suite coverage analysis testing is solved, and efficient and accurate automated testing is achieved.
Patent Information
- Application Number
- CN202410415876.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-08
- Publication Date
- 2024-10-18
AI Technical Summary
The coverage analysis testing of existing smart card test suites relies on manual operations, which is inefficient and inaccurate. Especially due to the huge number of test cases, testers require high industry experience and manual intervention, making it difficult to complete the test efficiently.
By obtaining the test log of the test suite, automatically segmenting instruction pairs, retrieving document pieces, generating prompt words, calling a large language model to identify natural language descriptions, and summarizing the test intentions of test cases, automated coverage analysis is achieved.
It improves testing efficiency and accuracy, reduces dependence on tester experience, and realizes an automated testing process without manual intervention.
Smart Images

Figure CN118796672A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of Internet of Things, and specifically relates to a method, apparatus, device and computer program product for testing a test suite. Background Art
[0002] Smart cards must have high security and high reliability, so smart card testing is a very important part of the card industry. Smart cards are usually tested through test suites, which come from third parties or open source test suites. The source of the test suites makes the quality of the test suites uneven, so verifying the quality of the test suites is an important prerequisite for ensuring the quality of smart cards.
[0003] Coverage analysis is an important aspect of testing a test suite. In related technologies, when performing coverage analysis on a test suite, the tester translates the instruction pairs consisting of the test instructions and the test responses of the test instructions into natural language one by one, and then summarizes the natural language corresponding to the instruction pairs belonging to the same test case into a sentence of test intent, and then compares the test intent with the test intent described in the test case, and finally obtains the coverage analysis degree of the test case.
[0004] The coverage analysis tests of the above test suites are all completed manually by testers, so extremely high industry experience is required of the testers. In addition, due to the huge number of test cases in the test suites, manual testing by testers also has the problem of low efficiency. Summary of the invention
[0005] The present application proposes a method, apparatus, device and computer program product for testing a test suite, which can alleviate the problems of low efficiency and low accuracy in manually performing coverage analysis tests on test suites in related technologies.
[0006] The first embodiment of the present application provides a method for testing a test suite, including:
[0007] Obtaining test logs for test cases in the test suite;
[0008] Based on the test log, a plurality of instruction pairs are obtained, each of which includes a test instruction and a test response corresponding to the test instruction;
[0009] Retrieving document pieces corresponding to each of the instruction pairs;
[0010] Based on the document piece, generating prompt words for each of the instruction pairs;
[0011] Calling a large language model to identify prompt words of each instruction pair to obtain a natural language description of each instruction pair;
[0012] The natural language description is summarized to obtain the test intent of the test case.
[0013] In one or more embodiments, based on the test log, a plurality of instruction pairs are obtained, including:
[0014] Dividing the test log into a plurality of target instruction pairs, each target instruction pair comprising a test instruction and a test response corresponding to the test instruction;
[0015] Searching for multiple instructions belonging to the same process instruction from the instructions included in the multiple target instruction pairs;
[0016] Merging target instruction pairs corresponding to the multiple instructions to obtain a merged instruction pair;
[0017] The merged instruction pair and the remaining instruction pairs are taken as the multiple instruction pairs, and the remaining instruction pairs are instruction pairs other than the target instructions corresponding to the multiple instructions in the multiple target instruction pairs.
[0018] In one or more embodiments, retrieving the document piece corresponding to each of the instruction pairs includes:
[0019] Obtaining a target vector index for each of the instruction pairs;
[0020] Retrieving target instruction pairs that match each of the target vector indices from a preset database;
[0021] The document piece corresponding to the target instruction pair is used as the document piece of the instruction pair that matches the target instruction pair in each of the instruction pairs.
[0022] In one or more embodiments, retrieving a target instruction pair matching each of the target vector indexes from a preset database includes:
[0023] Calculating the similarity between each of the target vector indexes and the vector index of each instruction pair in the preset database;
[0024] Based on the similarity, selecting a plurality of similar instruction pairs having a similarity greater than a similarity threshold from the preset database;
[0025] The multiple similar instruction pairs are used as target instruction pairs of the instruction pairs corresponding to the target vector indexes.
[0026] In one or more embodiments, generating prompt words based on the document piece includes:
[0027] Get the prompt word generation template;
[0028] In the case where the number of the document pieces is greater than the preset number of input parameters of the prompt word generation template, based on the similarity between the vector index corresponding to the document piece and the target vector index, selecting the preset number of target document pieces with the highest similarity from the document pieces;
[0029] The plurality of target document pieces are embedded into the prompt word generation template to obtain the prompt word.
[0030] In one or more embodiments, before obtaining the test log of the test case, the method further includes:
[0031] Acquire a test task, wherein the test task includes use case information and simulation environment information of the test case;
[0032] Creating a smart card simulation environment based on the simulation environment information;
[0033] Running a test case corresponding to the use case information in the smart card simulation environment, and collecting test data generated by the test case during the running of the test case, the test data including a test command and a test response;
[0034] The test data is compared with the log corresponding to the test case, and the authenticity of the log of the test case is determined based on the comparison result.
[0035] In one or more embodiments, after aggregating the natural language description to obtain the test intent of the test case, the method further includes:
[0036] Obtaining manual inspection results of the test intent;
[0037] When the manual inspection result indicates that the accuracy of the test intent does not meet the accuracy condition, the preset database is updated.
[0038] The second aspect of the present application provides a device for testing a test suite, including:
[0039] An acquisition module, used to acquire the test logs of the test cases in the test suite;
[0040] A first obtaining module, configured to obtain a plurality of instruction pairs based on a test log, each of the instruction pairs comprising a test instruction and a test response corresponding to the test instruction;
[0041] A retrieval module, used to retrieve document pieces corresponding to each of the instruction pairs;
[0042] A generating module, used for generating prompt words of each of the instruction pairs based on the document piece;
[0043] A second obtaining module is used to call the large language model to identify the prompt words of each instruction pair, and obtain a natural language description of each instruction pair;
[0044] A summarizing module is used to summarize the natural language description to obtain the test intent of the test case.
[0045] A third aspect of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect.
[0046] The fourth aspect embodiment of the present application proposes a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the method described in the first aspect.
[0047] The technical solution provided in the embodiments of the present application has at least the following technical effects or advantages:
[0048] In an embodiment of the present application, after obtaining the test log of the test case in the test suite, the test log is divided into multiple instruction pairs, the document piece corresponding to each instruction pair is retrieved, the prompt words of the instruction pair are generated based on the document piece, the natural language description of each instruction pair is obtained, and the natural language description is summarized to finally obtain the test intent of the test case. All of these are completed automatically, and the entire process does not require manual intervention by the tester. Compared with related technologies, the testing efficiency and accuracy are improved.
[0049] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] By reading the detailed description of the preferred embodiment below, various other advantages and benefits will become clear to those of ordinary skill in the art. The accompanying drawings are only used for the purpose of illustrating the preferred embodiment and are not considered to be limitations of the present application. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings.
[0051] In the attached picture:
[0052] Figure 1 A flowchart of a method for testing a test suite provided by an embodiment of the present application is shown;
[0053] Figure 2 A schematic diagram showing test log standardization provided by an embodiment of the present application is shown;
[0054] Figure 3 A schematic diagram showing a process instruction provided by an embodiment of the present application is shown;
[0055] Figure 4 A schematic diagram showing a natural language description and a test intent provided by an embodiment of the present application is shown;
[0056] Figure 5 A block diagram of a system for executing a method for testing a test suite provided by an embodiment of the present application is shown;
[0057] Figure 6 A schematic diagram showing a device for testing a test kit provided in an embodiment of the present application is shown;
[0058] Figure 7 A schematic diagram of the structure of a computer device provided by an embodiment of the present application is shown;
[0059] Figure 8 A schematic diagram of a storage medium provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0060] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally 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 application claimed 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.
[0061] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0062] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0063] With the advancement of science and technology, people's lives are becoming more and more digitalized. While digital life brings many conveniences, it also brings many security risks, such as telecommunications fraud and identity theft. Smart card technology is one of the important technologies to avoid security risks. Smart card is an intelligent device with a security chip. It can store and process sensitive information and provide highly secure data transmission and processing capabilities. It has been widely used in electronic payment, identity authentication, access control and other scenarios.
[0064] Smart cards must have high security and high reliability, so smart card testing is a very important part of the card industry. Smart card testing involves many aspects, including chip hardware testing, such as electrical characteristics, performance and reliability; as well as chip software functional testing, security testing and compatibility testing.
[0065] Whether as a card issuer, application developer, system integrator or other companies in the smart card industry chain, they will conduct rigorous testing on smart cards. Usually, testing is carried out through a test suite, which refers to a complete set of smart card automated testing tools, including an executor and a test case set. The test case set is the core component of the test suite, which contains test cases for the functions of each module of the smart card and is a collection of smart card testing experience; the executor is the execution tool of the test case, which is responsible for connecting to the smart card, simulating the role of the terminal, issuing instructions to the smart card according to the test steps in the test case included in the test case set, and judging whether the return value meets expectations. In order to fully verify the smart card, companies usually purchase a large number of third-party or open source test suites on the basis of self-developed test suites to ensure that the smart card has been fully tested. However, the quality of the test suites from the above sources is often uneven, so verifying the quality of the test suite is an important prerequisite for ensuring the quality of smart cards.
[0066] Currently, the quality evaluation of test suites is mainly based on the test logs generated by the test suites. Coverage analysis is performed based on the logs, which can specifically include the following steps:
[0067] The first step is to parse the test instructions (APDU instructions) one by one. The tester parses the hexadecimal APDU instructions into head+data according to the APDU instruction specification. The head is further parsed in the format of CLA+INS+P1+P2+P3. The data needs to refer to the specific instruction requirements and further parse in the format of TLV, LV or DGI to obtain the fully parsed APDU instructions.
[0068] The second step is to parse the APDU response. The tester refers to the APDU response specification and decomposes the response into data+SW1+SW2. Then, according to the specific response specification, the data is further parsed in the format of TLV, LV or DGI to obtain the fully parsed APDU response.
[0069] Then the tester will translate the command pairs consisting of the parsed APDU command and APDU response into natural language one by one to obtain easy-to-understand test steps;
[0070] Then, based on experience, the natural language of the instruction pairs included in each test case is summarized into a test intent expressed in one sentence;
[0071] The last stage is the analysis stage. Testers need to compare the summarized test intent with the test intent described in the test case, and check whether the test steps are accurate and complete against the test specifications, and finally derive the coverage analysis degree of the test case. The above process requires testers with rich experience in smart card testing to perform.
[0072] The coverage analysis tests of the above test suites are all completed manually by testers, so extremely high industry experience is required of the testers. In addition, due to the huge number of test cases in the test suites, manual testing by testers also has the problem of low efficiency.
[0073] In order to alleviate the technical problems existing in the related art, the embodiments of the present application provide a method, apparatus, device and computer program product for testing a test suite. The solution of this embodiment, after obtaining the test log of the test case in the test suite, divides the test log into multiple instruction pairs, retrieves the document pieces corresponding to each instruction pair, generates prompt words for the instruction pair based on the document pieces, obtains the natural language description of each instruction pair, and summarizes the natural language description to finally obtain the test intent of the test case, all of which are completed automatically, and the entire process does not require manual intervention by the tester, which improves the test efficiency and accuracy compared to the related art.
[0074] To facilitate understanding of this embodiment, a method for testing a test suite disclosed in an embodiment of the present application is first introduced in detail. The execution subject of the method for testing a test suite provided in the embodiment of the present application is generally a computer device with certain computing capabilities, and the computer device includes, for example: a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the method for testing a test suite can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0075] See also Figure 1 As shown, it is a flowchart of a method for testing a test suite provided in an embodiment of the present application, and the method may include the following steps:
[0076] Step 101: Get the test log of the test case in the test suite.
[0077] Step 102: Based on the test log, a plurality of instruction pairs are obtained, each instruction pair including a test instruction and a test response corresponding to the test instruction.
[0078] In this embodiment, after a single test case is run, the computer device can obtain the test log of the test case, standardize the test log, analyze the standardized test log, and obtain multiple instruction pairs. Figure 2 The schematic diagram of test log standardization is shown in Figure 1. Figure 2 As shown, in the standardized test log, the test command (command) and the test response (Received) exist in pairs, and each test command uniquely corresponds to a test response, such as,
[0079] The test response corresponding to the test instruction “00A4040008A000005105000010” is “XXXXXXXXXX9000”.
[0080] In this embodiment, each instruction pair may include a test instruction and a test response corresponding to the test instruction. In practical applications, there may be process instructions in the test log, and process instructions refer to instructions that complete the same process, such as instructions and responses in the handshake process of implementing a TCP connection. Such instructions can be combined for processing, thereby reducing the subsequent analysis process.
[0081] In specific implementation, based on the test log, multiple instruction pairs are obtained, which may include the following steps:
[0082] The test log is divided into a plurality of target instruction pairs, each target instruction pair including a test instruction and a test response corresponding to the test instruction;
[0083] Finding multiple instructions belonging to the same process instruction from the instructions included in the multiple target instruction pairs;
[0084] Merging target instruction pairs corresponding to multiple instructions to obtain merged instruction pairs;
[0085] The merged instruction pairs and the remaining instruction pairs are taken as a plurality of instruction pairs, and the remaining instruction pairs are instruction pairs other than the target instructions corresponding to the plurality of instructions among the plurality of target instruction pairs.
[0086] In the application, process instructions can be basically enumerated, and each process instruction has a specific format, so different templates can be pre-configured for different process instructions. For example, some process instructions have a specific bit of 84, and some process instructions have a specific bit of 80, while non-process instructions have neither 80 nor 84 in these specific bits. When decomposing the test instructions to obtain multiple instruction pairs, the pre-configured process instruction template is used to match the test log. If there are instructions that match the process instruction template, the instruction pairs corresponding to these instructions are merged to obtain a merged instruction pair.
[0087] As an example, given Figure 3 Schematic diagram of the process instructions shown. Figure 3 The APDU instructions in the will be parsed as "download instruction, package xx, data: xxxx", but they all describe the same download process. The result of cleaning according to the pre-configured process instruction template is "download application, ELF_AID: xxxx, EM_AID: xxxxx, APP_AID: xxxxx".
[0088] Step 103: Retrieve the document pieces corresponding to each instruction pair.
[0089] In this embodiment, a database is pre-configured, and multiple groups of instruction pairs and document pieces are stored in the database. In a group of instruction pairs and document pieces, the document piece is used to describe the instruction pair. After obtaining multiple instruction pairs based on the test log, each instruction pair can be used to query the database to obtain a document piece corresponding to each instruction pair.
[0090] In a specific implementation, retrieving the document pieces corresponding to each instruction pair may include the following steps:
[0091] Get the target vector index of each instruction pair;
[0092] Retrieving target instruction pairs that match each target vector index from a preset database;
[0093] The document piece corresponding to the target instruction pair is used as the document piece of the instruction pair that matches the target instruction pair among all instruction pairs.
[0094] In this embodiment, the target vector index of each instruction pair and the vector index of each instruction pair in the preset database are obtained by using a word embedding model (text-embedding-ada-002). When matching with the instruction pair in the database, the target vector index is compared with the vector index of each instruction pair in the database, so as to find the target instruction pair matching the target vector index from the preset database.
[0095] In this embodiment, when comparing the target vector index with the vector index of each instruction pair in the database, the comparison result can be determined by calculating the similarity.
[0096] In a specific implementation, retrieving a target instruction pair matching each target vector index from a preset database may include the following steps:
[0097] Calculate the similarity between each target vector index and the vector index of each instruction pair in the preset database;
[0098] Based on the similarity, multiple similar instruction pairs having a similarity greater than a similarity threshold are selected from a preset database;
[0099] A plurality of similar instruction pairs are used as target instruction pairs for instruction pairs corresponding to each target vector index.
[0100] It should be understood that two vector indexes with higher similarity indicate that the instruction pairs corresponding to the two vector indexes have higher similarity. The similarity threshold can be preset artificially based on experience or as required, and this embodiment does not specifically limit this.
[0101] Step 104: Generate prompt words for each instruction pair based on the document piece.
[0102] In this embodiment, the prompt word can be generated based on the prompt word generation template. The prompt word corresponding to each instruction pair can be obtained by embedding the document piece corresponding to each instruction pair in the prompt word generation template.
[0103] Since the length of the prompt word affects the recognition speed and accuracy of the large prediction model, the number of input parameters of the prompt word generation template can be pre-set, the document pieces of each instruction pair can be screened according to the input number, and finally the prompt word is generated based on the screened document pieces.
[0104] In a specific implementation, generating prompt words based on the document piece may include the following steps:
[0105] Get the prompt word generation template;
[0106] When the number of document pieces is greater than the preset number of input parameters of the prompt word generation template, based on the similarity between the vector index corresponding to the document piece and the target vector index, a preset number of target document pieces with the highest similarity are selected from the document pieces;
[0107] Embed multiple target document fragments into a prompt word generation template to obtain the prompt words.
[0108] It should be understood that when the number of document pieces is less than or equal to the preset number of input parameters of the prompt word generation template, the document pieces do not need to be screened based on similarity, and the document pieces are directly embedded in the prompt word generation template to obtain the prompt word.
[0109] Step 105: Call the large language model to identify the prompt words of each instruction pair, and obtain the natural language description of each instruction pair.
[0110] In this embodiment, a knowledge base is pre-configured for the large prediction model. The knowledge base stores structured APDU instruction response parsed text data. The knowledge base can be used as a data source for the large prediction model to provide accuracy and availability of the large prediction model analysis.
[0111] Step 106: Summarize the natural language description to obtain the test intent of the test case.
[0112] In this embodiment, the large prediction model can still be used to summarize the natural language description to obtain the test intent of the test case.
[0113] As an example, given Figure 4 Schematic diagram of the natural language description and test intent shown. Figure 4 The left half of the test case is the test log, which includes 9 instruction pairs, each of which corresponds to a natural language description, namely Figure 4 The right half includes 9 natural language descriptions numbered 1-9. These 9 natural language descriptions are summarized into a test intent described in one sentence, namely, "create and configure 3 security domains and transfer 3 security domains to 1 security domain."
[0114] In this embodiment, before using the method to test the test suite, the method can also be used to update the database and knowledge base involved in the above-mentioned embodiment. Specifically, after obtaining the test intent, the tester can also check the test intent and return the manual inspection result to the computer device. The manual inspection result is used to enable the computer device to verify whether the output test intent is accurate, so as to determine whether to update the database or knowledge base used in the above-mentioned embodiment.
[0115] In the specific implementation, after summarizing the natural language description and obtaining the test intent of the test case, it also includes:
[0116] Obtain manual inspection results of test intent;
[0117] When the manual inspection result indicates that the accuracy of the test intent does not meet the accuracy condition, the preset database is updated.
[0118] In the application, the manual inspection results can be expressed in the form of 0 or 1, for example, 0 indicates that the accuracy condition is not met, and 1 indicates that the accuracy condition is met. In this way, after obtaining the manual inspection results, the computer device can directly determine whether the test intent of the manual inspection results does not meet the accuracy condition.
[0119] In the solution provided by this embodiment, after obtaining the test log of the test case in the test suite, the test log is divided into multiple instruction pairs, the document piece corresponding to each instruction pair is retrieved, the prompt words of the instruction pair are generated based on the document piece, the natural language description of each instruction pair is obtained, and the natural language description is summarized to finally obtain the test intent of the test case. All of these are completed automatically, and the entire process does not require manual intervention by the tester. Compared with related technologies, the testing efficiency and accuracy are improved.
[0120] In addition to the coverage analysis test of the test suite in the related technology, there is also the authenticity verification test. In the specific implementation, it is divided into two cases according to whether the test suite is open source. For the open source test suite, the tester randomly samples or extracts key test cases, manually reads and analyzes the source code of the test case, compares the test log, and judges whether it actually executes the test operation and is consistent with the log output result, then it can be judged as true; for the closed source test suite, there is currently no general technical solution for verification, and it can only rely on the reputation of the developer or the certification of an authoritative organization. Therefore, there is an urgent need for a general technical solution that can verify the closed source test suite. At the same time, because the related technology requires the tester to be able to read the source code of the test case to test the open source test suite, this requires the tester to have extremely high industry experience, which makes it difficult for general testers to directly test the open source test suite.
[0121] In order to alleviate the above-mentioned problems existing in the test process of authenticity verification of test cases of test suites in related technologies, this embodiment also provides a test scheme for authenticity verification. In specific implementation, before obtaining the test log of the test case, the following steps may also be included:
[0122] Obtaining a test task, which includes test case information and simulation environment information of the test case;
[0123] Creating a smart card simulation environment based on the simulation environment information;
[0124] Running the test case corresponding to the use case information in the smart card simulation environment, and collecting test data generated by the test case during the running of the test case, the test data including the test command and the test response;
[0125] The test data is compared with the log corresponding to the test case, and the authenticity of the log of the test case is determined based on the comparison result.
[0126] The use case information is used to uniquely identify a test case, and the use case information includes but is not limited to the number of the test case.
[0127] The smart card simulation environment is used to simulate the smart card, and the simulation environment information specifies the parameters required to simulate the smart card, such as the memory and CPU of the smart card.
[0128] In this embodiment, when running test cases in a smart card simulation environment, the test suite sends test instructions to the smart card simulation environment and receives test responses returned by the smart card simulation environment based on the test instructions. During this process, the computer device can collect test instructions and test responses interacted between the test suite and the smart card simulation environment.
[0129] It should be understood that when the test data is identical to the test log of the test case, it can be confirmed that the test log output by the test suite is authentic.
[0130] Please refer to Figure 5 , Figure 5 A block diagram of a system for executing a method for testing a test suite provided in this embodiment. Figure 5 As shown, the system may include:
[0131] Front-end interaction module (Web UI) 51, smart card simulator management module 52, instruction collection module 53, index database module 54, intelligent processing module 55 and large language model module 56;
[0132] in:
[0133] The front-end interaction module (Web UI) 51 is used to provide the main interface for system and user interaction, display the test results in a visual form, including authenticity verification, coverage analysis results, etc., and provide interface functions for raw data input and operation management of the simulation environment.
[0134] The smart card simulator management module 52 is used to provide and manage simulators of various smart card OSs, including the mainstream Java Card and the localized OneOS Card, by providing an adapter (port) for the test suite client to access, thereby simulating the test suite to send instructions.
[0135] The intelligent processing module 55 has the following functions:
[0136] Import data: receive texts imported by users from Web UI51. In smart card testing, the texts imported by users mainly involve protocol implementation texts related to GP / UICC, and their test specification implementations.
[0137] Process data: Process the imported text, including slicing, vectorization, storage, and prompt construction.
[0138] The constructing of prompt means: according to the pre-processed APDU instruction pair input, the related document piece is searched from the index database module 54 to construct the prompt.
[0139] The assembled prompt is passed to the LLM model (large language model) in the large language model module 56, and the LLM model converts the APDU instruction pair into a natural language description, summarizes all descriptions of a single test case, and generates a test intent summary.
[0140] The instruction collection module 53 is used to collect the instructions sent by the test suite and the returned responses from the smart card simulator management module 52 to form an APDU command and response pair log in the original hexadecimal format.
[0141] In order to facilitate the understanding of the solution, this embodiment also provides Figure 5 The flowchart of the method of testing a test suite of the system shown in FIG. 1 may include the following steps:
[0142] Step 1: The test suite coverage analysis system receives the knowledge base imported into the system.
[0143] Among them, the knowledge base includes: original knowledge documents, codes, and related structured data in the field of smart cards. This application introduces a structured APDU instruction response parsing text data for knowledge base supplement for LLM indexing, which can greatly improve the accuracy of LLM reasoning.
[0144] Step 2: The intelligent processing module classifies and loads the documents in the knowledge base, slices them, and stores the sliced documents as standardized vector data in the vector database.
[0145] Among them, this application uses mature spring+vue3 technology to develop front-end and back-end programs, providing a front-end operation interface for adding / deleting / version updating / reloading / previewing database documents, so as to greatly improve the efficiency of optimizing the knowledge base.
[0146] Step 3: After receiving the instruction from the tester to start the test task, the system starts the smart card environment and test suite, executes the test cases in the task, and starts the command and response collection to obtain the original test data with test case granularity.
[0147] Among them, this application divides the test task execution link into two steps. First, a smart card simulator environment is used to connect to the test suite under test. The simulator environment sends the APDU instructions it receives and returns to the instruction acquisition module to summarize them as reference logs, which are compared with the output logs of the test suite under test, thereby solving the problem that the authenticity of the closed-source test suite cannot be verified; then a productized smart card is used to replace the simulation environment to connect to the test suite under test, carry out subsequent tests, and collect output logs.
[0148] Step 4: The intelligent analysis module searches the local database with the test data in step 3, filters the relevant corpus fragments, forms a standardized prompt to call LLM to obtain the natural language conversion results of the test raw data and summarizes them into APDU instruction-level test logs according to the test case dimension.
[0149] Among them, this application abandons the traditional method of using machine learning training models, adopts the currently mature and common open source LLM for reasoning, and uses llama_index technology to connect local data with LLM; compared with retraining the model, it not only saves a lot of computing costs, but also greatly improves the accuracy and availability of generated content. Among them, this application uses standard interface encapsulation for LLM calls, realizes the decoupling of the intelligent analysis module from a specific LLM, and can quickly switch to an LLM with good subsequent effects at low cost.
[0150] Step 5: Based on the APDU instruction-level test log obtained in step 4, the intelligent analysis module first cleans the process instructions to form test steps, and then calls the summarize prompt to generate a one-sentence test intent for the test case; finally, it summarizes and generates a test case coverage analysis file with test case as the granularity, including test steps and a one-sentence test intent.
[0151] Among them, this application implements the generation of the final test steps and test intent in two steps. The first is to use a highly customized smart card APDU instruction cleaning process to clean and merge process instructions, greatly reducing the noise when the final intent is generated; the second is to use the advantages of LLM in summary generation again, call LLM for summary generation, and obtain a one-sentence test intent.
[0152] Subsequently, testers can analyze the test case coverage file output by the intelligent analysis module and compare it with the test specifications to analyze whether the coverage is complete.
[0153] Using this use case analysis file greatly reduces the workload of testers compared to lengthy and difficult-to-understand raw hexadecimal logs, and can efficiently evaluate the quality of the test suite.
[0154] The present application also provides an apparatus for testing a test suite, which is used to execute the method for testing a test suite provided in any of the above embodiments. Figure 6 As shown, the device comprises:
[0155] An acquisition module 61 is used to acquire the test logs of the test cases in the test suite;
[0156] A first obtaining module 62, configured to obtain a plurality of instruction pairs based on the test log, each of the instruction pairs comprising a test instruction and a test response corresponding to the test instruction;
[0157] A retrieval module 63, used to retrieve document pieces corresponding to each of the instruction pairs;
[0158] A generating module 64, configured to generate prompt words for each of the instruction pairs based on the document piece;
[0159] A second obtaining module 65 is used to call the large language model to identify the prompt words of each instruction pair, and obtain a natural language description of each instruction pair;
[0160] The summarizing module 66 is used to summarize the natural language description to obtain the test intent of the test case.
[0161] In one or more embodiments, the first obtaining module 62 is used to:
[0162] Dividing the test log into a plurality of target instruction pairs, each target instruction pair comprising a test instruction and a test response corresponding to the test instruction;
[0163] Searching for multiple instructions belonging to the same process instruction from the instructions included in the multiple target instruction pairs;
[0164] Merging target instruction pairs corresponding to the multiple instructions to obtain a merged instruction pair;
[0165] The merged instruction pair and the remaining instruction pairs are taken as the multiple instruction pairs, and the remaining instruction pairs are instruction pairs other than the target instructions corresponding to the multiple instructions in the multiple target instruction pairs.
[0166] In one or more embodiments, the retrieval module 63 is used to:
[0167] Obtaining a target vector index for each of the instruction pairs;
[0168] Retrieving target instruction pairs that match each of the target vector indices from a preset database;
[0169] The document piece corresponding to the target instruction pair is used as the document piece of the instruction pair that matches the target instruction pair in each of the instruction pairs.
[0170] In one or more embodiments, the retrieval module 63 is used to:
[0171] Calculating the similarity between each of the target vector indexes and the vector index of each instruction pair in the preset database;
[0172] Based on the similarity, selecting a plurality of similar instruction pairs having a similarity greater than a similarity threshold from the preset database;
[0173] The multiple similar instruction pairs are used as target instruction pairs of the instruction pairs corresponding to the target vector indexes.
[0174] In one or more embodiments, the generation module 64 is used to:
[0175] Get the prompt word generation template;
[0176] In the case where the number of the document pieces is greater than the preset number of input parameters of the prompt word generation template, based on the similarity between the vector index corresponding to the document piece and the target vector index, selecting the preset number of target document pieces with the highest similarity from the document pieces;
[0177] The plurality of target document pieces are embedded into the prompt word generation template to obtain the prompt word.
[0178] In one or more embodiments, the device is also used to:
[0179] Before obtaining the test log of the test case, obtain a test task, wherein the test task includes the test case information and simulation environment information of the test case;
[0180] Creating a smart card simulation environment based on the simulation environment information;
[0181] Running a test case corresponding to the use case information in the smart card simulation environment, and collecting test data generated by the test case during the running of the test case, the test data including a test command and a test response;
[0182] The test data is compared with the log corresponding to the test case, and the authenticity of the log of the test case is determined based on the comparison result.
[0183] In one or more embodiments, the device is also used to:
[0184] After summarizing the natural language description and obtaining the test intent of the test case, obtaining a manual inspection result of the test intent;
[0185] When the manual inspection result indicates that the accuracy of the test intent does not meet the accuracy condition, the preset database is updated.
[0186] The device for testing the test suite provided in the embodiment of the present application and the method for testing the test suite provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.
[0187] The present application also provides a computer device to execute the above-mentioned method for testing the test suite. Figure 7 It shows a schematic diagram of a computer device provided by some embodiments of the present application. Figure 7 As shown, the computer device 7 includes: a processor 700, a memory 701, a bus 702 and a communication interface 703, and the processor 700, the communication interface 703 and the memory 701 are connected via the bus 702; the memory 701 stores a computer program that can be run on the processor 700, and the processor 700 executes the method of testing the test suite provided in any of the aforementioned embodiments of the present application when running the computer program.
[0188] The memory 701 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the device network element and at least one other network element is realized through at least one communication interface 703 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0189] The bus 702 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 701 is used to store a program, and the processor 700 executes the program after receiving an execution instruction. The method for testing the test suite disclosed in any implementation of the embodiment of the present application may be applied to the processor 700, or implemented by the processor 700.
[0190] The processor 700 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 700. The above processor 700 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a readily available programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 701, and the processor 700 reads the information in the memory 701 and completes the steps of the above method in combination with its hardware.
[0191] The computer device provided in the embodiment of the present application and the method for testing the test suite provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented therein.
[0192] The present application also provides a computer-readable storage medium corresponding to the method for testing the test suite provided in the above embodiment. Figure 8 The computer-readable storage medium shown is a CD 30 on which a computer program (ie, a program product) is stored. When the computer program is executed by a processor, the method for testing the test suite provided in any of the aforementioned embodiments will be executed.
[0193] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.
[0194] The computer-readable storage medium provided in the above-mentioned embodiments of the present application and the method for testing the test suite provided in the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.
[0195] An embodiment of the present application also provides a computer program product corresponding to the method of testing a test suite provided in the aforementioned embodiment, including a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the method of testing a test suite provided in any of the aforementioned embodiments.
[0196] It should be noted that:
[0197] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known structures and technologies are not shown in detail so as not to obscure the understanding of this description.
[0198] Similarly, it should be understood that in order to streamline the present application and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following schematic diagram: the claimed application requires more features than the features clearly stated in each claim. More specifically, as reflected in the claims below, the inventive aspects are less than all the features of the single embodiment disclosed above. Therefore, the claims following the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present application.
[0199] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present application and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0200] The above is only a preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for testing a test suite, characterized in that: include: Obtaining test logs for test cases in the test suite; Based on the test log, a plurality of instruction pairs are obtained, each of which includes a test instruction and a test response corresponding to the test instruction; Retrieving document pieces corresponding to each of the instruction pairs; Based on the document piece, generating prompt words for each of the instruction pairs; Calling a large language model to identify prompt words of each instruction pair to obtain a natural language description of each instruction pair; The natural language description is summarized to obtain the test intent of the test case.
2. The method according to claim 1, characterized in that Based on the test log, multiple instruction pairs are obtained, including: Dividing the test log into a plurality of target instruction pairs, each target instruction pair comprising a test instruction and a test response corresponding to the test instruction; Searching for multiple instructions belonging to the same process instruction from the instructions included in the multiple target instruction pairs; Merging target instruction pairs corresponding to the multiple instructions to obtain a merged instruction pair; The merged instruction pair and the remaining instruction pairs are taken as the multiple instruction pairs, and the remaining instruction pairs are instruction pairs other than the target instructions corresponding to the multiple instructions in the multiple target instruction pairs.
3. The method according to claim 1 or 2, characterized in that: Retrieving document pieces corresponding to each of the instruction pairs, including: Obtaining a target vector index for each of the instruction pairs; Retrieving target instruction pairs that match each of the target vector indices from a preset database; The document piece corresponding to the target instruction pair is used as the document piece of the instruction pair that matches the target instruction pair in each of the instruction pairs.
4. The method according to claim 3, characterized in that Retrieving target instruction pairs matching each of the target vector indexes from a preset database, including: Calculating the similarity between each of the target vector indexes and the vector index of each instruction pair in the preset database; Based on the similarity, selecting a plurality of similar instruction pairs having a similarity greater than a similarity threshold from the preset database; The multiple similar instruction pairs are used as target instruction pairs of the instruction pairs corresponding to the target vector indexes.
5. The method according to claim 4, characterized in that Based on the document piece, a prompt word is generated, including: Get the prompt word generation template; In the case where the number of the document pieces is greater than the preset number of input parameters of the prompt word generation template, based on the similarity between the vector index corresponding to the document piece and the target vector index, selecting the preset number of target document pieces with the highest similarity from the document pieces; The plurality of target document pieces are embedded into the prompt word generation template to obtain the prompt word.
6. The method according to claim 1, characterized in that Before getting the test log of the test case, also include: Acquire a test task, wherein the test task includes use case information and simulation environment information of the test case; Creating a smart card simulation environment based on the simulation environment information; Running a test case corresponding to the use case information in the smart card simulation environment, and collecting test data generated by the test case during the running of the test case, the test data including a test command and a test response; The test data is compared with the log corresponding to the test case, and the authenticity of the log of the test case is determined based on the comparison result.
7. The method according to claim 3, characterized in that After summarizing the natural language description and obtaining the test intent of the test case, the following is further included: Obtaining manual inspection results of the test intent; When the manual inspection result indicates that the accuracy of the test intent does not meet the accuracy condition, the preset database is updated.
8. A device for testing a test suite, characterized in that: include: An acquisition module, used to acquire the test logs of the test cases in the test suite; A first obtaining module, configured to obtain a plurality of instruction pairs based on a test log, each of the instruction pairs comprising a test instruction and a test response corresponding to the test instruction; A retrieval module, used to retrieve document pieces corresponding to each of the instruction pairs; A generating module, used for generating prompt words of each of the instruction pairs based on the document piece; A second obtaining module is used to call the large language model to identify the prompt words of each instruction pair, and obtain a natural language description of each instruction pair; A summarizing module is used to summarize the natural language description to obtain the test intent of the test case.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: The processor runs the computer program to implement the method according to any one of claims 1 to 7.
10. A computer program product, characterized in that The invention comprises a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the method as claimed in any one of claims 1 to 7.
