CN113609018A - Test method, training method, device, apparatus, medium, and program product - Google Patents

Test method, training method, device, apparatus, medium, and program product Download PDF

Info

Publication number
CN113609018A
CN113609018A CN202110905553.1A CN202110905553A CN113609018A CN 113609018 A CN113609018 A CN 113609018A CN 202110905553 A CN202110905553 A CN 202110905553A CN 113609018 A CN113609018 A CN 113609018A
Authority
CN
China
Prior art keywords
interface
data
interface data
classification model
training
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
CN202110905553.1A
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.)
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology 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 Industrial and Commercial Bank of China Ltd ICBC, ICBC Technology Co Ltd filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202110905553.1A priority Critical patent/CN113609018A/en
Publication of CN113609018A publication Critical patent/CN113609018A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • G06N20/10Machine learning using kernel methods, e.g. support vector machines [SVM]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Evolutionary Computation (AREA)
  • Computing Systems (AREA)
  • Medical Informatics (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Artificial Intelligence (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present disclosure provides a test method, apparatus, device, medium, and program product, which relate to the field of artificial intelligence or the field of finance, and the like. The test method comprises the following steps: acquiring N first interface data; classifying the N first interface data by using an interface classification model, wherein the interface classification model is obtained by training based on interface specifications of a scene to be tested; obtaining M second interface data based on the classification result of the interface classification model, wherein the N first interface data comprise the M second interface data, N and M are integers which are respectively larger than or equal to 1, and N is larger than or equal to M; and testing the scene to be tested based on the M second interface data. The present disclosure also provides a training method, apparatus, device, medium and program product.

Description

Test method, training method, device, apparatus, medium, and program product
Technical Field
The present disclosure relates to the field of artificial intelligence or the field of finance, and the like, and more particularly, to a testing method, a training method, an apparatus, a device, a medium, and a program product.
Background
Before a money item product is put into production formally, tests are often performed in order to find that the product may have problems as early as possible and improve the quality of service of the product. For example, in a service provided by a product, a user may perform a number of operations to handle the service in a sequence or rule. Upon receiving each operation submitted by the user, the data may be requested from the interface of the server, and then received and processed to handle the business step by step for the user. During the testing process, the tester is required to manually configure the interfaces and parameters that may be involved in a service to ensure that data can be processed normally during the user operation.
In implementing the disclosed concept, the inventors found that there are at least the following problems in the related art:
the process of manually configuring the interface by a tester is complicated, and incomplete configuration is easy to cause the interface to be tested to be missed, so that the test effect is not ideal.
Disclosure of Invention
In view of the above, the present disclosure provides a test method, a training method, an apparatus, a device, a medium, and a program product capable of automatically configuring an interface data list.
One aspect of the disclosed embodiments provides a test method. The test method comprises the following steps: acquiring N first interface data; classifying the N first interface data by using an interface classification model, wherein the interface classification model is obtained by training based on interface specifications of a scene to be tested; obtaining M second interface data based on the classification result of the interface classification model, wherein the N first interface data comprise the M second interface data, N and M are integers which are respectively larger than or equal to 1, and N is larger than or equal to M; and testing the scene to be tested based on the M second interface data.
According to an embodiment of the present disclosure, the acquiring N first interface data includes: determining at least one target scene based on the test service of the scene to be tested; and acquiring the N first interface data from the at least one target scene.
According to an embodiment of the present disclosure, before the acquiring N first interface data, the method further includes: training the interface classification model based on the interface specification using a machine learning algorithm; wherein the machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
According to an embodiment of the present disclosure, the training the interface classification model based on the interface specification using a machine learning algorithm includes: obtaining a training sample set, wherein the training sample set comprises at least one third interface data; determining at least one characteristic data of the third interface data based on the interface specification; training the interface classification model based on the at least one feature data.
According to an embodiment of the present disclosure, the at least one third interface data includes one or more classes of interface data, and in the case that the machine learning algorithm is the bayesian classification algorithm, the training the interface classification model based on the at least one feature data includes: calculating a conditional probability of obtaining each of the at least one feature data and a prior probability of obtaining interface data for each of the one or more categories; and training and obtaining the interface classification model based on the conditional probability and the prior probability.
According to an embodiment of the present disclosure, the classifying the N first interface data using the interface classification model includes: acquiring the at least one feature data of each first interface data in the N first interface data; classifying the each first interface data based on the conditional probability and the prior probability.
According to an embodiment of the present disclosure, the at least one feature data comprises: at least one of a type of interface, an interface URL value, a number of interface parameters, a type of interface parameter, or an interface return value.
Another aspect of the embodiments of the present disclosure provides a method for training an interface classification model. The training method comprises the following steps: training the interface classification model based on an interface specification of a scene to be tested by utilizing a machine learning algorithm, so that the interface classification model classifies N first interface data to obtain M second interface data, and testing the scene to be tested, wherein the N first interface data comprise the M second interface data, N and M are integers which are respectively greater than or equal to 1, and N is greater than or equal to M; wherein the machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
Another aspect of the present disclosure provides a test apparatus. The testing device comprises a first obtaining module, an interface classification module, a second obtaining module and a scene testing module. The first obtaining module is used for obtaining N first interface data. The interface classification module is used for classifying the N pieces of first interface data by using an interface classification model, wherein the interface classification model is obtained by training based on interface specifications of a scene to be tested; the second obtaining module is configured to obtain M second interface data based on a classification result of the interface classification model, where the N first interface data include the M second interface data, N and M are integers greater than or equal to 1, respectively, and N is greater than or equal to M. The scene testing module is used for testing the scene to be tested based on the M second interface data.
Another aspect of the present disclosure provides an exercise device. The training device comprises a first training module, a second training module and a third training module, wherein the first training module is used for training an interface classification model based on an interface specification of a scene to be tested by utilizing a machine learning algorithm, so that the interface classification model classifies N first interface data to obtain M second interface data for testing the scene to be tested, the N first interface data comprise the M second interface data, N and M are integers which are respectively greater than or equal to 1, and N is greater than or equal to M; wherein the machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
Another aspect of the present disclosure provides an electronic device including: one or more processors; memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method as described above.
Another aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method as described above.
Another aspect of the disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the method as described above.
One or more of the embodiments described above have the following advantages or benefits: the problem that interface data are easily missed to be tested when testers manually configure the interface data can be at least partially solved, the N first interface data are classified through an interface classification model obtained through interface specification training based on a scene to be tested, M second interface data are obtained, the process that the testers manually configure the interface data and then use the interface data for testing is avoided, effective interface data are screened out through classification, the second interface data which can be used for the scene to be tested are comprehensively obtained, the testing range is expanded, and the testing effect is improved.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an application scenario diagram suitable for implementing a testing method or a training method according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow diagram of a testing method according to an embodiment of the present disclosure;
FIG. 3 schematically shows a flow chart for obtaining N first interface data according to an embodiment of the disclosure;
FIG. 4 schematically illustrates a flow diagram of a testing method according to another embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow diagram of training an interface classification model according to an embodiment of the present disclosure;
FIG. 6 schematically illustrates a flow diagram for training an interface classification model based on at least one feature data according to an embodiment of the present disclosure;
FIG. 7 schematically illustrates a flow chart for classifying N first interface data using an interface classification model according to an embodiment of the present disclosure;
FIG. 8 schematically shows a block diagram of a test apparatus according to an embodiment of the present disclosure; and
FIG. 9 schematically illustrates a block diagram of an electronic device suitable for implementing a testing method or a training method according to an embodiment of the disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
Embodiments of the present disclosure provide a test method, apparatus, device, medium, and program product. The test method comprises the following steps: n first interface data are obtained. And classifying the N first interface data by using an interface classification model, wherein the interface classification model is obtained by training based on the interface specification of the scene to be tested. And obtaining M pieces of second interface data based on the classification result of the interface classification model, wherein the N pieces of first interface data comprise M pieces of second interface data, N and M are integers which are larger than or equal to 1 respectively, and N is larger than or equal to M. And testing the scene to be tested based on the M second interface data. Another embodiment of the present disclosure also provides a training method, apparatus, device, medium, and program product.
According to the embodiment of the disclosure, the N pieces of first interface data are classified through the interface classification model obtained through interface specification training based on the scene to be tested, so that the M pieces of second interface data are obtained, and the process that testers manually configure the interface data and then use the interface data for testing is avoided. Therefore, effective interface data are screened out through the classification process, the interface data which can be used for a scene to be tested are comprehensively obtained, the test range is expanded, and the test effect is improved.
It should be noted that the testing method, the training method, the apparatus, the device, the medium, and the program product provided in the embodiments of the present disclosure may be applied to the artificial intelligence technology in the aspects related to product testing, and may also be applied to various fields other than the artificial intelligence technology, such as the financial field. The application fields of the test method, the training device, the equipment, the medium and the program product provided by the embodiment of the disclosure are not limited.
Fig. 1 schematically illustrates an application scenario diagram suitable for implementing a testing method or a training method according to an embodiment of the present disclosure.
As shown in fig. 1, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (for example only) providing support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the testing method or the training method provided by the embodiments of the present disclosure may be executed by the same or different servers, and the testing device or the training device may also be disposed in the same or different devices. In particular, the testing methods or training methods provided by embodiments of the present disclosure may generally be performed by the server 105. Accordingly, the testing device or training device provided by the embodiments of the present disclosure may be generally disposed in the server 105. The testing method or training method provided by the embodiments of the present disclosure may also be performed by a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the testing device or the training device provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The testing method and the training method of the embodiment of the present disclosure will be described in detail below with fig. 2 to 7 based on the scenario described in fig. 1.
Fig. 2 schematically shows a flow chart of a testing method according to an embodiment of the present disclosure.
As shown in fig. 2, the test method of this embodiment includes operations S210 to S240.
In operation S210, N first interface data are acquired.
According to the embodiment of the disclosure, for example, in a scenario where a user registers an account through a web page, data such as an account category, a request verification code, a request region, and the like may be requested, and data such as a user name, a mailbox, and the like may also be sent. Each type of data may be requested, transmitted or received by a different interface, and the parameters transmitted or received by the interfaces have corresponding format or content requirements. The crawler technology can be used for crawling a plurality of first interface data (such as URL links, return values and the like) from the network, and effective interface data can be acquired from a large amount of data. The interface data may include a set of abstract methods and parameters set when the interface is defined, and data contents returned by the interface during operation.
In operation S220, the N first interface data are classified by using an interface classification model, where the interface classification model is obtained by training based on an interface specification of a scene to be tested.
According to an embodiment of the present disclosure, the interface specification includes an interface data definition set according to a test service provided by a scene to be tested. Taking a scene of registering an account through a web page as an example of a scene to be tested, wherein the service is a registration service. The interface specification may include interface type, number of interfaces, abstract methods in the interfaces, number of interface parameters, parameter type, parameter value, inheritance relationship of subclasses in the interfaces, data transfer relationship between various interfaces, and the like. The first interface data may include one or more data included in the interface specification. In other words, the scene to be tested sets an interface with a predetermined format through the interface specification so as to transmit and process data in the business handling process.
In operation S230, M second interface data are obtained based on the classification result of the interface classification model, where N first interface data include M second interface data, N and M are integers greater than or equal to 1, respectively, and N is greater than or equal to M.
According to the embodiment of the disclosure, since the interface classification model learns the interface specification in the scene to be tested in the training process, the N pieces of first interface data can be classified according to the specification during classification, for example, the first interface data conforming to the interface specification is classified into effective interface data, and the effective interface data can be used as the second interface data.
In operation S240, a scene to be tested is tested based on the M second interface data.
According to the embodiment of the disclosure, the N first interface data are classified through the interface classification model obtained through the interface specification training based on the scene to be tested, so as to obtain the M second interface data, and the process that testers manually configure the interface data and then test is avoided. Therefore, effective interface data are screened out through the classification process, second interface data which can be used for a scene to be tested are comprehensively obtained, the test range is expanded, and the test effect is improved.
Fig. 3 schematically shows a flowchart of acquiring N first interface data in operation S210 according to an embodiment of the present disclosure.
As shown in fig. 3, the test method for acquiring N first interface data in operation S210 includes operations S310 to S320.
In operation S310, at least one target scenario is determined based on a test service of a scenario to be tested.
In operation S320, N first interface data are acquired from at least one target scene.
According to the embodiment of the disclosure, when interface data is crawled in a full network by adopting a crawler technology, most invalid interface data may be included in the obtained interface data. Therefore, processing invalid interface data, whether in the crawling phase or the classification phase using the interface classification model, wastes significant time and computational resources.
Taking a scene of registering an account number through a web page as an example of a scene to be tested, wherein the testing service is a registration service. First, a registration page (i.e., at least one target scenario) for other products (e.g., a cell phone application or a website with a registration page) may be obtained. Then, N pieces of first interface data are acquired from the registered account pages of other products.
In other embodiments of the present disclosure, a correspondence relationship between different first interface data may be obtained from the first interface data of at least one target scenario, where the correspondence relationship may include a parameter transfer relationship between multiple operations in a business process.
By using the testing method of the embodiment of the disclosure, the data acquisition range can be narrowed by determining the target scene first, so that the acquired interface data is more accurate, and thus, the waste of time and the excessive processing of resources on invalid interface data are avoided. In addition, by obtaining the interface data of at least one target scene or the corresponding relation between the interface data, various application scenes after the production can be simulated in advance, so that the test cases are expanded, and the test effect is improved.
Fig. 4 schematically shows a flow chart of a testing method according to another embodiment of the present disclosure.
As shown in fig. 4, the test method of this embodiment includes operations S210 to S240, and before operation S210, operation S410 may be further included. The operations S210 to S240 may refer to the description of fig. 1, and are not described herein again.
In operation S410, an interface classification model is trained based on interface specifications using a machine learning algorithm. The machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
According to the embodiment of the disclosure, in the related art, the interface is manually configured by the tester, the mode of testing the interface data is defined, the tester has higher requirements on the aspects of understanding the service content of the scene to be tested, mastering the programming technology, understanding the interface specification and the like, and the situations of configuration errors or interface omission cannot be avoided. The interface classification model is obtained by training with a machine learning algorithm, and the interface specification can be learned in the training process, so that interface data meeting the requirements can be obtained from other existing products according to the interface specification, the requirements on testers can be reduced, the testing range is expanded, and the testing effect is improved.
Fig. 5 schematically shows a flowchart of training the interface classification model in operation S410 according to an embodiment of the present disclosure.
As shown in fig. 5, the training of the interface classification model based on the at least one feature data in operation S410 includes operations S510 to S530.
In operation S510, a training sample set is obtained, wherein the training sample set includes at least one third interface data.
In operation S520, at least one feature data of the third interface data is determined based on the interface specification.
According to the embodiment of the present disclosure, for example, the valid interface data conforming to the interface specification includes an interface name including a service name, and interface parameter values of types json, int, and the like, where the interface type is a post type or a get type (just an example). Thus, the determination of the characteristic data can be made from the interface name, the interface type, the parameter, and the like. Referring to table 1, table 1 shows URL (Uniform Resource Locator) examples of the valid interface and the invalid interface.
TABLE 1
Figure BDA0003198297320000101
According to an embodiment of the present disclosure, the at least one feature data includes: at least one of a type of interface, an interface URL value, a number of interface parameters, a type of interface parameter, or an interface return value.
Referring to Table 1, the interface URL values may include parameter values or service names, such as "www", "sp 1", "Youxiao", "Wuxiao", and the like. Interface parameters may include "mod", "ibd", "pid", "lid". The type of interface, the interface return value, the type of parameter are not listed in table 1. For example, the interface specification may specify that the interface URL values include "www" and "Youxiao", the number of interface parameters is 2, and the type of parameter value is int type. As shown in table 1, the number of interface parameters in the valid interface and the invalid interface is 2, the values of "mod" and "ibd" in the valid interface are 1, and the value of "lid" in the invalid interface does not meet the requirement. And the URL value in the invalid interface does not conform to the interface specification.
It should be noted that the interface URL values, the interface parameters, and the like in table 1 are merely examples, and specific values of the feature data may be set according to actual needs, which is not limited in the present disclosure.
In operation S530, an interface classification model is trained based on the at least one feature data.
According to an embodiment of the present disclosure, each third interface data in the training sample set may have a corresponding class label, such as an active data label or an inactive data label.
When the machine learning algorithm is a K-nearest neighbor algorithm, the K-nearest neighbor algorithm classifies the interface data to be classified into a class where the interface data with a label close to the interface data is located. Firstly, at least one feature data of each third interface data is obtained, and a standardized feature matrix is obtained through preprocessing. Then, the similarity of the feature matrix and the feature matrix of the third interface data corresponding to the class label is calculated, and the prediction classification result is output according to the similarity. The similarity can be obtained by calculating Euclidean distance (only as an example), a loss function can be constructed based on the prediction classification result and the class label in the training process, an interface classification model meeting the requirement is obtained by minimizing the loss function, and the test is carried out by using the test set.
When the machine learning algorithm is a support vector machine, firstly, a category distribution condition is obtained based on a category label corresponding to third interface data in a training sample set. Then, a kernel function is constructed for training of the interface classification model, and classification boundaries are drawn based on the kernel function. Next, a predictive classification result is output based on the at least one feature data of each third interface data. And finally, continuously optimizing parameters in the model by predicting the classification result and the class label, and testing by using the test set until the requirements are met.
When the machine learning algorithm is a logistic regression algorithm, at least one feature data of each third interface data is obtained and preprocessed to obtain a standardized feature matrix. Then, based on the feature matrix, a loss function (e.g., a sigmod function) is used to map the class probability of each third interface data to (0, 1), and the predicted classification result is output according to the mapped value. The process of training the interface classification model by using the logistic regression algorithm is to learn an 0/1 classification model from the training sample set. And finally, testing by using the test set until the requirements are met.
When the machine learning algorithm is the ensemble learning algorithm, firstly, a weak learner 1 is trained from a training sample set by using an initial weight, and the weight of the sample is updated according to the learning error rate of the weak learner 1, wherein the initial weight refers to a weight corresponding to each feature data, for example, and the learning error rate refers to the error rate of the prediction classification result output by the weak learner 1 to the third interface data in the training sample set relative to the class label, for example. Then, based on the updated weight, a weak learner 2 is trained, in which the weight is updated by giving greater importance to the third interface data having a high error rate in the weak learner 1 during the training of the weak learner 2. The above steps are repeated in a circulating mode until a preset number of weak learners are obtained. And finally, integrating through a set strategy to obtain a strong learner, namely using the strong learner as an interface classification model.
In some embodiments of the present disclosure, a plurality of K-nearest neighbor algorithms, support vector machines, logistic regression algorithms, or ensemble learning algorithms may be used jointly to obtain the interface classification model.
According to the embodiment of the disclosure, the input of the interface classification model is at least one kind of feature data, and the feature data is obtained according to the interface specification, so the interface classification model has a high classification effect on the interface data, and thus has high adaptability to the interface classification scene.
Fig. 6 schematically illustrates a flowchart of training an interface classification model based on at least one feature data in operation S530 according to an embodiment of the present disclosure.
As shown in fig. 6, the at least one third interface data includes one or more classes (such as the class labels mentioned above) of interface data, and in the case that the machine learning algorithm is a bayesian classification algorithm, the training of the interface classification model includes operations S610 to S620.
According to an embodiment of the present disclosure, the bayesian algorithm is defined as follows:
firstly, one or more third interface data x in a training sample set are obtainediE.g. X ═ X1,x2,x3……,xn}。
Then, a category set Y ═ Y is defined1,y2,y3……,yn}。
Then, extracting at least one characteristic data c of each third interface datajE.g. feature data set Ci={c1,c2,c3……,cn}。
Then, a conditional probability P (y) is calculatedi) And a probability P (y)i|xj) Wherein, in the step (A),
P(yi|xj)=P(xj|yi)*P(yi) Formula (1)
P(xj|yi)=P(c1|yi)*P(c2|yi)*P(c3|yi)......P(cn|yi) Formula (2)
Wherein, P (c)j|yi) Is a prior probability.
Finally, determining the category of each third interface data according to the formula (3), and removing the category label for comparison, wherein the category of each third interface data is calculated according to the following formula:
P(yk|xi)=Max{P(y1|xi),P(y2|xi),P(y3|xi)…P(yn|yi)}
formula (3)
Wherein, ykIs xiClass to which y belongskBelonging to the set Y.
In operation S610, a conditional probability of obtaining each of the at least one feature data and a prior probability of obtaining interface data of each of the one or more classes are calculated.
According to an embodiment of the present disclosure, the feature data set C may include a type of interface, an interface URL value, a number of interface parameters, and an interface return value. The set of categories Y may include valid interface data Y1And invalid interface data y2
First, a conditional probability P (y) is calculated1) And P (y)2)。
Then, taking the interface type as post or get as an example, P (type ═ post | y) is calculated1),P(type=post|y2),P(type=get|y1),P(type=post|y2) And the prior probability is equal. Other characteristic data may be obtained in the same manner.
In operation S620, an interface classification model is obtained based on the conditional probability and the prior probability training.
According to the embodiment of the disclosure, a Bayesian classification algorithm is utilized to obtain a plurality of classifiers by extracting different feature data or giving different weights to the prior probability corresponding to each feature data, and an optimal classifier is determined as an interface classification model based on the classification result. The Bayesian classification algorithm training model is simple and quick, and can obtain the interface classification model with higher efficiency, so that the classification result of each interface data can be accurately obtained through a plurality of characteristic data by combining the interface specification of the scene to be tested.
Fig. 7 schematically illustrates a flowchart of classifying the N first interface data by using the interface classification model in operation S220 according to an embodiment of the present disclosure.
As shown in fig. 7, the test method of this embodiment includes operations S710 to S720.
In operation S710, at least one feature data of each of the N first interface data is acquired.
In operation S720, each first interface data is classified based on the conditional probability and the prior probability.
According to the embodiment of the present disclosure, for example, the feature data of one first interface data x' are: the interface type is post, the URL value is Youxiao, the number of parameters (param) is 5, the return value response is 1, the prior probability of each feature data and the conditional probability obtained in the training process are obtained, and the feature data are classified, as follows:
P(x’|y1)=P(y1)*P(type=post|y1)*P(URL=*Youxiao|y1)*P(param=5|y1)*P(response=1|y1) Formula (4)
P(x’|y2)=P(y2)*P(type=post|y2)*P(URL=*Youxiao|y2)*P(param=5|y2)*P(response=1|y2) Formula (5)
If P (x' | y)1) Greater than P (x' | y)2) Then the first interface data x' belongs to y1Class, i.e. valid interface data.
It should be noted that the various feature data of the first interface data x' are merely examples, and the feature data may be arbitrarily selected according to actual requirements, and the disclosure is not particularly limited.
Based on the test method, the disclosure also provides a test device.
Fig. 8 schematically shows a block diagram of a test apparatus 800 according to an embodiment of the present disclosure.
As shown in fig. 8, the testing apparatus 800 of this embodiment includes a first obtaining module 810, an interface classifying module 820, a second obtaining module 830, and a scenario testing module 840.
The first obtaining module 810 may perform operation S210, for example, to obtain N first interface data.
According to an embodiment of the present disclosure, the first obtaining module 810 may further perform operations S310 to S310, for example, to determine at least one target scenario based on a test service of a scenario to be tested. N first interface data are acquired from at least one target scene.
The interface classification module 820 may perform operation S220, for example, to classify the N first interface data by using an interface classification model, where the interface classification model is trained based on the interface specification of the scene to be tested.
According to an embodiment of the disclosure, the interface classification module 820 may further perform operations S710 to S720, for example, to obtain at least one feature data of each of the N pieces of first interface data. Each first interface data is classified based on the conditional probability and the prior probability.
The second obtaining module 830 may perform operation S230, for example, to obtain M second interface data based on the classification result of the interface classification model, where N first interface data includes M second interface data, N and M are integers greater than or equal to 1, respectively, and N is greater than or equal to M.
The scenario testing module 840 may perform operation S240, for example, to test the scenario to be tested based on the M second interface data.
According to an embodiment of the present disclosure, the testing device 800 may further include a second training module. The second training module may perform operation S410, for example, to train an interface classification model based on an interface specification of a scene to be tested by using a machine learning algorithm, so that the interface classification model classifies N first interface data to obtain M second interface data to test the scene to be tested, where the N first interface data include M second interface data, N and M are integers greater than or equal to 1, respectively, and N is greater than or equal to M. The machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
According to an embodiment of the present disclosure, the second training module may further perform operations S510 to S530, for example, to obtain a training sample set, where the training sample set includes at least one third interface data. At least one characteristic data of the third interface data is determined based on the interface specification. An interface classification model is trained based on at least one feature data.
According to an embodiment of the present disclosure, the second training module may further perform operations S610 to S620, for example, to calculate a conditional probability of obtaining each of the at least one feature data and a prior probability of obtaining the interface data of each of the one or more classes in a case that the machine learning algorithm is a bayesian classification algorithm. And training based on the conditional probability and the prior probability to obtain an interface classification model.
Based on the training method, the disclosure also provides a training device.
According to an embodiment of the present disclosure, the training apparatus may include a first training module, for example, performing operation S410, to train an interface classification model based on an interface specification of a scene to be tested by using a machine learning algorithm, so that the interface classification model classifies N first interface data to obtain M second interface data to test the scene to be tested, where the N first interface data includes M second interface data, N and M are integers greater than or equal to 1, respectively, and N is greater than or equal to M. The machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
According to an embodiment of the disclosure, the first training module may further perform operations S510 to S530 and operations S610 to S620, for example, which are not described herein again.
According to the embodiments of the present disclosure, any plurality of modules in the testing apparatus 800 or the training apparatus may be combined and implemented in one module, or any one of the modules may be split into a plurality of modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of the other modules and implemented in one module. According to an embodiment of the present disclosure, at least one module in the testing device 800 or the training device may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or in any one of three implementations of software, hardware, and firmware, or in any suitable combination of any of them. Alternatively, at least one module of the testing device 800 or the training device may be at least partly implemented as a computer program module, which when executed may perform a corresponding function.
FIG. 9 schematically illustrates a block diagram of an electronic device suitable for implementing a testing method or a training method according to an embodiment of the disclosure.
As shown in fig. 9, an electronic apparatus 900 according to an embodiment of the present disclosure includes a processor 901 which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage portion 908 into a Random Access Memory (RAM) 903. Processor 901 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 901 may also include on-board memory for caching purposes. The processor 901 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 903, various programs and data necessary for the operation of the electronic apparatus 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. The processor 901 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 902 and/or the RAM 903. Note that the program may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 900 may also include input/output (I/O) interface 905, input/output (I/O) interface 905 also connected to bus 904, according to an embodiment of the present disclosure. The electronic device 900 may also include one or more of the following components connected to the I/O interface 905: an input section 906 including a keyboard, mouse, and the like. Including an output portion 907 such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker and the like. A storage section 908 including a hard disk and the like. And a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be embodied in the devices/apparatuses/systems described in the above embodiments. Or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 902 and/or the RAM 903 described above and/or one or more memories other than the ROM 902 and the RAM 903.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated in the flow chart. The program code is for causing a computer system to carry out the method according to the embodiments of the disclosure, when the computer program product is run on the computer system.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 901. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of a signal on a network medium, and downloaded and installed through the communication section 909 and/or installed from the removable medium 911. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program, when executed by the processor 901, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (13)

