Automated testing method, device, computer equipment and storage medium
By using neural network models to process the test result image data in automated testing, extracting and comparing the test object information, the problem of low accuracy of test results in traditional automated testing methods is solved, and higher accuracy of test results is achieved.
Patent Information
- Application Number
- CN202210390423.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-14
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2042-04-14
AI Technical Summary
When comparing the test results pictures, traditional automated testing methods are susceptible to irrelevant items such as light, background dynamics, instrument screen time, etc., resulting in low accuracy of the test results.
The neural network model is used to process the result image data of the test device after executing the test case, extract the test object information, and compare it with the target object information of the test case to improve the accuracy of the test results.
By using the pre-trained test model, the state changes of the test objects can be more accurately identified, the impact of external interference can be reduced, and the accuracy of the determination of test results can be improved.
Smart Images

Figure CN114863240B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automatic testing, and in particular to an automatic testing method, device, computer equipment and storage medium. Background Art
[0002] Automated testing refers to running a system or application under preset conditions and evaluating the results. In traditional automated testing, after taking screenshots of the test process, the test result image is compared with the expected image using the Hamming distance calculation method to determine the test result.
[0003] However, this method has extremely high requirements on images. When the images captured during the test process are affected by irrelevant factors such as light, background animation, instrument screen time, etc., it will interfere with the comparison results, resulting in low accuracy of the determined test results. Summary of the invention
[0004] In view of this, an object of the present invention is to provide an automated testing method, apparatus, computer device and storage medium, which can improve the problem of low accuracy of test results determined by current testing methods.
[0005] In order to achieve the above objectives, the technical solutions adopted by the embodiments of the present invention are as follows.
[0006] In a first aspect, an embodiment of the present invention provides an automated testing method, which adopts the following technical solution.
[0007] An automated testing method, the method comprising:
[0008] Obtaining result image data of the test device after executing any test case, wherein the result image data is image data of the screen of the test device, wherein the program to be tested is installed in the test device;
[0009] Determine the test object information of the result image data by using a preset test model, wherein the test object information includes an identification of the test object whose state changes after the test device executes the test case;
[0010] The test object information is compared with the target object information of the test case to obtain a test result, wherein the target object information includes an identifier of a target object whose state changes after the test device executes the test case.
[0011] Furthermore, the method further comprises the step of training to obtain the test model, the step comprising:
[0012] Obtaining a sample image group corresponding to each test case, wherein each sample image in the sample image group is a result image after a test device installed with a standard program executes the test case and executes any interference command;
[0013] giving each sample image in each sample image group the same label, wherein the label matches the test case corresponding to the sample image group;
[0014] The sample images in each of the sample image groups are shuffled and divided to obtain a training set, a test set and a validation set;
[0015] The neural network model is trained according to the training set, the test set and the validation set to obtain the test model.
[0016] Furthermore, the step of training the neural network model according to the training set, the test set and the validation set to obtain the test model includes:
[0017] Inputting the training set and the test set into a neural network model, configuring model parameters, and iteratively training the neural network model;
[0018] At the end of each iteration, determine whether the current neural network model has reached the termination condition. If so, the training ends and a candidate model is obtained. If not, continue to iterate the neural network model.
[0019] The candidate model is verified using the verification set. If the verification passes, the candidate model is used as a test model, otherwise iterative training continues.
[0020] Furthermore, the test model includes an input layer, a convolution layer, an excitation layer, a pooling layer, a fully connected layer and a Softmax layer connected in sequence;
[0021] The step of determining the test object information of the result image data by using a preset test model includes:
[0022] Using the result graph as input of the test model;
[0023] Extracting local features of the result image data through the convolution layer;
[0024] The local features are nonlinearly mapped through the excitation layer to obtain mapping features;
[0025] Extracting global features of the result image data through the pooling layer;
[0026] By combining the mapping features and the global features through the fully connected layer, a plurality of candidate objects are obtained;
[0027] Obtaining the weight of each candidate object through the Softmax layer;
[0028] The candidate object with the largest weight among the multiple candidate objects is used as a test object, and the test object information is obtained.
[0029] Furthermore, the method further comprises:
[0030] Record the test results of each test case and generate a test report after the test is completed.
[0031] Furthermore, the neural network model includes any one of an Alexnet model, a VGG model and a Resnet model.
[0032] Furthermore, the step of comparing the test object information with the target object information of the test case to obtain the test result includes:
[0033] Determine whether the test object information is consistent with the target object information of the test case. If so, the test result is passed; otherwise, the test result is an error.
[0034] In a second aspect, an embodiment of the present invention provides an automated testing device that adopts the following technical solution.
[0035] An automated testing device comprises an acquisition module, a prediction module and a processing module;
[0036] The acquisition module is used to acquire result image data after the test device executes any test case, wherein the result image data is image data of the screen of the test device, and the program to be tested is installed in the test device;
[0037] The prediction module is used to determine the test object state of the result image data by using a preset test model, wherein the test object information includes an identification of the test object whose state changes after the test device executes the test case;
[0038] The processing module is used to compare the test object information with the target object information of the test case to obtain a test result, wherein the target object information includes an identifier of a target object whose state is expected to change after the test device executes the test case.
[0039] In a third aspect, an embodiment of the present invention provides a computer device, which adopts the following technical solution.
[0040] A computer device comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the automated testing method as described in the first aspect.
[0041] In a fourth aspect, an embodiment of the present invention provides a storage medium, which adopts the following technical solution.
[0042] A storage medium stores a computer program, which, when executed by a processor, implements the automated testing method as described in the first aspect.
[0043] The automated testing method, apparatus, computer equipment, and storage medium provided by the embodiments of the present invention utilize a test model to determine test object information based on result image data after the test case is executed, and then obtain test results based on a comparison result between the test object information and the target object information of the test case. By utilizing the test model to determine the test object information, the actual test object can be determined more accurately, and then the test results can be obtained based on the test object information, thereby improving the accuracy of the test results.
[0044] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0046] Figure 1 A block diagram of an automated testing system provided by an embodiment of the present invention is shown.
[0047] Figure 2 One of the flow charts of the automated testing method provided by an embodiment of the present invention is shown.
[0048] Figure 3 The second flowchart of the automated testing method provided by the embodiment of the present invention is shown.
[0049] Figure 4 The third flowchart of the automated testing method provided by the embodiment of the present invention is shown.
[0050] Figure 5 Shows Figure 4 Schematic diagram of the process of some sub-steps of step S207.
[0051] Figure 6 Shows Figure 2 or Figure 3 Schematic diagram of the process of some sub-steps of step S103.
[0052] Figure 7 A block diagram of an automated testing device provided by an embodiment of the present invention is shown.
[0053] Figure 8 A block diagram of a computer device provided by an embodiment of the present invention is shown.
[0054] Icons: 100 - automated test system; 110 - test equipment; 120 - computer equipment; 130 - automated test device; 140 - acquisition module; 150 - prediction module; 160 - processing module. DETAILED DESCRIPTION
[0055] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0056] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.
[0057] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0058] In traditional automated testing, after taking a screenshot of the test process, the test result image is compared with the expected image by calculating the Hamming distance (the Hamming distance between two areas refers to the number of different binary bit positions corresponding to the two areas) to determine the test result.
[0059] However, this method has extremely high requirements for images. When the images captured during the test are affected by irrelevant factors such as light, background animation, and instrument screen time, the number of differences between the images captured during the test and the expected images will increase, causing the comparison results between the two to be disturbed, thereby reducing the accuracy of the test results, and further increasing the number of tests and reducing the efficiency of automated testing.
[0060] Based on the above considerations, an embodiment of the present invention provides an automated testing solution, which can improve the problem of low accuracy of the test results currently determined.
[0061] The automated testing method provided by the embodiment of the present invention can be applied in the environment shown in the figure, where the automated testing system 100 includes a testing device 110 and a computer device 120. The testing device 110 is installed with a program to be tested, and the testing device 110 and the computer device 120 can be connected to each other by wired or wireless communication. The computer device 120 obtains test object information based on the screenshot of the test process of the testing device 110 and the test model, and then obtains the test result based on the test object information.
[0062] In one scenario, the test device 110 may be a vehicle and an in-vehicle terminal on the vehicle, and the program to be tested may be an in-vehicle entertainment program, wherein the vehicle, the in-vehicle terminal and the in-vehicle entertainment program may also be referred to as a vehicle system.
[0063] The computer device 120 may be implemented by, but is not limited to, various personal computers, laptop computers, tablet computers, or an independent server or a server cluster consisting of multiple servers.
[0064] In one embodiment, Figure 2 As shown, an automated testing method is provided. This embodiment mainly applies the method to Figure 1 The computer device 120 is shown for illustration purposes only.
[0065] S101, obtaining result image data of the test device after executing any test case.
[0066] The result image data is image data of the screen of the test device 110 , and the program to be tested is installed in the test device 110 .
[0067] After executing a test case, the test device 110 may trigger a screenshot command, respond to the screenshot command, take a screenshot of the screen of the test device 110 to obtain result image data, and send the result image data to the computer device 120 .
[0068] Alternatively, after the test device 110 executes a test case, the computer device 120 sends a screenshot command to the test device 110 , and the test device 110 takes a screenshot of the screen in response to the screenshot command and sends the resulting image data to the computer device 120 .
[0069] S103, using a preset test model, determining the test object information of the result image data.
[0070] The test object information includes an identifier of a test object whose state changes after the test device 110 executes the test case.
[0071] The test model determines the test object information based on the result image data. It should be understood that the test model is a pre-trained machine learning model used to predict the test object information based on the result image data.
[0072] It should be understood that the test device 110 installed with the program to be tested includes multiple test objects, which can be functional controls (eg, air conditioning start controls and UI items) or physical objects (eg, high beam lights).
[0073] S105, comparing the test object information with the target object information of the test case to obtain a test result.
[0074] The target object information includes an identifier of a target object whose state is expected to change after the test device 110 executes the test case.
[0075] The automated testing method provided in this embodiment first uses the test model to determine the test object that changes in response to the test case after the test device 110 executes the test case based on the result image data, and compares the test object information with the target object information expected by the test case to obtain the test result. Therefore, when determining the mapping object information, it will not be affected by irrelevant factors such as light, background animation, instrument screen time, etc., thereby improving the accuracy of the test result determination.
[0076] It should be noted that there may be multiple test models, each of which corresponds to a test module. When testing, the corresponding test model may be selected according to the currently tested model to predict the test object of the test case.
[0077] The automated testing framework of the automated testing method provided in the embodiment of the present invention can be flexibly selected, for example, it can be Carina or Testproject.io. In this embodiment, in order to facilitate the generation of test reports, it is implemented on the python-pytest-allure framework.
[0078] In order to facilitate the determination of the test results, refer to Figure 3 The automated testing method provided by the embodiment of the present invention may further include step S107, which is performed after step S105.
[0079] S107, record the test results of each test case, and generate a test report after the test is completed.
[0080] The test report may be an allure test report obtained using allure of the python-pytest-allure framework.
[0081] When the test process is performed in the python-pytest-allure framework, the test device 110 obtains a test result each time a test case is executed, and each test result is stored in the allure test report. For example, assuming that when the 13th test case is executed, the allure test report has stored the test results of the first 12 test cases.
[0082] You can view the test results of each test case by clicking the class method name on the allure test report (one class method name represents one test case). The class method name in the allure test report is named after the "case name" of each test case, and since the "case name" of each test case is unique, the test case and the test result can correspond one to one.
[0083] Through the above steps S101 to S107, the test process, test result determination and test report generation are all automatically completed, thereby saving a lot of manpower.
[0084] In order to improve the prediction accuracy of the test model, a method for training the test model is provided in one embodiment. Figure 4 , which is a flow chart of another part of the steps of an embodiment of the present invention, the training is implemented through the following steps to obtain a test model.
[0085] S201, obtaining a sample image group corresponding to each test case.
[0086] Each sample image in the sample image group is a result image after the test device 110 installed with the standard program executes the test case and executes any interference command.
[0087] It should be noted that the external environment of the sample images in the sample image group may also be different, for example, there may be light at different angles or light of different brightness. For example, there is a test case for whether the left turn signal function is normal. First, the test case of the left turn signal is sent to the test device 110. After the screen (instrument) of the test device 110 displays the left turn signal, various interference commands are sent to increase interference factors, and a screenshot is taken for each case to obtain the sample image group corresponding to the test case of the left turn signal. The sample images in the sample image group include the left turn signal and various other different scenes.
[0088] The interference command may be, but is not limited to, any one or several of various interference commands such as an animation start command, a background switching command, and a time display command.
[0089] The sample images of the sample image group can be converted into numpy data format for storage through python opencv.
[0090] S203, giving the same label to each sample image in each sample image group.
[0091] Among them, the labels are matched with the test cases corresponding to the sample image groups.
[0092] For example, if the test case tests the high beam, the labels of the sample images in the sample image group corresponding to the test case are all 1, and 1 can indicate that the high beam is on. When the test case tests the low beam, the labels of the sample images in the sample image group corresponding to the test case are all 0, and 0 indicates low beam.
[0093] It should be understood that a tag characterizes a test object of a test case.
[0094] S205, shuffling the sample images in each sample image group and dividing them into a training set, a test set and a validation set.
[0095] Randomly shuffling sample images can improve the generalization ability of the subsequent neural network model, and the labels of the shuffled sample images remain unchanged. For example, there are 3 sample image data: A (label = a), B (label = b), C (label = c), and after the final split: dataset {B, C, A}, label {b, c, a}.
[0096] The dataset and label can be divided into training data, testing data, and verification data in a certain ratio (for example, 6:3:1). The training set can have the highest weight, and the data in the training set are all used to train the model. The data in the test set is used to adjust the parameters of the classifier of the learned model, for example, to select the number of hidden units in the neural network. In addition, the test set is also used to determine the network structure or control the parameters of the model complexity. The verification set is used to verify the accurate recognition rate of the model.
[0097] S207, training the neural network model according to the training set, the test set and the validation set to obtain a test model.
[0098] The neural network model can be flexibly selected, for example, it can be a Resnext model, or it can be an Alexnet model or a VGG model, etc. In this embodiment, the Resnext model is selected, and the Resnext model can design the network structure by adding a network layer, thereby improving the accuracy of model prediction.
[0099] In the above test model training process, using sample images under different interference factors as training sets can improve the influence of other changing factors outside the test point on the test point results, thereby improving the efficiency of automated testing.
[0100] It should be understood that the above-mentioned model training method is only an example of model training, and is not the only limitation. In other embodiments, the sample images in each sample image group may be shuffled and divided into a training set and a test set, and the neural network model may be trained based on the training set and the test set. The sample images in each sample image group may also be shuffled and divided into a training set and a validation set, and the neural network model may be trained based on the training set and the validation set.
[0101] The above step S207 is described below in detail through a specific implementation method. Figure 5 In one implementation, the above step S207 may include the following sub-steps.
[0102] S207-1, input the training set and the test set into the neural network model, configure the model parameters, and iteratively train the neural network model.
[0103] Model parameters include but are not limited to learning rate and step size.
[0104] S207-2, at the end of each iteration, determine whether the current neural network model has reached the termination condition. If not, execute step S207-3, and if so, execute step S207-4.
[0105] The termination condition includes but is not limited to any one or more of the accuracy rate and the number of iterations. For example, when the termination condition is a set accuracy rate and an iteration number threshold, in each iteration, the neural network model is trained with the training set, and the neural network model is tested with the test set to obtain the prediction accuracy, and it is determined whether the prediction accuracy reaches the set accuracy. If so, the termination condition is met. If not, it is determined whether the current number of iterations reaches the iteration number threshold. If the current number of iterations reaches the iteration number threshold, the termination condition is also met.
[0106] S207-3, continue to iteratively train the neural network model.
[0107] The neural network model may be, but is not limited to, any one of an Alexnet model, a VGG model, and a Resnet model.
[0108] S207-4, the training is completed and the candidate model is obtained.
[0109] It should be understood that when the current neural network model reaches the termination condition, the current neural network model is the candidate model.
[0110] For example, when the termination condition is a set accuracy, if the accuracy of the neural network model after a certain iteration, the parameters of the current neural network model are retained and the current neural network model is used as a candidate model. When the termination condition is an iteration number threshold, if the accuracy of the neural network model does not reach the set accuracy, it is determined whether the current iteration number reaches the iteration number threshold. If so, the current neural network model is the candidate model.
[0111] S07-5, use the verification set to verify the candidate model and determine whether the verification is passed. If yes, execute step S207-6, if not, return to step S207-3.
[0112] Input the sample images in the validation set into the candidate model, obtain the prediction results of the sample images output by the candidate model, compare the prediction results output by the candidate model with the labels, and calculate the accuracy of the prediction. If the accuracy exceeds the preset accuracy threshold, the verification is passed, otherwise the verification fails.
[0113] S207-6, using the candidate model as a test model.
[0114] Through the above steps S207 - 1 to S207 - 6 , a test model with higher prediction accuracy can be obtained, which helps to improve the accuracy of test result determination.
[0115] It should be understood that the above S107-1 to S107-6 are only examples of a training process, and are not the only limitation. In other implementations, the training set and the validation set may be used for training to obtain a candidate model, and the candidate model may be validated with the test set to obtain a test model.
[0116] Further, in one embodiment, the test model may include an input layer, a convolution layer, an excitation layer, a pooling layer, a fully connected layer, and a Softmax layer connected sequentially.
[0117] The number of each layer and the number of blocks can be set according to actual needs.
[0118] Based on the above, step S103 is introduced. Figure 6 , which is a flowchart of some sub-steps of the above step S103.
[0119] S301, using the result graph as input of the test model.
[0120] The input layer is the input of the test model (trained neural network model). In the convolutional neural network that processes images, the input layer generally represents the pixel matrix of an image. Therefore, a three-dimensional matrix can represent an image. The length and width of the three-dimensional matrix represent the size of the image, and the depth of the three-dimensional matrix represents the color channel of the image. For example, the depth of a black and white image is 1, while in RGB color mode, the depth of the image is 3.
[0121] Starting from the input layer, the convolutional neural network transforms the three-dimensional matrix of the previous layer into the three-dimensional matrix of the next layer through different neural network structures until the final fully connected layer.
[0122] S302, extracting local features of the result image data through a convolutional layer.
[0123] The convolution layer is the most important part of the convolutional neural network. The input of each node in the convolution layer is just a small piece of the previous layer of the neural network. The common size of this small piece is 3×3 or 5×5 (usually an odd number). The convolution layer attempts to analyze each small piece in the neural network more deeply to obtain more abstract features. Generally speaking, the node matrix processed by the convolution layer will become deeper, and the depth of the node matrix after the convolution layer will increase.
[0124] S303, performing nonlinear mapping on the local features through an excitation layer to obtain mapping features.
[0125] It should be noted that the excitation layer is actually an excitation function, which performs nonlinear mapping on the output of the convolution layer. The excitation function has the advantages of fast convergence and simple gradient calculation. The excitation function (Activity RULE) makes the output of some neurons 0, thereby forming the sparsity of the network and reducing the interdependence of parameters, thereby solving the problem of overfitting. In this embodiment, the excitation function is not specifically limited, and can be, but not limited to, a SIGMOID function and a TANH function.
[0126] S304, extracting global features of the result image data through a pooling layer.
[0127] The pooling layer can reduce the size of the matrix. The pooling operation can be considered as converting a high-resolution image into a low-resolution image. Through the pooling layer, the number of nodes in the final fully connected layer can be further reduced, thereby achieving the purpose of reducing the parameters in the entire neural network.
[0128] S305, obtaining multiple candidate objects by comprehensively mapping features and global features through a fully connected layer.
[0129] After multiple rounds of convolutional and pooling layers, the convolutional neural network will generally have 1 to 2 fully connected layers at the end to give the final classification result. After several rounds of convolutional and pooling layers, it can be considered that the information in the image has been abstracted into features with higher information content, that is, the convolutional and pooling layers can be regarded as the process of automatic image feature extraction. After the feature extraction is completed, the fully connected layer is used to complete the classification task.
[0130] S306, obtaining the weight of each candidate object through the Softmax layer.
[0131] The Softmax layer is mainly used for classification problems. Through the Softmax layer, the probability distribution of the current sample image belonging to different labels (test objects) can be obtained.
[0132] S307: taking the candidate object with the largest weight among the multiple candidate objects as a test object, and obtaining the test object information.
[0133] Through the above steps S301 to S307 , the test object information can be determined using the test model.
[0134] The test object information may include the identification of the test object and may also include the state change that occurs. The target object information includes the identification of the expected target object and may also include the state change that is expected to occur.
[0135] For step S107, the test object information is compared with the target object information of the test case, and the method of obtaining the test result can be flexibly selected. For example, the test object information and the target object information can be compared directly, or by using a preset rule or a comparison model.
[0136] In a real-time manner, S107 may be implemented by the following steps: determining whether the test object information is consistent with the target object information of the test case, if so, the test result is passed, otherwise, the test result is an error.
[0137] When the test object information only includes the identification of the test object, if the identification of the test object is consistent with the identification of the target object, the test result is passed, otherwise the test result is an error. When the test object information also includes the state change that occurs, if the identification of the test object is consistent with the identification of the target object, and the state change that occurs is consistent with the expected state change, the test result is passed, otherwise the test result is an error.
[0138] The automated testing method provided by an embodiment of the present invention first utilizes a test model to predict the actual test object of the test case based on the result image data after the test case is executed, and obtains the test object information, and then compares the test object information with the target object information of the test case to obtain the test result.
[0139] In the existing test methods, the result image data of the test case is directly compared with the target object image to obtain the test result. This method has many uncertainties. For example, when subject to external interference, the accuracy of the test result is greatly reduced. Compared with the existing test methods, the automated test method provided by the embodiment of the present invention first determines the test object that the test case actually acts on, and then obtains the test result based on the test object information, which can provide the prediction accuracy of the test object, thereby improving the accuracy of the test result determination.
[0140] Based on the same inventive concept as the above-mentioned automated testing method, in one embodiment, referring to Figure 7 The present invention also provides an automated testing device 130 , including an acquisition module 140 , a prediction module 150 and a processing module 160 .
[0141] The acquisition module 140 is used to acquire result image data after the test device 110 executes any test case.
[0142] The result image data is image data of the screen of the test device 110 , in which the program to be tested is installed.
[0143] The prediction module 150 is used to determine the test object state of the result image data using a preset test model.
[0144] The test object information includes an identifier of a test object whose state changes after the test device 110 executes a test case.
[0145] The processing module 160 is used to compare the state of the test object with the state of the target object of the test case to obtain a test result.
[0146] The target object state includes an identifier of a target object whose state is expected to change after the test device 110 executes the test case.
[0147] The above-mentioned automated testing device 130 first determines the test object that the test case actually acts on, and then obtains the test result according to the test object information, which can provide the prediction accuracy of the test object and thus improve the accuracy of the test result determination.
[0148] For the specific definition of the automated testing device 130, please refer to the definition of the automated testing method above, which will not be repeated here. Each module in the above-mentioned automated testing device 130 can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device 120 in the form of hardware, or can be stored in the memory in the computer device 120 in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0149] In one embodiment, a computer device 120 is provided. The computer device 120 may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device 120 includes a processor, a memory and a network interface connected via a system bus. Among them, the processor of the computer device 120 is used to provide computing and control capabilities. The memory of the computer device 120 includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device 120 is used to store test results and test reports. The network interface of the computer device 120 is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an automated testing method is implemented.
[0150] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device 120 to which the solution of the present invention is applied. The specific computer device 120 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0151] In one embodiment, the automated testing device 130 provided by the present invention can be implemented in the form of a computer program. Figure 8 The computer device 120 shown in FIG. 1 is executed on the computer device 120. The memory of the computer device 120 may store various program modules constituting the automated testing device 130, for example, Figure 7 The acquisition module 140, prediction module 150 and processing module 160 are shown. The computer program composed of various program modules enables the processor to execute the steps of the automated testing method of various embodiments of the present invention described in this specification.
[0152] For example, Figure 8 The computer device 120 shown can be Figure 7 The acquisition module 140 in the automated testing apparatus 130 shown in the figure performs step S101. The computer device 120 may perform step S103 through the prediction module 150. The computer device 120 may perform step S105 through the processing module 160.
[0153] In one embodiment, a computer device 120 is provided, including a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program: obtaining result image data of the test device 110 after executing any test case, the result image data being image data of the screen of the test device 110, and the test device 110 having a program to be tested installed therein; determining test object information of the result image data using a preset test model, wherein the test object information includes an identification of a test object whose state changes after the test device 110 executes the test case; and comparing the test object information with target object information of the test case to obtain a test result, wherein the target object information includes an identification of a target object whose state is expected to change after the test device 110 executes the test case.
[0154] In one embodiment, when the processor executes the computer program, the following steps are also implemented: obtaining a sample image group corresponding to each test case, each sample image in the sample image group is a result image after the test device 110 installed with a standard program executes the test case and executes any interference command; giving the same label to each sample image in each sample image group, and the label matches the test case corresponding to the sample image group; shuffling the sample images in each sample image group and dividing them to obtain a training set, a test set and a validation set; training a neural network model based on the training set, the test set and the validation set to obtain a test model.
[0155] In one embodiment, a storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: obtaining result image data of the test device 110 after executing any test case, the result image data being image data of the screen of the test device 110, and the test device 110 having a program to be tested installed therein; using a preset test model, determining test object information of the result image data, wherein the test object information includes an identification of a test object whose state changes after the test device 110 executes the test case; comparing the test object information with the target object information of the test case to obtain a test result, wherein the target object information includes an identification of a target object whose state is expected to change after the test device 110 executes the test case.
[0156] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining a sample image group corresponding to each test case, each sample image in the sample image group is a result image after the test device 110 installed with a standard program executes the test case and executes any interference command; giving the same label to each sample image in each sample image group, and the label matches the test case corresponding to the sample image group; shuffling the sample images in each sample image group and dividing them to obtain a training set, a test set and a validation set; training a neural network model based on the training set, the test set and the validation set to obtain a test model.
[0157] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0158] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0159] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device 120 (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0160] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An automated testing method, characterized in that: The method comprises: Obtaining result image data of the test device after executing any test case, wherein the result image data is image data of the screen of the test device, wherein the program to be tested is installed in the test device; Determine the test object information of the result image data by using a preset test model, wherein the test object information includes an identification of the test object whose state changes after the test device executes the test case; Comparing the test object information with the target object information of the test case to obtain a test result, wherein the target object information includes an identifier of a target object whose state is expected to change after the test device executes the test case; The method further comprises the step of training to obtain the test model, the step comprising: Obtaining a sample image group corresponding to each test case, wherein each sample image in the sample image group is a result image after a test device installed with a standard program executes the test case and executes any interference command; giving each sample image in each sample image group the same label, wherein the label matches the test case corresponding to the sample image group; The sample images in each of the sample image groups are shuffled and divided to obtain a training set, a test set and a validation set; The neural network model is trained according to the training set, the test set and the validation set to obtain the test model.
2. The automated testing method according to claim 1, characterized in that: The step of training the neural network model according to the training set, the test set and the validation set to obtain the test model comprises: Inputting the training set and the test set into a neural network model, configuring model parameters, and iteratively training the neural network model; At the end of each iteration, it is determined whether the current neural network model has reached the termination condition. If so, the training ends and a candidate model is obtained. If not, the neural network model continues to be iteratively trained. The candidate model is verified using the verification set. If the verification passes, the candidate model is used as a test model, otherwise iterative training continues.
3. The automated testing method according to claim 1 or 2, characterized in that: The test model includes a sequentially connected input layer, a convolution layer, an excitation layer, a pooling layer, a fully connected layer and a Softmax layer; The step of determining the test object information of the result image data by using a preset test model includes: Using the result image data as input of the test model; Extracting local features of the result image data through the convolution layer; The local features are nonlinearly mapped through the excitation layer to obtain mapping features; Extracting global features of the result image data through the pooling layer; By combining the mapping features and the global features through the fully connected layer, a plurality of candidate objects are obtained; Obtaining the weight of each candidate object through the Softmax layer; The candidate object with the largest weight among the multiple candidate objects is used as a test object, and the test object information is obtained.
4. The automated testing method according to claim 1 or 2, characterized in that: The method further comprises: Record the test results of each test case and generate a test report after the test is completed.
5. The automated testing method according to claim 2, characterized in that: The neural network model includes any one of an Alexnet model, a VGG model and a Resnet model.
6. The automated testing method according to claim 1 or 2, characterized in that: The step of comparing the test object information with the target object information of the test case to obtain the test result includes: It is determined whether the test object information is consistent with the target object information of the test case. If so, the test result is passed; otherwise, the test result is an error.
7. An automated testing device, characterized in that: It includes an acquisition module, a prediction module and a processing module; The acquisition module is used to acquire result image data after the test device executes any test case, wherein the result image data is image data of the screen of the test device, and the program to be tested is installed in the test device; The prediction module is used to determine the test object information of the result image data by using a preset test model, wherein the test object information includes an identification of the test object whose state changes after the test device executes the test case; The processing module is used to compare the test object information with the target object information of the test case to obtain a test result, wherein the target object information includes an identifier of a target object whose state is expected to change after the test device executes the test case; It also includes a module for training the test model, which is used to: Obtaining a sample image group corresponding to each test case, wherein each sample image in the sample image group is a result image after a test device installed with a standard program executes the test case and executes any interference command; giving each sample image in each sample image group the same label, wherein the label matches the test case corresponding to the sample image group; The sample images in each of the sample image groups are shuffled and divided to obtain a training set, a test set and a validation set; The neural network model is trained according to the training set, the test set and the validation set to obtain the test model.
8. A computer device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the automated testing method according to any one of claims 1 to 6.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the automated testing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Software automation test method and system
CN109086201A
Automatic test method and device, computer equipment and storage medium
CN111061526A