Test case execution method and device, electronic equipment and storage medium

By receiving the test environment identifier information in the test request, obtaining the database information, and updating the database table object model, the problem of test case failure caused by inconsistent environments in automated testing is solved, thereby improving the success rate of test case execution and the stability of automated testing.

CN116126675BActive Publication Date: 2026-03-20MASHANG CONSUMER FINANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-02
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

In automated testing, test cases often fail to run in the automated environment after being written and debugged successfully in the local environment. This is mainly due to the inconsistency between the database information of the local test environment and the automated test environment, resulting in a high failure rate.

Method used

By receiving the test environment identifier information in the test request, the system obtains the test environment database information corresponding to the target test case and updates the database table object model based on this information to ensure that the model matches the test environment, thereby automatically updating before executing the test case.

Benefits of technology

It improves the success rate of test case execution, enhances the stability of automated testing, avoids the inconvenience of manually updating the database table object model, and improves the flexibility of updates and the stability of automated testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126675B_ABST
    Figure CN116126675B_ABST
Patent Text Reader

Abstract

The application discloses a test case execution method and device, electronic equipment and a storage medium. The method comprises the following steps: receiving a test request for requesting execution of a target test case, wherein the test request comprises identification information for determining a test environment corresponding to the target test case; acquiring database information of the test environment corresponding to the target test case according to the identification information; updating data in a database table object model according to data in a database corresponding to the database information, wherein the database table object model is a model called during execution of the target test case; and executing the target test case according to the updated database table object model. The embodiment improves the execution success rate of the test case.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of software testing, and particularly relates to a test case execution method and device, electronic equipment and a storage medium. BACKGROUND

[0002] With the rapid development of modern Internet, the front-end and back-end business processes are more and more complex and the version iteration speed is faster and faster, so the importance of automatic testing is inevitable. Each test case in automatic testing has appropriate check points, and the check of test data accounts for at least 70%, so the frequency of database access by the automatic framework is very high. However, in daily automatic testing, the test case can be successfully executed in the local test environment, but various errors occur when it is formally run in the automatic environment, and the script test case is unstable, so a solution is needed to improve the execution success rate of the test case. SUMMARY

[0003] The embodiments of the present application provide a test case execution method and device, electronic equipment and a storage medium to solve the problem of high failure rate in executing test cases in related technologies and improve the execution success rate of test cases.

[0004] In a first aspect, the embodiments of the present application provide a test case execution method, which includes the following steps.

[0005] receiving a test request for requesting execution of a target test case, wherein the test request includes identification information for determining a test environment corresponding to the target test case;

[0006] obtaining database information of the test environment corresponding to the target test case according to the identification information;

[0007] updating data in a database table object model according to data in a database corresponding to the database information, wherein the database table object model is a model called during execution of the target test case;

[0008] executing the target test case according to the updated database table object model.

[0009] In a second aspect, the embodiments of the present application further provide a test case execution device, which includes the following modules.

[0010] a receiving module configured to receive a test request for requesting execution of a target test case, wherein the test request includes identification information for determining a test environment corresponding to the target test case;

[0011] an obtaining module configured to obtain database information of the test environment corresponding to the target test case according to the identification information;

[0012] an updating module, configured to update data in a database table object model according to data in a database corresponding to the database information, wherein the database table object model is a model called by the target test case during execution of the target test case;

[0013] an executing module, configured to execute the target test case according to the updated database table object model.

[0014] In a third aspect, an electronic device is provided, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, and the program or instructions, when executed by the processor, implement the steps of the method according to the first aspect.

[0015] In a fourth aspect, a readable storage medium is provided, which stores a program or instructions, and the program or instructions, when executed by a processor, implement the steps of the method according to the first aspect.

[0016] According to the above solution, the test request for requesting execution of the target test case is received, wherein the test request includes identification information for determining the test environment corresponding to the target test case, the database information of the test environment corresponding to the target test case is obtained according to the identification information, the data in the database table object model is updated according to the data in the database corresponding to the database information, wherein the database table object model is a model called by the target test case during execution of the target test case, and the target test case is executed according to the updated database table object model. Since the identification information of the test environment required by the target test case is carried in the test request, the database information of the test environment can be obtained through the identification information, so that the database table object model can be updated according to the database information before the target test case is executed, and therefore the target test case can be executed according to the updated database table object model, that is, the target test case is executed through the data of the test environment corresponding to the target test case, thereby avoiding the problem of test case execution failure caused by inconsistency between the locally written test environment and the database information of the automatic test environment, and improving the stability of the automatic test and the success rate of the test case execution. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 is a flowchart of a test case execution method in the embodiments of the present application;

