CN117707987A - Test case detection method and device, electronic equipment and storage medium - Google Patents

Test case detection method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117707987A
CN117707987A CN202410166446.5A CN202410166446A CN117707987A CN 117707987 A CN117707987 A CN 117707987A CN 202410166446 A CN202410166446 A CN 202410166446A CN 117707987 A CN117707987 A CN 117707987A
Authority
CN
China
Prior art keywords
test case
grammar
detected
detection
database
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
CN202410166446.5A
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.)
DMAI Guangzhou Co Ltd
Original Assignee
DMAI Guangzhou 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 DMAI Guangzhou Co Ltd filed Critical DMAI Guangzhou Co Ltd
Priority to CN202410166446.5A priority Critical patent/CN117707987A/en
Publication of CN117707987A publication Critical patent/CN117707987A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Machine Translation (AREA)

Abstract

The application provides a detection method and device for a test case, electronic equipment and a storage medium, wherein the detection method comprises the following steps: acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database; performing sentence similarity check on the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal sentence of the detected test case, marking the duplicate removal sentence, and storing a marking result of the duplicate removal sentence into a database; and carrying out grammar checking on the detected test cases based on a natural language processing model, if grammar errors are checked, marking the wrong grammar contents in the detected first test cases, and storing the marking results of the wrong grammar contents into a database. The quality of the test case is improved, and the problems possibly occurring when the test case is executed are reduced.

Description

