CN114637672A - Automatic data testing method and device, computer equipment and storage medium - Google Patents

Automatic data testing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114637672A
CN114637672A CN202210255332.9A CN202210255332A CN114637672A CN 114637672 A CN114637672 A CN 114637672A CN 202210255332 A CN202210255332 A CN 202210255332A CN 114637672 A CN114637672 A CN 114637672A
Authority
CN
China
Prior art keywords
test
interface
data
extraction model
tested
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
CN202210255332.9A
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.)
Ping An International Smart City Technology Co Ltd
Original Assignee
Ping An International Smart City 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 Ping An International Smart City Technology Co Ltd filed Critical Ping An International Smart City Technology Co Ltd
Priority to CN202210255332.9A priority Critical patent/CN114637672A/en
Publication of CN114637672A publication Critical patent/CN114637672A/en
Pending legal-status Critical Current

Links

Images

Classifications

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

Abstract

The embodiment of the application belongs to the technical field of test management and relates to an automatic data testing method which comprises the steps of establishing a metadata generation rule of basic metadata, creating a data extraction model according to the metadata generation rule, receiving an interface test request of an interface to be tested, obtaining a corresponding data extraction model according to the interface test request, taking the data extraction model as a target data extraction model, calling the metadata generation rule of the target data extraction model to generate test data of the interface to be tested, obtaining a test case according to the test data, returning the test case to the interface to be tested, testing the interface to be tested through the test case, and outputting an interface test result. The application also provides an automatic data testing device, computer equipment and a storage medium. In addition, the present application also relates to blockchain techniques, in which data extraction models can be stored. The application can realize the separation of the test data and the test cases and improve the test efficiency.

Description