[0018] Figure 2 is an updating diagram of a database table object model in the embodiments of the present application;

[0019] Figure 3 is a flowchart of another test case execution method in the embodiments of the present application;

[0020] Figure 4 is a structural schematic diagram of an execution device of a test case in an embodiment of the present application;

[0021] Figure 5 is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0022] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0023] Specifically, in the automated testing, the test case written and debugged in the local test environment can be successfully executed, but once formally run in the automated environment, various errors will occur, the test case is very unstable, and after observing the log, it is found that most of the errors are caused by the different environment database information of the local test environment and the automated test environment, for example, some data tables have more fields, and some even have more data tables. These problems will cause the test case to fail.

[0024] In addition, in the related automated testing scheme, an open source method (for example, sqlacodegen) is usually used to assemble information in the form of a manual command before each time of running the automated test, including the file name, database address, database port, database username, database password, database name, database table and other information to form a complete command, which is executed in the file path to generate a data table object model, and then the test case is executed through the database table object model. This causes the need to manually execute the command to update the data table object model before each time of running the automated test, and the parameters of the command are different for different test environments, so the complete command needs to be slowly assembled, which is not convenient.

[0025] The database table object model (Object Relational Mapping, ORM) refers to writing the database table and field information into the program code in the form of an object model for use by the automated framework. That is, a data table of the database is mapped into an object in the program code, a data table record corresponds to an object instance, and each field in the data table corresponds to an attribute of the program object. The database table object model converts the operation on the database into the operation on the object, which facilitates the implementation of the operation on the database in the object-oriented thought. In the embodiment, the database table object model is a model called by the test case execution.

[0026] Herein a specific application scenario is taken as an example for illustration.

[0027] For example, it is assumed that the application scenario of the test case is an interface test scenario. In a computer, an interface is a shared boundary between two independent components of a computer system for information exchange, which can occur between computer software, hardware, external devices or operating personnel, or a combination thereof. Interface testing is mainly used to detect the interaction points between external systems and systems and between internal subsystems. The focus of the test is to check the exchange, transmission and control management process of data. It is assumed that in the interface test scenario, the database data corresponding to the test environment written locally is A, the database data corresponding to the test environment of the automatic test is B, and the database data A corresponding to the local test environment is not the same as the database data B corresponding to the test environment of the automatic test, for example, the database data B has one more field than the database data A. At this time, the test case is executed successfully through the database data A, but when the test case is run in the automatic test environment, the database data B is different from the database data A, resulting in the failure of the test case.

[0028] In addition, it is assumed that the data related to the test environment in the currently generated database table object model is database data A. After the test case fails, the database table object model needs to be manually updated, and the database data A in the database table object model A is updated to database data B. The update is not intelligent and convenient.

[0029] To solve the above problems, the applicant provides a test case execution method. By receiving a test request for requesting execution of a target test case, the test request carries identification information of a test environment required by the target test case. The identification information can be used to obtain database information of the test environment, so that the database table object model called by the target test case during execution can be updated according to the database information before the target test case is executed. Therefore, the target test case can be executed according to the updated database table object model, that is, the target test case is executed through the data of the test environment corresponding to the target test case. The problem of test case execution failure caused by inconsistency between the database information of the local test environment and the automatic test environment is avoided, and the automatic update process of the database table object model is realized, thereby improving the stability of the automatic test and the success rate of the test case execution.

[0030] The test case execution method provided by the embodiments of the present application will be described in detail in combination with the accompanying drawings and specific embodiments and application scenarios.

[0031] Figure 1An embodiment of the present application provides a test case execution method, which can be executed by an electronic device. The electronic device can include a server and / or a terminal device. The terminal device can include a smartphone, a tablet computer, a notebook computer, a desktop computer, a smart voice interaction device, a smart home appliance, a smart watch, a vehicle-mounted terminal, an aircraft, etc. The server can include a single physical server, a server cluster composed of multiple physical servers, a distributed system, or a cloud server capable of providing cloud computing services. In other words, the method can be executed by software or hardware installed on the electronic device. The method includes the following steps:

[0032] Step 101: receiving a test request for requesting execution of a target test case.

[0033] Specifically, the test request includes identification information of a test environment corresponding to the target test case.

[0034] The identification information of the test environment can be a number corresponding to the test environment, a name of the test environment, etc.

[0035] The electronic device receives the test request including the identification information of the test environment corresponding to the target test case, so that the test environment corresponding to the target test case can be determined according to the identification information of the test environment, and the automatic test of the target test case can be started after the test request is received.

[0036] Of course, before receiving the test request for requesting execution of the target test case, the target test case can also be constructed in response to an operation of constructing the target test case. The parameters used when constructing the target test case include the test environment identification information.

[0037] Step 102: obtaining database information of a test environment corresponding to the target test case according to the identification information.

[0038] Specifically, the database information of the test environment corresponding to the target test case can be obtained according to the identification information of the test environment, so that the data of the database corresponding to the test environment can be obtained.

[0039] Specifically, when the database information of the test environment corresponding to the target test case is acquired according to the identification information, the environment configuration of the test environment can be searched from the engineering directory corresponding to the target test case through the identification information of the test environment, and the database information corresponding to the test environment is acquired from the environment configuration. Taking the name of the test environment as the identification information for example, the environment configuration of the corresponding test environment can be searched from the engineering directory corresponding to the target test case through the name of the test environment, so as to acquire the database information under the test environment. In this way, by acquiring the database information of the test environment, the underlying data required when the target test case is executed is acquired, and support is provided for executing the target test case.

[0040] In an embodiment, the database information includes at least one of the following: the name of the database table object model, the database username, the database password, the database address, and the database name. In this way, the database corresponding to the test environment can be searched through the database username, the database password, the database address, and the database name in the database information, so as to acquire the data in the database; in addition, the database table object model to be updated can be searched through the name of the database table object model, thereby providing a basis for updating the database table object model. Of course, the database table object model can also have a default storage path, so that the electronic device can search for the database table object model to be updated through the default storage path.

[0041] Step 103: updating the data in the database table object model according to the data in the database corresponding to the database information.

[0042] The database table object model is a model called when the target test case is executed.

[0043] Specifically, the database table object model refers to writing the database table and field information into the program code in an object mode for use by the automation framework. That is, a data table of the database is mapped into an object in the program code, a data table record corresponds to an object instance, and each field in the data table corresponds to an attribute of the program object. The database table object model converts the operation on the database into the operation on the object, which facilitates the operation on the database in an object-oriented manner. In this embodiment, the database table object model is a model called when the test case is executed.

[0044] The automation framework can be open source software that provides a structured query language (SQL) toolkit and an object-relational mapping tool, for example, the automation framework can be SQLAlchemy. SQLAlchemy is a framework in a computer programming language (for example, Python) that operates a database through a database table object model, and its object-relational mapper provides a method for associating user-defined Python classes with database tables and associating instances of these classes (objects) with rows in their corresponding tables; it includes a system called a unit of work that transparently synchronizes changes in the state of objects and their related rows, and a system that expresses database queries according to user-defined classes and their defined relationships with each other.

[0045] In this way, the data in the database table object model is updated according to the data in the database corresponding to the database information, and since the data in the database corresponding to the database information is the data in the database of the target test case required test environment, the data in the database table object model related to the test environment can be matched with the target test case after the data in the database table object model is updated according to the data in the database corresponding to the database information, thereby ensuring that the target test case can be successfully executed. In addition, the database table object model is updated by the obtained database information, realizing the automatic updating process of the database table object model, and avoiding the problem of time-consuming and inconvenience caused by manually updating the database table object model before executing the target test case.