Test case detection method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer application technologies, and in particular, to a method and apparatus for detecting a test case, an electronic device, and a storage medium.
Background
A test case is a set of test inputs, execution conditions, and expected results that are formulated for a certain goal in order to test a certain program path or verify whether a certain specific requirement is met. In software testing, test cases often accumulate, the number grows continuously, and the test cases can be adjusted according to the continuous requirement of optimizing projects, and the testers including writing the test cases are not identical, so that the management and maintenance of the test cases often face the following challenges: and (5) testing the case repeatedly for format consistency and format errors. Currently, test case management typically relies on manual inspection and maintenance, which can lead to inefficiency and susceptibility to errors. Therefore, how to reduce the manual operation of the test cases and improve the accuracy of the test cases becomes a technical problem that is not small.
Disclosure of Invention
In view of this, an object of the present application is to provide a test case detection method, apparatus, electronic device, and storage medium, by performing repeated content detection and error grammar detection on a test case, so as to optimize a technical problem of low test case quality caused by repeated inspection after the test case is written and ambiguous errors of test case description by a tester, improve the quality of the test case, and reduce possible problems when executing the test case.
The embodiment of the application provides a detection method of a test case, which comprises the following steps:
acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database;
performing sentence similarity check on the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal sentence of the detected first test case, marking the duplicate removal sentence, and storing a marking result of the duplicate removal sentence into the database;
carrying out grammar checking on the first test case passing the detection based on a natural language processing model, if grammar errors are checked, marking wrong grammar contents in the first test case passing the detection, and storing marking results of the wrong grammar contents into the database;
and continuously receiving the second test case input by the user, and carrying out format content detection, sentence similarity detection and grammar detection on the second test case.
In one possible implementation manner, after the natural language processing model is used for carrying out grammar checking on the detected first test case, if grammar errors are checked, marking and correcting the grammar contents of the errors in the detected first test case, and storing the corrected marking result in the database, the detection method further comprises:
Generating a calibration report of the first test case based on the detected marking result of the first test case, the duplication eliminating statement and the marking result of the wrong grammar content in the database;
and correcting the detected first test case based on the marking result of the duplicate removal statement and the marking result of the wrong grammar content in the calibration report of the first test case, and generating a corrected first test case.
In one possible implementation manner, the detecting the format content of the first test case, storing the detected first test case in a database, includes:
code format detection is carried out on the first test case based on a regular expression, and if the first test case does not pass the code format detection, the first test case is not stored in the database;
if the first test case passes the code format detection, performing code cycle traversal on the first test case to judge whether the content of the first test case accords with preset content, if so, passing the first test case, and storing the passed first test case into the database;
And if the first test case does not accord with the preset content, not storing the first test case into the database.
In one possible implementation manner, the performing, based on a pre-trained text similarity algorithm model, a sentence similarity check on the detected first test case, determining a duplicate removal sentence of the detected first test case, and marking the duplicate removal sentence, including:
performing sentence similarity check on the detected first test case based on the text similarity algorithm model, and determining the similarity between each sentence of the detected first test case and other sentences;
and determining the duplicate removal statement passing through the detected first test case based on the similarity and a preset similarity threshold, and marking the duplicate removal statement in the detected first test case.
In one possible implementation manner, the grammar checking of the first test case passing through the detection based on the natural language processing model, if a grammar error is checked, marking the wrong grammar content in the first test case passing through the detection, and storing the marking result of the wrong grammar content in the database, including:
The natural language processing model checks at least one grammar item in bracket statement, variable statement, function call, conditional statement and cyclic statement included in the first test case based on standard code writing grammar rule, if grammar error is checked, marks the grammar content passing the error in the first test case, and stores the marking result of the grammar content passing the error into the database.
In one possible implementation, the text similarity algorithm model is trained by:
acquiring label information of a plurality of sample test cases;
inputting the sample test case into an initial text similarity algorithm model, checking sentence similarity of the sample test case, and determining a duplicate removal sentence of the sample test case;
and carrying out iterative training on the initial text similarity algorithm model based on the deduplication statement of the sample test case and the label information of the sample test case, and determining the text similarity algorithm model.
In one possible implementation manner, the iterative training of the initial text similarity algorithm model based on the deduplication statement of the sample test case and the tag information of the sample test case, to determine the text similarity algorithm model includes:
Determining a loss value of the initial text similarity algorithm model based on the deduplication statement of the sample test case and the real deduplication statement in the tag information of the sample test case;
detecting whether the loss value is larger than a preset loss threshold value, if not, stopping iterative training of the initial text similarity algorithm model, and determining the text similarity algorithm model;
if yes, changing model parameters of the initial text similarity algorithm model, continuing to train the changed initial text similarity algorithm model in an iterative mode until the loss value is smaller than or equal to the preset loss threshold value, stopping training the initial text similarity algorithm model in an iterative mode, and determining the text similarity algorithm model.
The embodiment of the application also provides a detection device for the test case, which comprises:
the first detection module is used for acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database;
the similarity checking module is used for checking statement similarity of the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal statement of the detected first test case, marking the duplicate removal statement, and storing a marking result of the duplicate removal statement into the database;
The grammar checking module is used for carrying out grammar checking on the first test case which passes the detection based on a natural language processing model, marking the wrong grammar content in the first test case which passes the detection if grammar errors are checked, and storing the marking result of the wrong grammar content into the database;
and the second detection module is used for continuously receiving the second test case input by the user, and detecting the format content, the similarity of the sentences and the grammar of the second test case.
The embodiment of the application also provides electronic equipment, which comprises: the system comprises a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, the processor and the memory are communicated through the bus when the electronic device runs, and the machine-readable instructions are executed by the processor to execute the steps of the detection method of the test case.
The embodiments of the present application also provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor performs the steps of the method for detecting a test case as described above.
The embodiment of the application provides a detection method, a detection device, electronic equipment and a storage medium for a test case, wherein the detection method comprises the following steps: acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database; performing sentence similarity check on the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal sentence of the detected first test case, marking the duplicate removal sentence, and storing a marking result of the duplicate removal sentence into the database; carrying out grammar checking on the first test case passing the detection based on a natural language processing model, if grammar errors are checked, marking wrong grammar contents in the first test case passing the detection, and storing marking results of the wrong grammar contents into the database; and continuously receiving the second test case input by the user, and carrying out format content detection, sentence similarity detection and grammar detection on the second test case. The beneficial effects are as follows: by detecting the repeated content and the error grammar of the test case, the technical problem of low test case quality caused by repeated checking after the test case is written by a tester and ambiguous errors of test case description is solved, the quality of the test case is improved, and the possible problems in executing the test case are reduced.
In order to make the above objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered limiting the scope, and that other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for detecting a test case according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a test case detection method according to an embodiment of the present application;
FIG. 3 is a schematic structural diagram of a test case detection apparatus according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a second embodiment of a test case detection apparatus according to the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the accompanying drawings in the present application are only for the purpose of illustration and description, and are not intended to limit the protection scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this application, illustrates operations implemented according to some embodiments of the present application. It should be appreciated that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to the flow diagrams and one or more operations may be removed from the flow diagrams as directed by those skilled in the art.
In addition, the described embodiments are only some, but not all, of the embodiments of the present application. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, as provided in the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, are intended to be within the scope of the present application.
In order to enable those skilled in the art to make use of the present application, the following embodiments are provided in connection with a particular application scenario "test case detection", and the generic principles defined herein may be applied to other embodiments and application scenarios without departing from the spirit or scope of the application.
First, application scenarios applicable to the present application will be described. The method and the device can be applied to the technical field of computer application.
It has been found that a test case is a set of test inputs, execution conditions, and expected results that are tailored for a certain goal in order to test a certain program path or verify whether a certain specific requirement is met. In software testing, test cases often accumulate, the number grows continuously, and the test cases can be adjusted according to the continuous requirement of optimizing projects, and the testers including writing the test cases are not identical, so that the management and maintenance of the test cases often face the following challenges: and (5) testing the case repeatedly for format consistency and format errors. Currently, test case management typically relies on manual inspection and maintenance, which can lead to inefficiency and susceptibility to errors. Therefore, how to reduce the manual operation of the test cases and improve the accuracy of the test cases becomes a technical problem that is not small.
Based on the above, the embodiment of the application provides a test case detection method, which optimizes the technical problem of low test case quality caused by repeated checking after the test case is written and ambiguous errors of test case description by performing repeated content detection and error grammar detection on the test case, improves the test case quality, and reduces the possible problems when the test case is executed.
Referring to fig. 1, fig. 1 is a flowchart of a test case detection method according to an embodiment of the present application. As shown in fig. 1, a detection method provided in an embodiment of the present application includes:
s101: and acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database.
In the step, a first test case of software input by a user is obtained, format content detection is carried out on the first test case, and the detected first test case is stored in a TestCase table record of a database.
Here, in addition to storing the detected first test case into the TestCase table record of the database, the detected first test case may also be stored into the distributed storage system.
In one possible implementation manner, the detecting the format content of the first test case, storing the detected first test case in a database, includes:
a: and carrying out code format detection on the first test case based on a regular expression, and if the first test case does not pass the code format detection, not storing the first test case into the database.
And if the first test case does not pass the code format detection, the first test case is not stored in the database.
Wherein the code format is a standard code format in the prior art.
B: if the first test case passes the code format detection, performing code cycle traversal on the first test case to judge whether the content of the first test case accords with preset content, if so, passing the detection on the first test case, and storing the passed detection on the first test case into the database.
If the first test case passes the code format detection, performing code cycle traversal on the first test case to judge whether the content of the first test case accords with the preset content, if so, passing the detection on the first test case, and storing the detected first test case into a database.
The preset content is preset test content corresponding to the first test case.
C: and if the first test case does not accord with the preset content, not storing the first test case into the database.
If the first test case does not meet the preset content, the first test case is not stored in the database.
The first test case is imported, the format and the content of the first test case need to be judged, namely the adopted regular expression and code traversing circulation are needed, the regular expression is used for judging the code format first, then the circulating traversing is used for judging whether the code content accords with the code format, if so, the first test case and the second test case can be successfully imported and stored in a database and a distributed storage system.
S102: and carrying out sentence similarity check on the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal sentence of the detected first test case, marking the duplicate removal sentence, and storing a marking result of the duplicate removal sentence into the database.
In the step, sentence similarity checking is carried out on the detected first test case according to a pre-trained text similarity algorithm model, duplicate removal sentences of the detected first test case are determined, the duplicate removal sentences are marked, and the marked results of the duplicate removal sentences are stored in a database.
The marking result of the duplicate removal statement is the position information of the duplicate removal statement in the first test case.
In one possible implementation manner, the performing, based on a pre-trained text similarity algorithm model, a sentence similarity check on the detected first test case, determining a duplicate removal sentence of the detected first test case, and marking the duplicate removal sentence, including:
(1): and carrying out sentence similarity check on the detected first test case based on the text similarity algorithm model, and determining the similarity between each sentence of the detected first test case and other sentences.
And performing sentence similarity detection on the detected first test case according to the text similarity algorithm model, and determining the similarity between each sentence of the detected first test case and other sentences in the detected first test case.
Here, the similarity check may be performed on the vocabulary of the first test case that passes the detection in addition to the similarity check on the sentence.
(2): and determining the duplicate removal statement passing through the detected first test case based on the similarity and a preset similarity threshold, and marking the duplicate removal statement in the detected first test case.
Here, the statement corresponding to the similarity exceeding the preset similarity threshold is determined as the duplicate removal statement of the detected first test case, and the duplicate removal statement of the detected first test case is marked.
In one possible implementation, the text similarity algorithm model is trained by:
a: and acquiring a plurality of sample test cases and label information of each sample test case.
Here, a plurality of sample test cases and tag information of each sample test case are acquired.
b: and inputting the sample test case into an initial text similarity algorithm model, checking the sentence similarity of the sample test case, and determining the duplicate removal sentence of the sample test case.
And inputting the sample test case into the initial text similarity algorithm model, and checking the sentence similarity of the sample test case to determine the duplicate removal sentence of the sample test case.
c: and carrying out iterative training on the initial text similarity algorithm model based on the deduplication statement of the sample test case and the label information of the sample test case, and determining the text similarity algorithm model.
And performing iterative training on the initial text similarity algorithm model according to the deduplication statement of the sample test case and the label information of the sample test case, and determining the text similarity algorithm model.
In one possible implementation manner, the iterative training of the initial text similarity algorithm model based on the deduplication statement of the sample test case and the tag information of the sample test case, to determine the text similarity algorithm model includes:
i: and determining the loss value of the initial text similarity algorithm model based on the duplicate removal statement of the sample test case and the real duplicate removal statement in the label information of the sample test case.
And calculating the duplicate removal statement of the sample test case and the real duplicate removal statement in the label information of the sample test case according to the loss function, and determining the loss value of the initial text similarity algorithm model.
II: and detecting whether the loss value is larger than a preset loss threshold value, if not, stopping iterative training of the initial text similarity algorithm model, and determining the text similarity algorithm model.
Here, whether the loss value is larger than a preset loss threshold value is detected, if not, the iterative training of the initial text similarity algorithm model is stopped, and the text similarity algorithm model is determined.
III: if yes, changing model parameters of the initial text similarity algorithm model, continuing to train the changed initial text similarity algorithm model in an iterative mode until the loss value is smaller than or equal to the preset loss threshold value, stopping training the initial text similarity algorithm model in an iterative mode, and determining the text similarity algorithm model.
If yes, the model parameters of the initial text similarity algorithm model are changed, iteration training is continued on the changed initial text similarity algorithm model until the loss value is smaller than or equal to a preset loss threshold value, the iteration training on the initial text similarity algorithm model is stopped, and the text similarity algorithm model is determined.
Text similarity algorithms include, for example, cosine similarity, edit distance, BERT similarity algorithm, and the like.
Here, the model detects whether the imported cases have similar words and sentences based on the initial text similarity algorithm, while this allows the model to identify similar or duplicate test cases even if they are not identical in literal text. The algorithm needs to be trained in advance, meets the current use case format, needs to be subjected to fine tuning training aiming at the use case format, needs to read the model file and the test use case file, and then carries out training through training rules and the current equipment architecture, wherein the training result can be directly displayed through the model and can be stored in ceph. The imported text similar algorithm model needs to be imported into the ceph, the model files are stored in the current task life cycle, if the current task life cycle is finished, a timing cleaning script is used for cleaning the model files in the ceph, and the files are ensured not to be redundant.
S103: and carrying out grammar checking on the first test case passing the detection based on a natural language processing model, if grammar errors are checked, marking wrong grammar contents in the first test case passing the detection, and storing marking results of the wrong grammar contents into the database.
In the step, grammar checking is carried out on the first test case passing through the detection according to a natural language processing model, if grammar errors are checked, wrong grammar contents in the first test case passing through the detection are marked, and marking results of the wrong grammar contents are stored in a database.
After the grammar checking, the test cases in ceph are updated. The distributed storage system of the ceph open source used by the storage position of the test case deploys the ceph cluster, and simultaneously configures a storage pool and uses RADOS Gateway provided by the ceph to configure and manage object storage, and the POSIX compatible distributed file system is used for storing and viewing the test case and other model files and the like.
The method comprises the steps of accessing a natural language processing model or other components, checking related errors of semantics and grammar through the natural language processing model, marking for a round, updating test cases in ceph, and recording the number and positions of marks in a database.
In one possible implementation manner, the grammar checking of the first test case passing through the detection based on the natural language processing model, if a grammar error is checked, marking the wrong grammar content in the first test case passing through the detection, and storing the marking result of the wrong grammar content in the database, including:
the natural language processing model checks at least one grammar item in bracket statement, variable statement, function call, conditional statement and cyclic statement included in the first test case based on standard code writing grammar rule, if grammar error is checked, marks the grammar content passing the error in the first test case, and stores the marking result of the grammar content passing the error into the database.
The natural language processing model checks at least one grammar item in bracket statement, variable statement, function call, conditional statement and loop statement included in the first test case according to standard code writing grammar rule, if grammar error is checked, marks the grammar content passing the error in the detected first test case, and stores the marking result of the grammar content in the database.
The system adopts an NLP technology to analyze natural language texts in test cases, and marks errors or non-standard parts by introducing an algorithm or accessing an NLP semantic generalization platform to detect semantics and vocabulary in the test cases. Through NLP, the system can understand the semantic structure of the test case, identify keywords and phrases, and perform grammar and semantic analysis.
In the scheme, if the model is accessed to the natural language processing model, a specific algorithm is required to be imported, the imported model is stored in ceph, but the model is not stored for a long time, namely, the model file is cleared after training is completed. Meanwhile, the system supports a specific case format for the test case to be imported on the premise of checking semantic vocabulary errors and removing duplication of a similarity algorithm based on NLP, and is used for checking and correcting the test case under the rule of the adaptation algorithm. When the system needs to perform standard interception in S101, namely before the test case is imported, the problem that the process cannot be executed due to errors in the format is solved, namely the case is not standard and cannot be performed to the next step.
In the scheme, the system can ensure the format consistency and correctness of the test cases by automatically executing the format check. This helps to eliminate grammar errors and format problems in test cases, improves the quality of test cases, and reduces problems that may occur when test cases are executed. Through similarity analysis, the system can identify and de-duplicate similar test cases, so that the work of repeatedly creating similar test cases is reduced, and the maintenance cost of test case management is reduced.
In one possible implementation manner, after the natural language processing model is used for carrying out grammar checking on the detected first test case, if grammar errors are checked, marking and correcting the grammar contents of the errors in the detected first test case, and storing the corrected marking result in the database, the detection method further comprises:
(one): and generating a calibration report of the first test case based on the detected first test case, the marking result of the duplicate removal statement and the marking result of the wrong grammar content in the database.
Here, a calibration report of the first test case is generated from the detected first test case, the marking result of the deduplication statement, and the marking result of the erroneous grammatical content in the database.
Specifically, reading a TestCase table record in a database, namely obtaining a marking result of a duplicate removal statement and a marking result of wrong grammar content, connecting the database through a python script library sqlalchemy code after reading is completed, executing a read_sql query data table, and writing the query result into the code to generate a comparison report.
In the scheme, the calibration report is generated, so that a user can quickly identify and repair the problems in the test case. This helps to ensure the accuracy and consistency of the test cases, improving the readability of the test cases.
(II): and correcting the detected first test case based on the marking result of the duplicate removal statement and the marking result of the wrong grammar content in the calibration report of the first test case, and generating a corrected first test case.
Here, the detected first test case is corrected according to the marking result of the duplicate removal statement and the marking result of the wrong grammar content in the calibration report of the first test case, and the corrected first test case is generated.
Specifically, deleting the duplicate removal statement in the detected first test case, correcting the grammar content of the error in the detected first test case, and generating a corrected first test case.
S104: and continuously receiving the second test case input by the user, and carrying out format content detection, sentence similarity detection and grammar detection on the second test case.
In the step, the second test case input by the user is continuously received, and format content detection, sentence similarity detection and grammar detection are carried out on the second test case, so that the test case input by the user in real time is detected, the quality of the test case is improved, and the possible problems in executing the test case are reduced. Here, the checking process of the second test case is consistent with the checking process of the first test case, and this part will not be described in detail.
Further, referring to fig. 2, fig. 2 is a schematic diagram of a test case detection method according to an embodiment of the present application. As shown in FIG. 2, a test case in an execl format is imported through a platform system, python codes and regular expressions are written to check and verify the content and the format of the test case, and the test case is stored in a database after the check and verification of the test case are passed. Sentence similarity checking is carried out on the test cases based on the text similarity algorithm model, a marking result of the duplicate removal sentence is generated, grammar checking is carried out on the test cases based on the natural language processing model, a marking result of wrong grammar content is generated, the test cases are corrected according to the marking result of wrong grammar content and the marking result of the duplicate removal sentence, new test cases are generated, meanwhile, a checking result is generated on the test cases, final checking is completed, a case checking report can be generated, and export can be carried out on the newly generated test cases.
The embodiment of the application provides a detection method of a test case, which comprises the following steps: acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database; performing sentence similarity check on the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal sentence of the detected first test case, marking the duplicate removal sentence, and storing a marking result of the duplicate removal sentence into the database; carrying out grammar checking on the first test case passing the detection based on a natural language processing model, if grammar errors are checked, marking wrong grammar contents in the first test case passing the detection, and storing marking results of the wrong grammar contents into the database; and continuously receiving the second test case input by the user, and carrying out format content detection, sentence similarity detection and grammar detection on the second test case. By detecting the repeated content and the error grammar of the test case, the technical problem of low test case quality caused by repeated checking after the test case is written by a tester and ambiguous errors of test case description is solved, the quality of the test case is improved, and the possible problems in executing the test case are reduced.
Referring to fig. 3 and fig. 4, fig. 3 is a schematic structural diagram of a test case inspection device according to an embodiment of the present application, and fig. 4 is a schematic structural diagram of a test case inspection device according to an embodiment of the present application. As shown in fig. 3, the test case detection apparatus 300 includes:
the first detection module 310 is configured to obtain a first test case input by a user, detect format content of the first test case, and store the detected first test case into a database;
the similarity checking module 320 is configured to perform sentence similarity checking on the detected first test case based on a pre-trained text similarity algorithm model, determine a duplicate removal sentence of the detected first test case, mark the duplicate removal sentence, and store a marking result of the duplicate removal sentence into the database;
the grammar checking module 330 is configured to perform grammar checking on the detected first test case based on a natural language processing model, if a grammar error is checked, mark the erroneous grammar content in the detected first test case, and store the marking result of the erroneous grammar content in the database;
And the second detection module 340 is configured to continuously receive the second test case input by the user, and perform format content detection, sentence similarity detection and grammar detection on the second test case.
Further, as shown in fig. 4, the test case detection apparatus 300 further includes a correction module 350, where the correction module 350 is configured to:
generating a calibration report of the first test case based on the detected marking result of the first test case, the duplication eliminating statement and the marking result of the wrong grammar content in the database;
and correcting the detected first test case based on the marking result of the duplicate removal statement and the marking result of the wrong grammar content in the calibration report of the first test case, and generating a corrected first test case.
Further, when the first detection module 310 is configured to detect the format content of the first test case and store the detected first test case in a database, the first detection module 310 is specifically configured to:
code format detection is carried out on the first test case based on a regular expression, and if the first test case does not pass the code format detection, the first test case is not stored in the database;
If the first test case passes the code format detection, performing code cycle traversal on the first test case to judge whether the content of the first test case accords with preset content, if so, passing the first test case, and storing the passed first test case into the database;
and if the first test case does not accord with the preset content, not storing the first test case into the database.
Further, when the similarity checking module 320 is configured to perform a sentence similarity check on the detected first test case based on the pre-trained text similarity algorithm model, and determine that the duplicate-removed sentence of the detected first test case is passed, the similarity checking module 320 is specifically configured to:
performing sentence similarity check on the detected first test case based on the text similarity algorithm model, and determining the similarity between each sentence of the detected first test case and other sentences;
and determining the duplicate removal statement passing through the detected first test case based on the similarity and a preset similarity threshold, and marking the duplicate removal statement in the detected first test case.
Further, the grammar checking module 330 is further configured to perform grammar checking on the detected first test case based on the natural language processing model, if a grammar error is checked, mark the wrong grammar content in the detected first test case, and store the marking result of the wrong grammar content in the database, where the grammar checking module 330 is specifically configured to:
the natural language processing model checks at least one grammar item in bracket statement, variable statement, function call, conditional statement and cyclic statement included in the first test case based on standard code writing grammar rule, if grammar error is checked, marks the grammar content passing the error in the first test case, and stores the marking result of the grammar content passing the error into the database.
Further, as shown in fig. 4, the test case detection apparatus 300 further includes a model training module 360, where the model training module 360 is configured to:
acquiring label information of a plurality of sample test cases;
inputting the sample test case into an initial text similarity algorithm model, checking sentence similarity of the sample test case, and determining a duplicate removal sentence of the sample test case;
And carrying out iterative training on the initial text similarity algorithm model based on the deduplication statement of the sample test case and the label information of the sample test case, and determining the text similarity algorithm model.
Further, when the model training module 360 is configured to iteratively train the initial text similarity algorithm model based on the deduplication statement of the sample test case and the tag information of the sample test case, the model training module 360 is specifically configured to:
determining a loss value of the initial text similarity algorithm model based on the deduplication statement of the sample test case and the real deduplication statement in the tag information of the sample test case;
detecting whether the loss value is larger than a preset loss threshold value, if not, stopping iterative training of the initial text similarity algorithm model, and determining the text similarity algorithm model;
if yes, changing model parameters of the initial text similarity algorithm model, continuing to train the changed initial text similarity algorithm model in an iterative mode until the loss value is smaller than or equal to the preset loss threshold value, stopping training the initial text similarity algorithm model in an iterative mode, and determining the text similarity algorithm model.
The embodiment of the application provides a detection device of test case, detection device includes: the first detection module is used for acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database; the similarity checking module is used for checking statement similarity of the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal statement of the detected first test case, marking the duplicate removal statement, and storing a marking result of the duplicate removal statement into the database; the grammar checking module is used for carrying out grammar checking on the first test case which passes the detection based on a natural language processing model, marking the wrong grammar content in the first test case which passes the detection if grammar errors are checked, and storing the marking result of the wrong grammar content into the database; and the second detection module is used for continuously receiving the second test case input by the user, and detecting the format content, the similarity of the sentences and the grammar of the second test case. By detecting the repeated content and the error grammar of the test case, the technical problem of low test case quality caused by repeated checking after the test case is written by a tester and ambiguous errors of test case description is solved, the quality of the test case is improved, and the possible problems in executing the test case are reduced.
Referring to fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 5, the electronic device 500 includes a processor 510, a memory 520, and a bus 530.
The memory 520 stores machine-readable instructions executable by the processor 510, and when the electronic device 500 is running, the processor 510 communicates with the memory 520 through the bus 530, and when the machine-readable instructions are executed by the processor 510, the steps of the method for detecting a test case in the method embodiment shown in fig. 1 can be executed, and a specific implementation manner may refer to the method embodiment and will not be described herein.
The embodiment of the present application further provides a computer readable storage medium, where a computer program is stored on the computer readable storage medium, and when the computer program is executed by a processor, the steps of the method for detecting a test case in the method embodiment shown in fig. 1 may be executed, and a specific implementation manner may refer to the method embodiment and will not be described herein.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the foregoing examples are merely specific embodiments of the present application, and are not intended to limit the scope of the present application, but the present application is not limited thereto, and those skilled in the art will appreciate that while the foregoing examples are described in detail, the present application is not limited thereto. Any person skilled in the art may modify or easily conceive of the technical solution described in the foregoing embodiments, or make equivalent substitutions for some of the technical features within the technical scope of the disclosure of the present application; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for detecting a test case, the method comprising:
acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database;
performing sentence similarity check on the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal sentence of the detected first test case, marking the duplicate removal sentence, and storing a marking result of the duplicate removal sentence into the database;
carrying out grammar checking on the first test case passing the detection based on a natural language processing model, if grammar errors are checked, marking wrong grammar contents in the first test case passing the detection, and storing marking results of the wrong grammar contents into the database;
and continuously receiving the second test case input by the user, and carrying out format content detection, sentence similarity detection and grammar detection on the second test case.
2. The method according to claim 1, wherein after the first test case passing the detection is checked for grammar based on a natural language processing model, if a grammar error is checked, the grammar content of the error in the first test case passing the detection is subjected to mark correction, and a result of the correction mark is stored in the database, the method further comprises:
Generating a calibration report of the first test case based on the detected marking result of the first test case, the duplication eliminating statement and the marking result of the wrong grammar content in the database;
and correcting the detected first test case based on the marking result of the duplicate removal statement and the marking result of the wrong grammar content in the calibration report of the first test case, and generating a corrected first test case.
3. The method according to claim 1, wherein the detecting the format content of the first test case, storing the detected first test case in a database, includes:
code format detection is carried out on the first test case based on a regular expression, and if the first test case does not pass the code format detection, the first test case is not stored in the database;
if the first test case passes the code format detection, performing code cycle traversal on the first test case to judge whether the content of the first test case accords with preset content, if so, passing the first test case, and storing the passed first test case into the database;
And if the first test case does not accord with the preset content, not storing the first test case into the database.
4. The method according to claim 1, wherein the performing, based on a pre-trained text similarity algorithm model, a sentence similarity check on the detected first test case, determining a duplicate-removed sentence of the detected first test case, and marking the duplicate-removed sentence includes:
performing sentence similarity check on the detected first test case based on the text similarity algorithm model, and determining the similarity between each sentence of the detected first test case and other sentences;
and determining the duplicate removal statement passing through the detected first test case based on the similarity and a preset similarity threshold, and marking the duplicate removal statement in the detected first test case.
5. The method according to claim 1, wherein the grammar checking of the first test case passing the detection based on the natural language processing model, if a grammar error is checked, marking the erroneous grammar content in the first test case passing the detection, and storing the marking result of the erroneous grammar content in the database, comprises:
The natural language processing model checks at least one grammar item in bracket statement, variable statement, function call, conditional statement and cyclic statement included in the first test case based on standard code writing grammar rule, if grammar error is checked, marks the grammar content passing the error in the first test case, and stores the marking result of the grammar content passing the error into the database.
6. The method of claim 1, wherein the text similarity algorithm model is trained by:
acquiring label information of a plurality of sample test cases;
inputting the sample test case into an initial text similarity algorithm model, checking sentence similarity of the sample test case, and determining a duplicate removal sentence of the sample test case;
and carrying out iterative training on the initial text similarity algorithm model based on the deduplication statement of the sample test case and the label information of the sample test case, and determining the text similarity algorithm model.
7. The method according to claim 6, wherein the iteratively training the initial text similarity algorithm model based on the deduplication statement of the sample test case and the tag information of the sample test case, to determine the text similarity algorithm model, comprises:
Determining a loss value of the initial text similarity algorithm model based on the deduplication statement of the sample test case and the real deduplication statement in the tag information of the sample test case;
detecting whether the loss value is larger than a preset loss threshold value, if not, stopping iterative training of the initial text similarity algorithm model, and determining the text similarity algorithm model;
if yes, changing model parameters of the initial text similarity algorithm model, continuing to train the changed initial text similarity algorithm model in an iterative mode until the loss value is smaller than or equal to the preset loss threshold value, stopping training the initial text similarity algorithm model in an iterative mode, and determining the text similarity algorithm model.
8. A test case detection apparatus, the detection apparatus comprising:
the first detection module is used for acquiring a first test case input by a user, detecting format content of the first test case, and storing the detected first test case into a database;
the similarity checking module is used for checking statement similarity of the detected first test case based on a pre-trained text similarity algorithm model, determining a duplicate removal statement of the detected first test case, marking the duplicate removal statement, and storing a marking result of the duplicate removal statement into the database;
The grammar checking module is used for carrying out grammar checking on the first test case which passes the detection based on a natural language processing model, marking the wrong grammar content in the first test case which passes the detection if grammar errors are checked, and storing the marking result of the wrong grammar content into the database;
and the second detection module is used for continuously receiving the second test case input by the user, and detecting the format content, the similarity of the sentences and the grammar of the second test case.
9. An electronic device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating via said bus when the electronic device is running, said machine readable instructions when executed by said processor performing the steps of the method for detecting a test case according to any of claims 1 to 7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the test case detection method according to any of claims 1 to 7.
CN202410166446.5A 2024-02-06 2024-02-06 Test case detection method and device, electronic equipment and storage medium Pending CN117707987A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410166446.5A CN117707987A (en) 2024-02-06 2024-02-06 Test case detection method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410166446.5A CN117707987A (en) 2024-02-06 2024-02-06 Test case detection method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117707987A true CN117707987A (en) 2024-03-15