1. A method of testing, comprising:
acquiring N first interface data;
classifying the N first interface data by using an interface classification model, wherein the interface classification model is obtained by training based on interface specifications of a scene to be tested;
obtaining M second interface data based on the classification result of the interface classification model, wherein the N first interface data comprise the M second interface data, N and M are integers which are respectively larger than or equal to 1, and N is larger than or equal to M;
and testing the scene to be tested based on the M second interface data.
2. The method of claim 1, wherein the obtaining N first interface data comprises:
determining at least one target scene based on the test service of the scene to be tested;
and acquiring the N first interface data from the at least one target scene.
3. The method of claim 1, wherein prior to said obtaining N first interface data, further comprising:
training the interface classification model based on the interface specification using a machine learning algorithm;
wherein the machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
4. The method of claim 3, wherein the training the interface classification model based on the interface specification using a machine learning algorithm comprises:
obtaining a training sample set, wherein the training sample set comprises at least one third interface data;
determining at least one characteristic data of the third interface data based on the interface specification;
training the interface classification model based on the at least one feature data.
5. The method of claim 4, wherein the at least one third interface data comprises one or more classes of interface data, and in the case that the machine learning algorithm is the Bayesian classification algorithm, the training the interface classification model based on the at least one feature data comprises:
calculating a conditional probability of obtaining each of the at least one feature data and a prior probability of obtaining interface data for each of the one or more categories;
and training and obtaining the interface classification model based on the conditional probability and the prior probability.
6. The method of claim 5, wherein the classifying the N first interface data using an interface classification model comprises:
acquiring the at least one feature data of each first interface data in the N first interface data;
classifying the each first interface data based on the conditional probability and the prior probability.
7. The method of claim 4, wherein the at least one feature data comprises:
at least one of a type of interface, an interface URL value, a number of interface parameters, a type of interface parameter, or an interface return value.
8. A training method of an interface classification model comprises the following steps:
training the interface classification model based on an interface specification of a scene to be tested by utilizing a machine learning algorithm, so that the interface classification model classifies N first interface data to obtain M second interface data, and testing the scene to be tested, wherein the N first interface data comprise the M second interface data, N and M are integers which are respectively greater than or equal to 1, and N is greater than or equal to M;
wherein the machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
9. A test apparatus, comprising:
the first acquisition module is used for acquiring N first interface data;
the interface classification module is used for classifying the N pieces of first interface data by using an interface classification model, wherein the interface classification model is obtained by training based on interface specifications of a scene to be tested;
a second obtaining module, configured to obtain M second interface data based on a classification result of the interface classification model, where the N first interface data include the M second interface data, N and M are integers greater than or equal to 1, respectively, and N is greater than or equal to M;
and the scene testing module is used for testing the scene to be tested based on the M second interface data.
10. An apparatus for training an interface classification model, comprising:
the interface classification module is used for training an interface classification model based on an interface specification of a scene to be tested by utilizing a machine learning algorithm so as to enable the interface classification model to classify N pieces of first interface data to obtain M pieces of second interface data to test the scene to be tested, wherein the N pieces of first interface data comprise the M pieces of second interface data, N and M are integers which are greater than or equal to 1 respectively, and N is greater than or equal to M;
wherein the machine learning algorithm comprises at least one of a Bayesian classification algorithm, a K-nearest neighbor algorithm, a support vector machine, a logistic regression algorithm or an ensemble learning algorithm.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-8.
12. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method of any one of claims 1 to 8.
13. A computer program product comprising a computer program which, when executed by a processor, implements a method according to any one of claims 1 to 8.
CN202110905553.1A 2021-08-05 2021-08-05 Test method, training method, device, apparatus, medium, and program product Pending CN113609018A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110905553.1A CN113609018A (en) 2021-08-05 2021-08-05 Test method, training method, device, apparatus, medium, and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110905553.1A CN113609018A (en) 2021-08-05 2021-08-05 Test method, training method, device, apparatus, medium, and program product