Automatic data testing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of test management technologies, and in particular, to an automated data testing method and apparatus, a computer device, and a storage medium.
Background
With the development of computer technology, more and more businesses are implemented through computer programs, such as financial services, social services, online shopping, and the like, and data interaction between various business services, such as interaction between the interior of a business system and interaction between the business system and a user, is implemented by calling various predefined interfaces. In order to ensure that various interfaces can meet the requirements for data interaction, the interfaces need to be tested after being developed.
The preparation of test data is an important ring in interface service test, and the quality and efficiency of the test data preparation directly affect the quality and efficiency of the test. Automated testing places higher demands on test data preparation, which requires test data to be prepared at once, rather than allowing batch preparation.
The test data preparation refers to the process of continuously analyzing, verifying and checking original test data to form structured data, so that reasonable and effective test data can be efficiently provided for test projects, test services and test boundaries are covered, and requirements of test integrity, consistency and the like are met. In the process of executing the automatic test case, support of test data is often needed, and the problem of case execution failure is caused by insufficient data or change of a tested program.
Disclosure of Invention
The embodiment of the application aims to provide an automatic data testing method, an automatic data testing device, computer equipment and a storage medium, so as to solve the problem that the execution of a test case fails due to insufficient test data or the change of a tested program in the related technology.
In order to solve the above technical problem, an embodiment of the present application provides an automated data testing method, which adopts the following technical solutions:
establishing a metadata generation rule of basic metadata;
creating a data extraction model according to the metadata generation rule;
receiving an interface test request of an interface to be tested, obtaining a corresponding data extraction model according to the interface test request, and taking the data extraction model as a target data extraction model;
calling a metadata generation rule of the target data extraction model to generate test data of the interface to be tested, and obtaining a test case according to the test data;
and returning the test case to the interface to be tested, testing the interface to be tested through the test case, and outputting an interface test result.
Further, the step of establishing the metadata generation rule of the basic metadata includes:
configuring data attributes of the basic metadata and corresponding data generation functions;
and importing the data attribute and the data generation function into a preset script template to generate a metadata generation rule corresponding to the basic metadata.
Further, the step of creating a data extraction model according to the metadata generation rule includes:
configuring model parameters of the data extraction model according to the basic metadata;
obtaining a corresponding metadata generation rule according to the model parameters;
generating the data extraction model based on the model parameters and the metadata generation rules.
Further, the step of generating the data extraction model based on the model parameters and the metadata generation rules comprises:
mapping the model field and the metadata generation rule to obtain a model rule mapping relation;
and generating a data extraction model based on the model rule mapping relation.
Further, the step of obtaining the corresponding data extraction model according to the interface test request includes:
extracting interface information of the interface test request, and determining an interface to be tested according to the interface information;
and determining a corresponding data extraction model based on the to-be-tested interface and the corresponding relation between the pre-configured to-be-tested interface and the data extraction model.
Further, the step of obtaining the test case according to the test data includes:
acquiring a preset interface test template corresponding to the interface to be tested;
and updating the preset interface test template according to the interface test request and the test data to obtain a test case.
Further, after the step of testing the interface to be tested by the test case and outputting an interface test result, the method further includes:
when the interface test result is detected to be abnormal, test data of the test process is obtained;
and matching abnormal data in the interface test result through a preset regular expression, marking the code segment corresponding to the matched test data as an error code, and sending an error prompt message.
In order to solve the above technical problem, an embodiment of the present application further provides an automated data testing apparatus, which adopts the following technical solution:
the establishing module is used for establishing a metadata generating rule of the basic metadata;
the model creating module is used for creating a data extraction model according to the metadata generating rule;
the acquisition module is used for receiving an interface test request of an interface to be tested, acquiring a corresponding data extraction model according to the interface test request, and taking the data extraction model as a target data extraction model;
the generating module is used for calling a metadata generating rule of the target data extraction model to generate test data of the interface to be tested and obtaining a test case according to the test data;
and the test module is used for returning the test case to the interface to be tested, testing the interface to be tested through the test case and outputting an interface test result.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which adopts the following technical solutions:
the computer device includes a memory having computer readable instructions stored therein and a processor that when executed implements the steps of the automated data testing method described above.
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solutions:
the computer readable storage medium has stored thereon computer readable instructions which, when executed by a processor, implement the steps of the automated data testing method described above.
Compared with the prior art, the embodiment of the application mainly has the following beneficial effects:
the method comprises the steps of establishing a metadata generation rule of basic metadata, creating a data extraction model according to the metadata generation rule, receiving an interface test request of an interface to be tested, obtaining a corresponding data extraction model according to the interface test request, using the data extraction model as a target data extraction model, calling the metadata generation rule of the target data extraction model to generate test data of the interface to be tested, obtaining a test case according to the test data, returning the test case to the interface to be tested, testing the interface to be tested through the test case, and outputting an interface test result; according to the method and the device, the data extraction model is created, and the test data is called through the data extraction model, so that the test data can be separated from the test case, the test data can be automatically extracted and verified, and the problems of test environment change and test data failure are solved; meanwhile, the influence of environmental data can be effectively controlled, the use of the instance is defined in a standard mode, the waiting time and the preparation time in the test process are reduced, the problem caused by problem data is reduced, the test is prevented from being carried out, the automatic test case is better served, and the test efficiency is further improved.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of an automated data testing method according to the present application;
FIG. 3 is a schematic block diagram of one embodiment of an automated data testing apparatus according to the present application;
FIG. 4 is a block diagram of one embodiment of a computer device according to the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
The present application provides an automated data testing method, which may be applied to a system architecture 100 as shown in fig. 1, where the system architecture 100 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.
A user may use terminal devices 101, 102, 103 to interact with a server 105 over a network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III, motion Picture Experts compression standard Audio Layer 3), an MP4 player (Moving Picture Experts Group Audio Layer IV, motion Picture Experts compression standard Audio Layer 4), a laptop portable computer, a desktop computer, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that, the automated data testing method provided by the embodiment of the present application is generally executed by a server/terminal device, and accordingly, the automated data testing apparatus is generally disposed in the server/terminal device.
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.
With continued reference to FIG. 2, a flow diagram of one embodiment of an automated data testing method according to the present application is shown, including the steps of:
step S201, a metadata generation rule of the basic metadata is established.
The basic metadata includes, but is not limited to, a mobile phone number, contact and legal names, contact addresses, work, mailbox, organization codes, region, bank card data, bank information, operation photos, order numbers, serial numbers, and the like.
In this embodiment, a metadata generation rule of the basic metadata is established, and is used for subsequent operations such as creating a user, a merchant, and an operation account.
Specifically, a data preparation site can be built by using the Django technology of python, basic metadata is configured in the data preparation site, and a data generation function used by the basic metadata and a name of the basic metadata are configured in the basic metadata. And generating test data by using a third-party library such as a maker according to the name of the basic metadata and the data generation function.
Step S202, a data extraction model is created according to the metadata generation rule.
In this embodiment, according to different application scenarios of the test data, data extraction models corresponding to different application scenarios, including but not limited to a personal user model, a merchant model, an operation account model, and the like, may be created according to a metadata generation rule corresponding to the test data.
In some alternative implementations, the step of creating the data extraction model according to the metadata generation rule includes:
configuring model parameters of the data extraction model according to the basic metadata;
obtaining a corresponding metadata generation rule according to the model parameters;
a data extraction model is generated based on the model parameters and the metadata generation rules.
The model parameters comprise model names, model fields and result preset values, wherein the model names can be set according to application scenes, such as a personal user model, a merchant model, an operation account model and the like; the model field can be configured according to the data attribute of the basic metadata required by the model, the model field can be consistent with the data attribute, and also can have a one-to-one mapping relation with the data attribute, for example, the model field comprises a name, a telephone number, an address and the like; the result preset value is a return value of the interface test expectation basic metadata, which can be a custom value and can also refer to the basic metadata.
In this embodiment, the basic metadata may be classified according to an application scenario, and corresponding model parameters may be configured according to the basic metadata in the classification result.
The basic metadata all have corresponding metadata generation rules, and the model fields of the model parameters are configured according to the data attributes of the basic metadata, so that the corresponding metadata generation rules can be obtained according to the model fields.
The data extraction model created in the embodiment is a set of metadata generation rules, and can be used for calling data, so that test data can be automatically extracted and verified, and the problems that the test environment is changed and the test data cannot be invalid are solved.
It is emphasized that the data extraction model may also be stored in a node of a blockchain in order to further ensure privacy and security of the data extraction model.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Step S203, receiving an interface test request of an interface to be tested, obtaining a corresponding data extraction model according to the interface test request, and taking the data extraction model as a target data extraction model.
The interface test request may be a message for requesting an interface automation test sent by the terminal, or may be sent through the interface to be tested, where the interface test request may include information of the interface to be tested, such as an interface name and an interface number, and identification information of the interface to be tested.
Specifically, interface information of the interface test request is extracted, an interface to be tested is determined according to the interface information, and a corresponding data extraction model is determined based on the interface to be tested and a preset corresponding relation between the interface to be tested and the data extraction model.
In this embodiment, a corresponding relationship between the interface to be tested and the data extraction model is pre-configured, and according to the interface to be tested and the corresponding relationship, the data extraction model corresponding to the interface to be tested can be determined, and the data extraction model is used as the target data extraction model.
For example, the data extraction model is a personal merchant model, the personal merchant model includes metadata generation rules corresponding to basic metadata such as a name, a contact address, a telephone number, an operation account number, a serial number and the like, each metadata has a calling interface corresponding to the metadata, and the corresponding relationship between the personal merchant model and the interface to be tested can be configured by establishing a mapping relationship between each metadata generation rule of the personal merchant model and the corresponding metadata calling interface of the personal merchant model.
And step S204, calling a metadata generation rule of the target data extraction model to generate test data of the interface to be tested, and obtaining a test case according to the test data.
The target data extraction model is a set of metadata generation rules, and the required test data can be obtained by calling the metadata generation rules.
In this embodiment, the step of obtaining the test case according to the test data includes:
acquiring a preset interface test template corresponding to an interface to be tested;
and updating the preset interface test template according to the interface test request and the test data to obtain a test case.
The preset interface test template is a data file which records test parameters and is set corresponding to various interfaces, and may specifically be an Excel form file, an Txt text file or an Xml (Extensible Markup Language) file, which may include but is not limited to interface test parameters including an interface test serial number, an interface name, test data, a verification result, an execution mode, variables, and the like. Different test cases can be obtained by configuring the test parameters in the interface test template.
Different types of the interfaces can correspond to different test parameters, for example, for Post and Get type interfaces, the interfaces correspond to different execution modes, corresponding test parameters can be set in a targeted manner by configuring corresponding interface test templates for different interfaces, other intermediate processing is not needed, and the test efficiency is improved.
It should be noted that the test data in the preset interface test template is a blank field, and needs to be updated according to the obtained test data.
The test case is a test file for performing a test task on the interface, and the interface can be subjected to related tests by executing the test case. After the interface test template is obtained, the test parameters in the interface test template can be updated according to the test request parameters included in the interface test request, so that the required test case is obtained. In a specific application, the test parameters comprise interface types, execution modes, test data and verification results, the test request parameters are extracted from the interface test requests, various test parameters in the interface test templates are configured one by one according to the test request parameters, and after configuration is completed, corresponding test cases are generated according to the updated test templates.
According to the embodiment, the test case is updated according to the interface test request and the corresponding test data, so that the situation that the test data is invalid and the test is hindered due to the change of the test environment can be avoided.
And S205, returning the test case to the interface to be tested, testing the interface to be tested through the test case, and outputting an interface test result.
And after the test case is obtained, returning the test case to the corresponding interface to be tested through the preset API, executing the test case to realize the automatic test of the interface to be tested, and finally obtaining an interface test result.
In specific application, the obtained test case can be executed through a TestNG test suite, an Ant script or a Jenkins tool so as to call a corresponding interface to be tested and perform automatic test, an interface execution result is obtained, and finally the result execution result is compared with a preset result preset value so as to obtain an interface test result, so that the rapid automatic test of the interface to be tested is realized.
In this embodiment, after the test case is returned, the API interface may be called to store data, so that subsequent data is ready for use.
Generally, the interface test is a function test, and whether the interface test result meets the interface function requirement can be determined according to the comparison result by comparing the interface execution result with a preset result preset value. In specific application, the success rate of interface test can be counted for executing different interface test cases for multiple times, and the problem of deviation of interface test results caused by abnormal interface execution results can be avoided.
In this embodiment, before the test case is returned to the interface to be tested, mock processing needs to be performed on the third-party interface corresponding to the interface to be tested, specifically, a mock script is set according to a mock data rule, configuration is performed according to codes and field values returned by the third-party standard interface, a mock request address is generated, the mock address is directly pointed to during automatic testing, and a correct mock is immediately returned after the request. For example, in the testing process, when jumping to a third-party payment platform or a bank system, the system directly returns success and simulates callback contents according to a third-party standard interface document, thereby avoiding factors such as service data change and environmental instability caused by interaction between other third-party services and the payment system, and further influencing the execution of automated testing.
It should be understood that Mock processing refers to a method of creating a virtual object for testing, for some objects that are not easily constructed or easily obtained during the testing process.
According to the method and the device, the data extraction model is created, and the test data is called through the data extraction model, so that the test data can be separated from the test case, the test data can be automatically extracted and verified, and the problems of environment change and test data failure are solved; meanwhile, the influence of environmental data can be effectively controlled, the use of the instance is defined in a standard mode, the waiting time and the preparation time in the test process are reduced, the problem caused by problem data is reduced, the test is prevented from being carried out, the automatic test case is better served, and the test efficiency is further improved.
In some optional implementations of this embodiment, the step of establishing the metadata generation rule of the basic metadata includes:
configuring data attributes of basic metadata and corresponding data generation functions;
and importing the data attribute and the data generation function into a preset script template to generate a metadata generation rule corresponding to the basic metadata.
The data attribute may be a name of basic metadata, and different basic metadata correspond to different data generation functions, for example, a mobile phone number is generated through fake telephone _ number (), a contact and a legal name are generated through fake name (), a contact address is generated through fake address (), a mailbox is generated through fake email (), and the like, and the data generation function may also be customized.
Corresponding test data are obtained through a data generation function, and the test data can be stored in a MySQL database.
The script template can be written by adopting a general programming language, and the data attribute of the basic metadata and the corresponding data generation function are added into the script template to generate a general metadata generation rule.
The embodiment can improve the efficiency of establishing the metadata generation rule.
In some optional implementations of this embodiment, the step of generating the data extraction model based on the model parameters and the metadata generation rule includes:
mapping the model field and the metadata generation rule to obtain a model rule mapping relation;
and generating a data extraction model based on the model rule mapping relation.
In the present embodiment, by establishing a mapping relationship between the model field and the metadata generation rule, the data extraction model is generated based on the mapping relationship.
The mapping relationship may be implemented by establishing a mapping relationship table, or may be established by a key-value pair (key-value).
Specifically, a mapping relationship table is created, and the model field and the metadata generation rule corresponding to the model field are mapped, for example, if the model field is a name, the metadata generation rule corresponding to the name and the name is configured to the mapping relationship table, if the model field is a phone number, the phone number and the metadata generation rule corresponding to the phone number are configured to the mapping relationship table, and so on, the model rule mapping relationship is obtained. The data extraction model is a set of metadata generation rules, an application scene of the data extraction model is determined, corresponding model fields are obtained according to the application scene, metadata generation rules corresponding to the model fields are obtained based on a model rule mapping relation, and then the corresponding data extraction model is generated.
In this embodiment, an API (Application Programming Interface) is set for the data extraction model, and the test data obtained through the data extraction model is returned to the Interface to be tested through the API.
According to the embodiment, the data extraction model is established based on the model parameters and the metadata generation rule, so that the establishment efficiency of the model can be improved.
In some optional implementation manners, after the step of testing the interface to be tested by the test case and outputting the test result of the interface, the method further includes:
when detecting that the interface test result is abnormal, acquiring test data of the test process;
and matching abnormal data in the interface test result through a preset regular expression, marking the code segment corresponding to the matched test data as an error code, and sending an error prompt message.
When the interface test result is detected to be abnormal, the interface error can be tracked and positioned so as to prompt developers, and the developers can rapidly process error codes.
Specifically, when detecting that a test interface is abnormal, obtaining test data of a test process, matching abnormal data in an interface test result through a preset regular expression, marking a code segment corresponding to the matched test data as an error code, for example, adding error identification information, simultaneously generating and sending an error-reporting prompt message, for example, an error-reporting prompt window or an error-reporting voice message, and calling an early warning function to notify a tester or a developer through a mail.
It should be noted that, the data program run out from the normal test case is identified and stored in the database as the preparation data for the subsequent performance test, and the abnormal data is periodically cleaned through the cron expression of the scheduling task.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware associated with computer readable instructions, which can be stored in a computer readable storage medium, and when executed, the processes of the embodiments of the methods described above can be included. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 3, as an implementation of the method shown in fig. 2, the present application provides an embodiment of an automated data testing apparatus, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 3, the automated data testing apparatus 300 according to the present embodiment includes: a building module 301, a model creation module 302, an obtaining module 303, a generating module 304, and a testing module 305. Wherein:
the establishing module 301 is configured to establish a metadata generation rule of the basic metadata;
the model creating module 302 is used for creating a data extraction model according to the metadata generation rule;
the obtaining module 303 is configured to receive an interface test request of an interface to be tested, obtain a corresponding data extraction model according to the interface test request, and use the data extraction model as a target data extraction model;
the generating module 304 is configured to invoke a metadata generating rule of the target data extraction model to generate test data of the interface to be tested, and obtain a test case according to the test data;
the test module 305 is configured to return the test case to the interface to be tested, test the interface to be tested through the test case, and output an interface test result.
It is emphasized that the data extraction model may also be stored in a node of a blockchain in order to further ensure privacy and security of the data extraction model.
According to the automatic data testing device, the data extraction model is created, and the test data is called through the data extraction model, so that the separation of the test data and the test case can be realized, the test data can be automatically extracted and verified, and the problems of environment change and test data failure are solved; meanwhile, the influence of environmental data can be effectively controlled, the use of the instance is defined in a standard mode, the waiting time and the preparation time in the test process are reduced, the problem caused by problem data is reduced, the test is prevented from being carried out, the automatic test case is better served, and the test efficiency is further improved.
In some optional implementations of this embodiment, the establishing module 301 includes a configuration sub-module and a generating sub-module, where the configuration sub-module is configured to configure the data attribute of the basic metadata and a corresponding data generating function; the generation submodule is used for leading the data attribute and the data generation function into a preset script template and generating a metadata generation rule corresponding to the basic metadata.
The embodiment can improve the efficiency of establishing the metadata generation rule.
In this embodiment, the model creating module 302 includes a parameter configuration sub-module, an obtaining sub-module, and a creating sub-module, where:
the parameter configuration submodule is used for configuring the model parameters of the data extraction model according to the basic metadata;
the obtaining submodule is used for obtaining a corresponding metadata generation rule according to the model parameters;
a creation sub-module is used to generate the data extraction model based on the model parameters and the metadata generation rules.
The data extraction model created in this embodiment is a set of metadata generation rules, and can be used for calling data, so that test data can be automatically extracted and verified, and the problem that the test data cannot be invalid even if the test environment is changed is solved.
In some optional implementation manners, the creating sub-module includes a mapping unit and a model generating unit, and the mapping unit is configured to map the model field and the metadata generation rule to obtain a model rule mapping relationship; the model generating unit is used for generating a data extraction model based on the model rule mapping relation.
According to the embodiment, the data extraction model is established based on the model parameters and the metadata generation rule, so that the establishment efficiency of the model can be improved.
In this embodiment, the obtaining module 303 is further configured to:
extracting interface information of the interface test request, and determining an interface to be tested according to the interface information;
and determining a corresponding data extraction model based on the to-be-tested interface and the corresponding relation between the pre-configured to-be-tested interface and the data extraction model.
In this embodiment, the generating module 304 includes an obtaining submodule and an updating submodule, where the obtaining submodule is used to obtain a preset interface test template corresponding to the interface to be tested; and the updating submodule is used for updating the preset interface test template according to the interface test request and the test data to obtain a test case.
According to the embodiment, the test case is updated according to the interface test request and the corresponding test data, so that the situation that the test data is invalid and the test is hindered due to the change of the test environment can be avoided.
In some alternative implementations, the automated data testing apparatus 300 further includes an exception module to:
when the interface test result is detected to be abnormal, test data of the test process is obtained;
and matching abnormal data in the interface test result through a preset regular expression, marking the code segment corresponding to the matched test data as an error code, and sending an error prompt message.
The embodiment can realize tracking and positioning of the interface error so as to prompt developers, so that the developers can quickly process the error codes.
In order to solve the technical problem, the embodiment of the application further provides computer equipment. Referring to fig. 4, fig. 4 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 4 comprises a memory 41, a processor 42, and a network interface 43, which are communicatively connected to each other via a system bus. It is noted that only computer device 4 having components 41-43 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 41 includes at least one type of readable storage medium including flash memory, hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), Random Access Memory (RAM), Static Random Access Memory (SRAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Programmable Read Only Memory (PROM), magnetic memory, magnetic disks, optical disks, etc. In some embodiments, the memory 41 may be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 4. Of course, the memory 41 may also include both internal and external storage devices of the computer device 4. In this embodiment, the memory 41 is generally used for storing an operating system installed in the computer device 4 and various types of application software, such as computer readable instructions of an automated data testing method. Further, the memory 41 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 42 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is configured to execute computer readable instructions stored in the memory 41 or process data, such as computer readable instructions for executing the automated data testing method.
The network interface 43 may comprise a wireless network interface or a wired network interface, and the network interface 43 is generally used for establishing communication connection between the computer device 4 and other electronic devices.
In this embodiment, when the processor executes the computer readable instructions stored in the memory, the steps of the automated data testing method according to the above embodiments are implemented, and by creating the data extraction model and calling the test data through the data extraction model, the test data can be separated from the test case, so that the test data can be automatically extracted and verified, and the problems of environment change and test data failure are solved; meanwhile, the influence of environmental data can be effectively controlled, the use of the instance is defined in a standard mode, the waiting time and the preparation time in the test process are reduced, the problem caused by problem data is reduced, the test is prevented from being carried out, the automatic test case is better served, and the test efficiency is further improved.
The application further provides another embodiment, which is to provide a computer-readable storage medium, where the computer-readable storage medium stores computer-readable instructions, where the computer-readable instructions are executable by at least one processor, so that the at least one processor executes the steps of the automated data testing method as described above, and by creating a data extraction model and calling test data through the data extraction model, separation of the test data from test cases can be achieved, so that the test data can be automatically extracted and verified, and the problems of environment change and test data failure are solved; meanwhile, the influence of environmental data can be effectively controlled, the use of the instance is defined in a standard mode, the waiting time and the preparation time in the test process are reduced, the problem caused by problem data is reduced, the test is prevented from being carried out, the automatic test case is better served, and the test efficiency is further improved.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application or portions thereof that contribute to the prior art may be embodied in the form of a software product, where the computer software product is stored in a storage medium (such as a ROM/RAM, a magnetic disk, and an optical disk), and includes several instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. An automated data testing method, comprising the steps of:
establishing a metadata generation rule of basic metadata;
creating a data extraction model according to the metadata generation rule;
receiving an interface test request of an interface to be tested, obtaining a corresponding data extraction model according to the interface test request, and taking the data extraction model as a target data extraction model;
calling a metadata generation rule of the target data extraction model to generate test data of the interface to be tested, and obtaining a test case according to the test data;
and returning the test case to the interface to be tested, testing the interface to be tested through the test case, and outputting an interface test result.
2. The automated data testing method of claim 1, wherein the step of establishing metadata generation rules for the base metadata comprises:
configuring data attributes of the basic metadata and corresponding data generation functions;
and importing the data attribute and the data generation function into a preset script template to generate a metadata generation rule corresponding to the basic metadata.
3. The automated data testing method of claim 1, wherein the step of creating a data extraction model according to the metadata generation rules comprises:
configuring model parameters of the data extraction model according to the basic metadata;
obtaining a corresponding metadata generation rule according to the model parameters;
generating the data extraction model based on the model parameters and the metadata generation rules.
4. The automated data testing method of claim 3, wherein the step of generating the data extraction model based on the model parameters and the metadata generation rules comprises:
mapping the model field and the metadata generation rule to obtain a model rule mapping relation;
and generating a data extraction model based on the model rule mapping relation.
5. The automated data testing method of claim 1, wherein the step of obtaining a corresponding data extraction model from the interface test request comprises:
extracting interface information of the interface test request, and determining an interface to be tested according to the interface information;
and determining a corresponding data extraction model based on the to-be-tested interface and the corresponding relation between the pre-configured to-be-tested interface and the data extraction model.
6. The automated data testing method of claim 1, wherein the step of obtaining test cases from the test data comprises:
acquiring a preset interface test template corresponding to the interface to be tested;
and updating the preset interface test template according to the interface test request and the test data to obtain a test case.
7. The automated data testing method of claim 1, wherein after the step of testing the interface to be tested through the test case and outputting the test result of the interface, the method further comprises:
when the interface test result is detected to be abnormal, test data of the test process is obtained;
and matching abnormal data in the interface test result through a preset regular expression, marking the code segment corresponding to the matched test data as an error code, and sending an error prompt message.
8. An automated data testing apparatus, comprising:
the establishing module is used for establishing a metadata generating rule of the basic metadata;
the model creating module is used for creating a data extraction model according to the metadata generating rule;
the acquisition module is used for receiving an interface test request of an interface to be tested, acquiring a corresponding data extraction model according to the interface test request, and taking the data extraction model as a target data extraction model;
the generating module is used for calling a metadata generating rule of the target data extraction model to generate test data of the interface to be tested and obtaining a test case according to the test data;
and the test module is used for returning the test case to the interface to be tested, testing the interface to be tested through the test case and outputting an interface test result.
9. A computer device comprising a memory having computer readable instructions stored therein and a processor that when executed implements the steps of an automated data testing method according to any one of claims 1 to 7.
10. A computer readable storage medium having computer readable instructions stored thereon which, when executed by a processor, implement the steps of the automated data testing method of any of claims 1 to 7.
CN202210255332.9A 2022-03-15 2022-03-15 Automatic data testing method and device, computer equipment and storage medium Pending CN114637672A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210255332.9A CN114637672A (en) 2022-03-15 2022-03-15 Automatic data testing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210255332.9A CN114637672A (en) 2022-03-15 2022-03-15 Automatic data testing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114637672A true CN114637672A (en) 2022-06-17

Family

ID=81947064

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210255332.9A Pending CN114637672A (en) 2022-03-15 2022-03-15 Automatic data testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114637672A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627851A (en) * 2023-07-24 2023-08-22 恒生电子股份有限公司 Interface testing method and device
CN116627851B (en) * 2023-07-24 2023-10-20 恒生电子股份有限公司 Interface testing method and device

Similar Documents

Publication Publication Date Title
CN110764798A (en) Microcode upgrading method, device, computer equipment and storage medium
CN113448862B (en) Software version testing method and device and computer equipment
CN112631911A (en) Automatic testing method and device, computer equipment and storage medium
CN112631924A (en) Automatic testing method and device, computer equipment and storage medium
CN112181835A (en) Automatic testing method and device, computer equipment and storage medium
CN112328486A (en) Interface automation test method and device, computer equipment and storage medium
CN112860662B (en) Automatic production data blood relationship establishment method, device, computer equipment and storage medium
CN113869789A (en) Risk monitoring method and device, computer equipment and storage medium
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
CN116956326A (en) Authority data processing method and device, computer equipment and storage medium
CN115578170A (en) Financial batch certificate making method, device, equipment and storage medium
CN115328764A (en) Test code optimization method based on automatic test and related equipment thereof
CN114968822A (en) Interface testing method and device, computer equipment and storage medium
CN113806372B (en) New data information construction method, device, computer equipment and storage medium
CN115577867B (en) Method and system for creating spot check task, computer equipment and storage medium
CN113298636B (en) Risk control method, device and system based on simulation resource application
CN114218191A (en) System function migration method and device, computer equipment and storage medium
CN117827661A (en) Code grammar checking method, system, computer device and storage medium
CN115526731A (en) Task batch processing method and device, computer equipment and storage medium
CN117421233A (en) Annotation-based code generation method, annotation-based code generation device, computer equipment and storage medium
CN116737437A (en) Data analysis method, device, computer equipment and storage medium
CN116955201A (en) Data development test method, device, equipment and medium
CN117667668A (en) Application analysis method, device, equipment and storage medium based on application upgrading
CN115080045A (en) Link generation method and device, computer equipment and storage medium
CN117422523A (en) Product online method and device, computer equipment and storage medium

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