Family

ID=90162938

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410166446.5A Pending CN117707987A (en) 2024-02-06 2024-02-06 Test case detection method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117707987A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110471838A (en) * 2019-07-08 2019-11-19 深圳壹账通智能科技有限公司 Method of calibration, device, computer equipment and the storage medium of test case
CN112416806A (en) * 2020-12-09 2021-02-26 西北大学 JS engine fuzzy test method based on standard document analysis
WO2021208727A1 (en) * 2020-11-24 2021-10-21 平安科技(深圳)有限公司 Text error detection method and apparatus based on artificial intelligence, and computer device
CN114385491A (en) * 2021-12-30 2022-04-22 大连理工大学 JS translator defect detection method based on deep learning
CN116893960A (en) * 2023-06-29 2023-10-17 兴业银行股份有限公司 Code quality detection method, apparatus, computer device and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110471838A (en) * 2019-07-08 2019-11-19 深圳壹账通智能科技有限公司 Method of calibration, device, computer equipment and the storage medium of test case
WO2021208727A1 (en) * 2020-11-24 2021-10-21 平安科技(深圳)有限公司 Text error detection method and apparatus based on artificial intelligence, and computer device
CN112416806A (en) * 2020-12-09 2021-02-26 西北大学 JS engine fuzzy test method based on standard document analysis
CN114385491A (en) * 2021-12-30 2022-04-22 大连理工大学 JS translator defect detection method based on deep learning
CN116893960A (en) * 2023-06-29 2023-10-17 兴业银行股份有限公司 Code quality detection method, apparatus, computer device and storage medium