Publications (1)

Publication Number Publication Date
CN113609018A true CN113609018A (en) 2021-11-05

Family

ID=78339856

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110905553.1A Pending CN113609018A (en) 2021-08-05 2021-08-05 Test method, training method, device, apparatus, medium, and program product

Country Status (1)

Country Link
CN (1) CN113609018A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115774679A (en) * 2023-01-31 2023-03-10 深圳依时货拉拉科技有限公司 AB experimental regression testing method and device and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115774679A (en) * 2023-01-31 2023-03-10 深圳依时货拉拉科技有限公司 AB experimental regression testing method and device and storage medium
CN115774679B (en) * 2023-01-31 2023-04-28 深圳依时货拉拉科技有限公司 AB experiment regression testing method, device and storage medium

Similar Documents

Publication Publication Date Title
CN109325213B (en) Method and device for labeling data
CN111107048A (en) Phishing website detection method and device and storage medium
CN113507419B (en) Training method of traffic distribution model, traffic distribution method and device
CN112329762A (en) Image processing method, model training method, device, computer device and medium
CN113779240A (en) Information identification method, device, computer system and readable storage medium
WO2023050143A1 (en) Recommendation model training method and apparatus
CN114579878A (en) Training method of false news discrimination model, false news discrimination method and device
US20230281696A1 (en) Method and apparatus for detecting false transaction order
CN113609018A (en) Test method, training method, device, apparatus, medium, and program product
CN113392200A (en) Recommendation method and device based on user learning behaviors
CN116155628B (en) Network security detection method, training device, electronic equipment and medium
CN113535577A (en) Application testing method and device based on knowledge graph, electronic equipment and medium
CN112214770A (en) Malicious sample identification method and device, computing equipment and medium
CN116468970A (en) Model training method, image processing method, device, equipment and medium
CN116956204A (en) Network structure determining method, data predicting method and device of multi-task model
CN115525781A (en) Multi-mode false information detection method, device and equipment
CN115292187A (en) Method and device for automatically testing code-free page, electronic equipment and medium
CN113159877B (en) Data processing method, device, system and computer readable storage medium
CN113052509A (en) Model evaluation method, model evaluation apparatus, electronic device, and storage medium
CN113391988A (en) Method and device for losing user retention, electronic equipment and storage medium
CN114692970A (en) User intention prediction model training method, user intention prediction method and device
CN114637921B (en) Item recommendation method, device and equipment based on modeling accidental uncertainty
CN114880565B (en) Information recommendation method, model training method and related device
CN114328891A (en) Training method of information recommendation model, information recommendation method and device
CN116541702A (en) Sample label generation method, model training method, device and equipment

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