[0046] In one embodiment, the test request further includes indication information for indicating whether to update the database table object model; at this time, before the database information of the test environment corresponding to the target test case is obtained according to the identification information, the step of obtaining the database information of the test environment corresponding to the target test case according to the identification information can be further included. In the case where the indication information indicates to update the database table object model, the step of obtaining the database information of the test environment corresponding to the target test case according to the identification information. In this way, the step of obtaining the database information of the test environment corresponding to the target test case is executed when the test request includes the indication information and the indication information indicates to update the database table object model, so that it can be selected according to the demand whether to update the database table object model, and the flexibility of updating the database table object model is improved.

[0047] Specifically, the indication information can be represented by binary digits, for example, 0 indicates not to update the database table object model, and 1 indicates to update the database table object model; of course, the indication information can also be represented by characters, for example, the character "N" indicates not to update the database table object model, and the character "Y" indicates to update the database table object model; of course, the above is only an example, and the embodiment does not specifically limit the specific form of the indication information.

[0048] Of course, if the indication information indicates not to update the database table object model, the target test case can be directly executed, meeting the automatic test requirement of the test environment which does not update the database table object model.

[0049] Step 104: executing the target test case according to the updated database table object model.

[0050] Specifically, after updating the database table object model, the target test case can be executed according to the updated database table object model. At this time, since the data in the updated database table object model includes the data in the database corresponding to the test environment required by the target test case, the data in the database table object model related to the test environment can be matched with the target test case, so as to ensure that the target test case can be successfully executed, and improve the execution success rate of the target test case.

[0051] In this way, the embodiment realizes updating the database table object model before executing the target test case through the above steps. Since the database table object model is updated according to the database information of the test environment of the target test case, the updated database table object model can meet the test environment requirement of the target test case, thereby improving the execution success rate of the target test case. In addition, the embodiment realizes the automatic updating process of the database table object model by obtaining the database information of the test environment through the test request, and updating the data in the database table object model according to the data in the database corresponding to the database information.

[0052] In addition, in an embodiment, updating the data in the database table object model according to the data in the database corresponding to the database information can include:

[0053] Assembling the database information into a command statement, the language format of the command statement being the same as that of the database table object model; calling a pre-encapsulated command executor to execute the command statement in the path where the database table object model is located, so as to update the data in the database corresponding to the database information into the database table object model.

[0054] Specifically, after obtaining the database information, the database information can be assembled into a command statement in the same language format as the database table object model. For example, as an example, assuming that the database information includes the name of the database table object model, the database username, the database password, the database address, and the database name, the file name of the database table object model is icrm.py, the database username is root, the database password is 123456, the database address is 192.168.1.1:3306, and the database name is user, the database information can be assembled into a command statement as follows: sqlacodegen --outfile icrm.py mysql: / / root:123456@192.168.1.1:3306 / user?charset=utf8.

[0055] After assembling the database information into the command statement, a pre-encapsulated command executor can be called to execute the command statement in the path of the database table object model, so as to update the data in the database corresponding to the database information into the database table object model, thereby realizing the update of the database table object model.

[0056] Specifically, the command executor can be used to execute a command prompt (cmd) command in a Microsoft Windows operating system (windows) or a command in a Linux environment.

[0057] In addition, in an embodiment, when updating the data in the database corresponding to the database information into the database table object model, any of the following methods can be included:

[0058] One method: by executing the command statement, the data in the database corresponding to the database information is added to the database table object model.

[0059] Specifically, if the database table object model does not include the data in the database corresponding to the database information required by the test environment of the target test case, the data in the database corresponding to the database information can be added to the database table object model by executing the command statement, so that the updated database table object model includes the data in the database corresponding to the test environment, and thus the execution success rate of the target test case can be improved when the target test case is executed through the updated database table object model.

[0060] The second method: by executing the command statement, the target information in the database table object model is replaced with the data in the database corresponding to the database information.

[0061] The target information is information related to the test environment of the target test case.

[0062] Specifically, in this way, if the information related to the test environment already exists in the database table object model, the target information in the database table object model can be replaced by the data in the database corresponding to the database information by executing the command statement, so that the updated database table object model includes the data in the database corresponding to the test environment required by the target test case, and further so that the execution success rate of the target test case can be improved when the target test case is executed through the updated database table object model.

[0063] In one embodiment, the target information is a target data table, and the replacing of the target information in the database table object model by the data in the database corresponding to the database information can include:

[0064] According to the plurality of attributes of the data in the database corresponding to the database information, a plurality of table fields to be mapped and data of each table field are determined, wherein each attribute corresponds to a table field, and the data corresponding to each attribute is the data of the table field corresponding to the attribute; and according to each table field of the target data table, the plurality of table fields to be mapped and the data corresponding to each table field are mapped into the target data table.

[0065] Specifically, the data in the database corresponding to the database information has a plurality of attributes, each attribute corresponds to a table field, and the data corresponding to each attribute is the data of the table field corresponding to the attribute. For example, as shown in Figure 2 , it is assumed that the plurality of attributes can include id, name, age, etc.; the table field corresponding to the attribute id is id, the data corresponding to the table field of the attribute is bigint, the table field corresponding to the attribute name is name, the data corresponding to the table field of the attribute is varchar(100), and the table field corresponding to the attribute age is age, the data corresponding to the table field of the attribute is int. In addition, the target information in the database table object model can be a target data table, which also includes a plurality of table fields, for example, referring to Figure 2 , the plurality of table fields in the target data table include id, name and age. In addition, the database corresponding to the database information is embodied by the class name (Class Name), and the target data table of the database table object model is embodied by the table name (TableName).

[0066] In this embodiment, the plurality of table fields to be mapped and the data of each table field can be determined according to the plurality of attributes of the data in the database corresponding to the database information, and the plurality of table fields to be mapped and the data corresponding to each table field in the database corresponding to the database information are mapped into the target data table. For example, referring to Figure 2In the process of mapping the database information corresponding to the database to be mapped to the target data table, the Class Name to TableName mapping can be performed, that is, the mapping relationship of the table field can be established first, and then the data corresponding to each table field in the database information corresponding to the database is mapped to the corresponding table field of the target data table, so as to realize the replacement and update of the target information in the database table object model.

[0067] In this way, the above-mentioned any way realizes the updating of the data of the database corresponding to the database information to the database table object model, thereby realizing the updating process of the database table object model.

[0068] The present application will be described below through a specific embodiment. The present application will be described below through Figure 3 An embodiment of the present application will be described below.

[0069] As Figure 3 shown, the embodiment can include the following steps:

[0070] Step 301: parameterize the target test case through the continuous integration tool.

[0071] Specifically, the continuous integration tool can be Jenkins, which is a continuous integration tool developed based on an object-oriented programming language (Java), used to monitor continuous and repetitive work, and aims to provide an open and easy-to-use software platform to enable continuous integration of software projects.

[0072] In this step, the target test case can be parameterized first, and the parameters include the indication information indicating whether to update the database table object model and the identification information of the test environment, such as the name of the test environment (testEnv).

[0073] In addition, specifically, the test request includes the above two parameters, that is, the indication information indicating whether to update the database table object model and the identification information of the test environment. For example, as an example, the parameter form included in the test request can be:

[0074] python-m pytest--isUpdateOrm=%isUpdateOrm%--testEnv=%testEnv%

[0075] Step 302: receiving a test request for requesting to execute the target test case, and starting an automated test project.

[0076] In this step, take pytest automation test framework as an example, pytest automation test framework uses command line parameters (pytest_addoption) in the configuration (conftest) file to obtain parameters in the test request. Then, the parameters are parsed to determine whether the database table object model needs to be updated. If not, the execution of the automated test case is directly started. If so, go to step 3.

[0077] Step 303: Read the identification information of the test environment corresponding to the target test case, and assemble the command statement.

[0078] Specifically, the identification information of the test environment is taken as the name of the test environment as an example.

[0079] In this step, the name of the test environment (testEnv) is first parsed, and then the database information in the corresponding test environment is found according to the test environment name in the configuration item in the project corresponding to the target test case, and assembled into a command statement.

[0080] Wherein, if the database information includes the name of the database table object model, the database username, the database password, the database address and the database name, the file name of the database table object model is icrm.py, the database username is root, the database password is 123456, the database address is 192.168.1.1:3306, and the database name is user, then:

[0081] The command statement assembled by the database information can be: sqlacodegen--outfile icrm.pymysql: / / root:123456@192.168.1.1:3306 / user?charset=utf8.

[0082] Step 304: Execute the command statement to update the database table object model.