Similar Documents

Publication Publication Date Title
US9535894B2 (en) Automated correction of natural language processing systems
US20220083450A1 (en) Automated bug fixing using deep learning
CN106886509A (en) A kind of academic dissertation form automatic testing method
US11790166B2 (en) Quality assessment method for automatic annotation of speech data
CN111090641A (en) Data processing method and device, electronic equipment and storage medium
CN111651978A (en) Entity-based lexical examination method and device, computer equipment and storage medium
CN112925524A (en) Method and device for detecting unsafe direct memory access in driver
CN115481396A (en) NC code abnormality detection method, device, equipment and storage medium
CN114385491A (en) JS translator defect detection method based on deep learning
CN113157565B (en) Feedback JS engine fuzzy test method and device based on seed case mutation
Qiu et al. Deep just-in-time defect localization
CN112540925A (en) New characteristic compatibility detection system and method, electronic device and readable storage medium
CN111178037A (en) Repeated defect report identification method and device and electronic equipment
CN114969334B (en) Abnormal log detection method and device, electronic equipment and readable storage medium
CN117707987A (en) Test case detection method and device, electronic equipment and storage medium
CN116360794A (en) Database language analysis method, device, computer equipment and storage medium
CN116245076A (en) Automatic construction method of DRC test version gallery, DRC method, DRC system and readable storage medium
CN114201177A (en) File generation method, file generation device, electronic equipment, medium and computer program product
CN110633204B (en) Program defect detection method and device
CN115185920A (en) Method, device and equipment for detecting log type
CN114860873A (en) Method, device and storage medium for generating text abstract
CN114065762A (en) Text information processing method, device, medium and equipment
CN112101019A (en) Requirement template conformance checking optimization method based on part-of-speech tagging and chunk analysis
CN113672512A (en) Code inspection rule generating method, code inspection method, device and medium
US11087097B2 (en) Automatic item generation for passage-based assessment

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