[0083] Specifically, in this process, the encapsulated command executor can be executed to execute the command statement in the path of the database table object model to update the data in the database corresponding to the database information to the database table object model.

[0084] Wherein, the updating process includes adding the data in the database corresponding to the database information to the database table object model, or replacing the target data table in the database table object model with the data in the database corresponding to the database information.

[0085] Specifically, the process of replacing the target data table in the database table object model with the data in the database corresponding to the database information can be referred to Figure 2 Related content, which will not be repeated here.

[0086] Step 305: executing the target test case.

[0087] In this step, the target test case is executed to perform data verification through the updated database table object model.

[0088] Of course, the database table object model can also be used by the automation framework to operate the database and verify the data.

[0089] The above steps update the database table object model before executing the automation test case, greatly improve the stability of the automation framework and the success rate of the test case execution, and avoid manually creating or updating the database table object model before each execution of the automation test case, thereby realizing the automatic updating process of the database table object model.

[0090] Figure 4 An embodiment of the application shows a structure schematic diagram of a test case execution device. As shown in the figure, Figure 4 The test case execution device includes:

[0091] The receiving module 401 is configured to receive a test request for requesting execution of a target test case, wherein the test request includes identification information for determining a test environment corresponding to the target test case.

[0092] The obtaining module 402 is configured to obtain database information of the test environment corresponding to the target test case according to the identification information.

[0093] The updating module 403 is configured to update data in a database table object model according to data in a database corresponding to the database information, wherein the database table object model is a model called during execution of the target test case.

[0094] The execution module 404 is configured to execute the target test case according to the updated database table object model.

[0095] In an implementation manner, the updating module 403 is configured to assemble the database information into a command statement, the language format of the command statement is the same as that of the database table object model, call a pre-encapsulated command executor, and execute the command statement in a path where the database table object model is located, so as to update data in the database corresponding to the database information into the database table object model.

[0096] In an implementation manner, the updating module 403 is configured to add data in the database corresponding to the database information into the database table object model by executing the command statement.

[0097] In an implementation manner, the updating module 403 is configured to replace the target information in the database table object model with data in the database corresponding to the database information by executing the command statement, wherein the target information is information related to the test environment of the target test case.

[0098] In an implementation manner, the target information is a target data table, and the updating module 403 is configured to determine a plurality of table fields to be mapped and data of each table field according to a plurality of attributes of data in the database corresponding to the database information, wherein each attribute corresponds to a table field, and the data corresponding to each attribute is data of the table field corresponding to the attribute; and map the plurality of table fields to be mapped and the data corresponding to each table field into the target data table according to each table field of the target data table.

[0099] In an implementation manner, the test request further includes indication information for indicating whether to update the database table object model; and in a case where the indication information indicates to update the database table object model, the step of acquiring the database information of the test environment corresponding to the target test case according to the identification information in the acquiring module is performed.

[0100] In an implementation manner, the database information includes at least one of the following: a name of the database table object model, a database username, a database password, a database address, and a database name.

[0101] The test case execution device provided by the embodiments of the present application can implement the method embodiments Figures 1-3 The method embodiments implement various processes, and to avoid repetition, details are not described herein.

[0102] It should be noted that the embodiments of the test case execution device in the present specification and the embodiments of the test case execution method in the present specification are based on the same inventive concept, and therefore the specific implementation of the test case execution device embodiments can be referred to the foregoing corresponding test case execution method embodiments, and repeated details are not described herein.

[0103] The test case execution apparatus in the embodiments of the present application can be an apparatus, or a component, an integrated circuit, or a chip in a terminal. The apparatus can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc., and the embodiments of the present application are not limited in this regard.

[0104] The test case execution apparatus in the embodiments of the present application can be an apparatus having an operating system. The operating system can be an Android operating system, an ios operating system, or other possible operating systems, and the embodiments of the present application are not limited in this regard.

[0105] Based on the same technical concept, the embodiments of the present application further provide an electronic device for executing the test case execution method described above, Figure 5 A structural schematic diagram of an electronic device for implementing various embodiments of the present application. The electronic device can have great differences due to different configurations or performances, and can include a processor 510, a communications interface 520, a memory 530, and a communications bus 540. The processor 510, the communications interface 520, and the memory 530 can communicate with each other through the communications bus 540. The processor 1210 can invoke a computer program stored on the memory 530 and executable on the processor 510 to perform the following steps:

[0106] receiving a test request for requesting execution of a target test case, wherein the test request includes identification information for determining a test environment corresponding to the target test case;

[0107] obtaining database information of the test environment corresponding to the target test case according to the identification information;

[0108] updating data in a database table object model according to data in a database corresponding to the database information, wherein the database table object model is a model called during execution of the target test case;

[0109] executing the target test case according to the updated database table object model.

[0110] In an implementation, the updating of the data in the database table object model according to the database information comprises: assembling the database information into a command statement, the language format of the command statement being the same as that of the database table object model; and invoking a pre-encapsulated command executor to execute the command statement in a path where the database table object model is located, so as to update the data in the database corresponding to the database information into the database table object model.

[0111] In an implementation, the updating of the data in the database table object model according to the database information comprises: adding the data in the database corresponding to the database information into the database table object model by executing the command statement.

[0112] In an implementation, the updating of the data in the database table object model according to the database information comprises: replacing target information in the database table object model with the data in the database corresponding to the database information by executing the command statement, wherein the target information is information related to a test environment of the target test case.

[0113] In an implementation, the target information is a target data table, and the replacing of the target information in the database table object model with the data in the database corresponding to the database information comprises: determining a plurality of table fields to be mapped and data of each table field according to a plurality of attributes of the data in the database corresponding to the database information, wherein each attribute corresponds to a table field, and the data corresponding to each attribute is data of the table field corresponding to the attribute; and mapping the plurality of table fields to be mapped and the data corresponding to each table field into the target data table according to each table field of the target data table.

[0114] In an implementation, the test request further comprises indication information for indicating whether to update the database table object model; and before the obtaining of the database information of the test environment corresponding to the target test case according to the identification information, the method further comprises: in a case where the indication information indicates to update the database table object model, performing the step of obtaining the database information of the test environment corresponding to the target test case according to the identification information.

[0115] In an implementation, the database information comprises at least one of the following: a name of the database table object model, a database username, a database password, a database address, and a database name.

[0116] The specific implementation steps can refer to the steps of the execution method embodiments of the test case described above, and the same technical effects can be achieved. To avoid repetition, details are not described here.

[0117] It should be noted that the electronic device in the embodiments of the present application includes a server, a terminal or other devices in addition to the terminal.

[0118] The above electronic device structure does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than the illustration, or combine certain components, or different component arrangements. For example, the input unit can include a graphics processing unit (GPU) and a microphone, and the display unit can be configured with a display panel in the form of a liquid crystal display, an organic light-emitting diode, etc. The user input unit includes at least one of a touch panel and other input devices. The touch panel is also called a touch screen. Other input devices can include, but are not limited to, a physical keyboard, function keys (such as volume control buttons, on-off buttons, etc.), trackballs, mice, joysticks, and the like, and details are not described here.

[0119] The memory can be used to store software programs and various data. The memory can mainly include a first storage area storing programs or instructions and a second storage area storing data, wherein the first storage area can store an operating system, application programs or instructions required by at least one function (such as a sound playing function, an image playing function, etc.), and the like. In addition, the memory can include a volatile memory or a non-volatile memory, or the memory can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically EPROM (EEPROM), or a flash memory. The volatile memory can be a Random Access Memory (RAM), a Static RAM (SRAM), a Dynamic RAM (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate SDRAM (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synchlink DRAM (SLDRAM), and a Direct Rambus RAM (DRRAM).

[0120] The processor can include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and an application program, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above-mentioned modem processor can also not be integrated into the processor.

[0121] The embodiment of the present application further provides a readable storage medium, the readable storage medium stores programs or instructions, the programs or instructions are executed by a processor to realize each process of the execution method embodiment of the test case, and the same technical effects can be achieved. To avoid repetition, details are not described here.

[0122] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0123] The chip provided in the embodiments of the present application includes a processor and a communication interface, the communication interface is coupled with the processor, the processor is used to execute programs or instructions, realize various processes of the above method embodiments, and achieve the same technical effects. To avoid repetition, details are not described here.

[0124] It should be understood that the chip mentioned in the embodiments of the present application can also be referred to as a system-level chip, a system chip, a chip system, or a system-on-chip chip, etc.

[0125] It should be noted that in this document, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of additional identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to the order of performing functions as shown or discussed, but can also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method can be performed in an order different from the described order, and various steps can also be added, omitted or combined. In addition, the features described with reference to some examples can be combined in other examples.

[0126] From the above description of the embodiments, those skilled in the art can clearly understand that the above method embodiments can be realized by means of software and necessary general hardware platforms, of course, also by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk), and includes a plurality of instructions for causing a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the various embodiments of the present application.

[0127] The embodiments of the present application are described above with reference to the accompanying drawings, but the present application is not limited to the specific embodiments described above, and the specific embodiments described above are merely illustrative, but not restrictive, and a person of ordinary skill in the art can make many forms under the inspiration of the present application without departing from the purpose of the present application and the scope protected by the claims.

Claims

1. A method for executing test cases, characterized in that, include: Receive a test request for requesting the execution of a target test case, wherein the test request includes identification information for determining the test environment corresponding to the target test case; Based on the identification information, obtain the database information of the test environment corresponding to the target test case; The data in the database table object model is updated based on the data in the database corresponding to the database information. The database table object model is the model called when the target test case is executed. The database table object model is generated based on the database information corresponding to the locally written test environment. Updating the data in the database table object model includes: adding data from the database corresponding to the database information to the database table object model, or replacing the target information in the database table object model with the data from the database corresponding to the database information, wherein the target information is information related to the test environment of the target test case; The target test cases are executed based on the updated database table object model.

2. The method for executing test cases according to claim 1, characterized in that, The step of updating the data in the database table object model based on the data in the database corresponding to the database information includes: The database information is assembled into command statements, and the language format of the command statements is the same as the language format of the database table object model. A pre-packaged command executor is invoked to execute the command statement at the path where the database table object model is located, so as to update the data in the database corresponding to the database information to the database table object model.

3. The method for executing test cases according to claim 2, characterized in that, The step of updating the data in the database corresponding to the database information to the database table object model includes: By executing the command statement, the data in the database corresponding to the database information is added to the database table object model.

4. The method for executing test cases according to claim 2, characterized in that, The step of updating the data in the database corresponding to the database information to the database table object model includes: By executing the command statement, the target information in the database table object model is replaced with the data in the database corresponding to the database information.

5. The method for executing test cases according to claim 4, characterized in that, The target information is a target data table. The step of replacing the target information in the database table object model with the data in the database corresponding to the database information includes: Based on the various attributes of the data in the database corresponding to the database information, determine multiple table fields to be mapped and the data of each table field, wherein each attribute corresponds to one table field, and the data corresponding to each attribute is the data of the table field corresponding to that attribute. Based on the various table fields of the target data table, the multiple table fields to be mapped and the data corresponding to each table field are mapped to the target data table.

6. The method for executing test cases according to claim 1, characterized in that, The test request also includes indication information for indicating whether to update the database table object model; Before obtaining the database information of the test environment corresponding to the target test case based on the identification information, the method further includes: If the instruction information indicates that the database table object model should be updated, the step of obtaining the database information of the test environment corresponding to the target test case based on the identification information shall be performed.

7. The method for executing test cases according to claim 1, characterized in that, The database information includes at least one of the following: The database table object model name, database username, database password, database address, and database name.

8. A test case execution device, characterized in that, include: The receiving module is configured to receive a test request for requesting the execution of a target test case, wherein the test request includes identification information for determining the test environment corresponding to the target test case; The acquisition module is used to acquire the database information of the test environment corresponding to the target test case based on the identification information; The update module is used to update the data in the database table object model according to the data in the database corresponding to the database information, wherein the database table object model is the model called when the target test case is executed, and the database table object model is generated based on the database information corresponding to the locally written test environment; Updating the data in the database table object model includes: adding data from the database corresponding to the database information to the database table object model, or replacing the target information in the database table object model with the data from the database corresponding to the database information, wherein the target information is information related to the test environment of the target test case; The execution module is used to execute the target test cases based on the updated database table object model.

9. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method for executing test cases as described in any one of claims 1-7.

10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the test case execution method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Interface test method and device, electronic device and storage medium

    CN111581083A