A method, device, equipment and storage medium for switching use case test environment

By creating environment switch files and configuration files, and using environment name switching to realize the entry parameter reading of automated use cases in different environments, the environment dependence problem of coded automation use cases is solved, and the execution and maintenance workload of automated use cases in different environments is reduced.

CN115543805BActive Publication Date: 2025-08-29PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211236916.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-10
Publication Date
2025-08-29
Estimated Expiration
2042-10-10

AI Technical Summary

Technical Problem

The execution of coded automation use cases has a strong dependence on the environment, and the input parameter information and return expected results cannot be shared among different environments, resulting in the use cases being unable to be executed in different environments, increasing the maintenance workload of automation use cases.

Method used

By creating environment switch files and configuration files, using environment names to switch, automated use cases to read parameter data in different environments, realizing the switching of environment names and calling configuration files, solving the problem of strong environment dependence.

Benefits of technology

It realizes automatic parameters entry for automated use cases in different environments, reduces maintenance workload, reduces operation difficulty for testers, and automatically adapts interface parameters entry and generates response results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115543805B_ABST
    Figure CN115543805B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, device and storage medium for processing a use case test environment switch, which sets an environment for automated execution of a use case by creating an environment switch file and its environment name, and creating a corresponding configuration file based on the environment name. Access information is configured in a fixed format in the configuration file, so that when the execution environment of the use case is switched, the configuration file with the corresponding name can be called based on the environment name of the environment switch file, and input parameter data is read according to the access information configured in the configuration file, so that the use case can be automatically input in different execution environments. This solves the technical problem that the execution of coded automated use cases has a strong dependence on the environment, and the input parameter information and expected return results that are strongly related to the environment required by the use case cannot be shared between different environments, thereby causing the use case to be unable to meet the requirements of execution in different environments, thereby increasing the maintenance workload of the automated use cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of financial technology, and in particular to a method, apparatus, device and storage medium for switching a use case test environment. Background Art

[0002] An online system is a system in which input data can be directly input into the computer for processing from the data source, and the output data, i.e. the processing results, can be directly transmitted to the user.

[0003] Most systems that provide interface services mock the external system interfaces they rely on when implementing coded automation. The input and output parameters of coded automation use cases are fixed, and data must be cleaned before and after the automation use case is executed to ensure that the use case is not affected by the environment. In this case, automated use cases generally cannot be executed in a joint debugging environment, otherwise the accuracy of the joint debugging data may be affected, data conflicts may occur, and dirty data may cause the use case execution to fail.

[0004] In banking systems, business processes are highly complex, and environmental maintenance costs are high. Therefore, the Youma Automation environment and the joint debugging environment must be shared. The online wealth management agency sales system connects to multiple bank systems and relies on numerous external system interfaces. Youma Automation cannot mock every external system's data interface. Consequently, the execution of Youma Automation use cases is highly dependent on the environment. The required input parameters and expected return results, such as customer numbers, card numbers, and products, which are highly context-dependent, cannot be shared across different environments. This leads to technical issues such as the use cases being unable to execute in different environments, increasing the maintenance workload for the automated use cases. Summary of the Invention

[0005] The present application provides a method, apparatus, device and storage medium for switching use case test environments, which solves the technical problem that the execution of coded automation use cases is strongly dependent on the environment, and the input parameter information and expected return results that are strongly related to the environment required by the use cases cannot be shared between different environments, resulting in the use cases being unable to meet the requirements of execution in different environments, and increasing the maintenance workload of the automation use cases.

[0006] In view of this, a first aspect of the present application provides a method for switching a use case test environment, the method comprising:

[0007] S1. Create an environment switch file, and set the name of the environment for automated execution in the environment switch file;

[0008] S2. Create a configuration file, name the configuration file with the environment name configured in the environment switch file, and configure access information in a fixed format in the configuration file;

[0009] S3. When executing, the use case reads the environment name of the environment switch file and obtains the corresponding configuration file according to the environment name;

[0010] S4. Read input parameter data according to the access information configured in the configuration file;

[0011] S5. If the environment for executing the use case needs to be switched, the environment name of the environment switch file is set to the environment name corresponding to the environment after switching, and the process returns to step S3.

[0012] Optionally, step S4 specifically includes:

[0013] S41. Obtain first input parameter data through an SQL statement according to the database access information configured in the configuration file;

[0014] S42. Obtain second input parameter data through the interface address according to the third-party system access information configured in the configuration file.

[0015] Optionally, the step S41 includes:

[0016] S411: The expected result response code of the use case and the first input parameter data are passed into the interface test template as map type parameters;

[0017] S412. Obtain an actual response message for the first input parameter data, where the actual response message includes actual fields, field values ​​contained in the actual fields, and an input parameter response code;

[0018] S413. Obtain a response result according to the input parameter response code and the expected result response code, where the response result includes a successful response and a failed response.

[0019] Optionally, after step S413, the following steps are further included:

[0020] S414. If the response result is a successful response, create an expected value corresponding to the actual field according to the source of the field value of the actual response message and the preset field value generation rule;

[0021] S415. parse the actual response message, and compare the results of each actual field of the actual response message with the corresponding expected value. If each actual field of the actual response message is consistent with the corresponding expected value, the use case comparison result passes; otherwise, the use case comparison result fails.

[0022] Optionally, after step S413, the following steps are further included:

[0023] S416. If the response result is a response failure, the expected result response code of the use case and the actual response result are passed into the interface test template as map type parameters;

[0024] S417: Generate an expected response message for the use case, where the expected response message includes an expected field, a field value contained in the expected field, and the expected result response code;

[0025] S418. Compare the expected field, the field value contained in the expected field, and the expected result response code with the actual field, the field value contained in the actual field, and the input parameter response code respectively. If they are all consistent, the use case comparison result passes; otherwise, the use case comparison result fails.

[0026] Optionally, sources of the field values ​​of the actual response message include interface input parameters, user information and product information in a database, and calculations based on product configuration.

[0027] Optionally, the creating the expected value of the corresponding actual field according to a preset field value generation rule based on the source of the field value of the actual response message specifically includes:

[0028] The expected value of the corresponding actual field is obtained from the database according to the source of the field value of the actual response message and the database access information.

[0029] A second aspect of the present application provides a device for processing a use case test environment switch, the device comprising:

[0030] A first creation unit is configured to create an environment switch file, and set an environment name for automated execution in the environment switch file;

[0031] A second creating unit is configured to create a configuration file, name the configuration file with the environment name configured in the environment switch file, and configure access information in a fixed format in the configuration file;

[0032] An execution unit, configured to read the environment name of the environment switch file when executing a use case, and obtain the corresponding configuration file according to the environment name;

[0033] An input parameter unit, configured to read input parameter data according to the access information configured in the configuration file;

[0034] The environment switching unit is used to set the environment name of the environment switch file to the environment name corresponding to the switched environment if the environment for executing the use case needs to be switched, and jump to the execution unit.

[0035] A third aspect of the present application provides a use case test environment switching processing device, the device comprising a processor and a memory:

[0036] The memory is used to store program code and transmit the program code to the processor;

[0037] The processor is configured to execute the steps of the method for switching the use case test environment as described in the first aspect according to the instructions in the program code.

[0038] In a fourth aspect, the present application provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the steps of the use case test environment switching processing method described in the first aspect.

[0039] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0040] In the present application, a method for switching the test environment of a use case is provided, in which the environment for the automated execution of the use case is set by creating an environment switch file and its environment name, and a corresponding configuration file is created based on the environment name. Access information is configured in a fixed format in the configuration file, so that when the execution environment of the use case is switched, the configuration file with the corresponding name can be called based on the environment name of the environment switch file, and the input parameter data is read according to the access information configured in the configuration file, so that the use case can be automatically input in different execution environments. This solves the technical problem that the execution of coded automation use cases has a strong dependence on the environment, and the input parameter information and return expected results that are strongly related to the environment required by the use case cannot be shared between different environments, thereby causing the use case to be unable to meet the requirements of execution in different environments, thereby increasing the maintenance workload of the automation use case. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 A flow chart of a method for switching a use case test environment in an embodiment of the present application;

[0042] Figure 2 This is a structural diagram of a test environment switching device for a use case in an embodiment of the present application;

[0043] Figure 3 This is a structural diagram of a use case test environment switching device in an embodiment of the present application. DETAILED DESCRIPTION

[0044] In order to help those skilled in the art better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0045] This application designs a use case test environment switching method, device, equipment and storage medium, which solves the technical problem that automated use cases cannot be executed in a joint debugging environment, which affects the accuracy of joint debugging data, or causes data conflicts, resulting in dirty data and causing use case execution failure.

[0046] For easier understanding, see Figure 1 , Figure 1 This is a flow chart of a method for switching a test environment for a use case in an embodiment of the present application. Figure 1 As shown, specifically:

[0047] S1. Create an environment switch file and set the environment name for automated execution in the environment switch file;

[0048] It should be noted that in the Youma automated test project, an environment switch file is created, such as env.properties, and the environment name for automated execution is set in the environment switch file. Different environments can be distinguished by the environment name.

[0049] It is understandable that when the environment name of the environment switch file is changed, the environment will be switched to the environment with the corresponding environment name in the changed environment switch file.

[0050] S2. Create a configuration file, name the configuration file after the environment name configured in the environment switch file, and configure access information in a fixed format in the configuration file;

[0051] It's important to note that since different environments are distinguished only by their names, corresponding configuration files are created. These configuration files are named after the environment names configured in the environment switch files, so different configuration files also correspond to the corresponding environments based on the environment names. The configuration files contain access information in a fixed format, such as the application service's access address and port, database instance information, and Redis access instance information.

[0052] That is, each environment corresponds to a configuration file, and the configuration files are distinguished by the environment name.

[0053] S3. When executing, the use case reads the environment name of the environment switch file and obtains the corresponding configuration file based on the environment name;

[0054] It should be noted that when the use case is executed, it first reads the environment name configured in the environment switch file, and then obtains the configuration file with the corresponding name based on the environment name. The environment switch file and the configuration file are associated through the environment name. Based on the current environment name of the environment switch file, the configuration file corresponding to the same environment name can be obtained.

[0055] S4. Read the input parameter data according to the access information configured in the configuration file;

[0056] It should be noted that after obtaining the configuration file with the corresponding environment name, the corresponding input parameter data can be read according to the access information configured in the configuration file. For example, according to the access address and port of the application service; DB instance information; redis access instance information, the corresponding input parameter data can be obtained through the application service request address and port; DB access address and port; database name; access username and password, etc.

[0057] S5. If the environment for executing the use case needs to be switched, the environment name of the environment switch file is set to the environment name corresponding to the environment after switching, and the process returns to step S3.

[0058] It should be noted that based on the technology of obtaining configuration files through environment names in different environments, if it is necessary to switch the environment for the use case execution, it is only necessary to change the environment name of the environment switch file to the environment name corresponding to the environment after the switch, and return to step S3 to obtain the corresponding configuration file based on the environment name of the environment switch file. It is understandable that, that is, in the use case test, after the environment is switched, the input parameter data required by the use case can still be automatically transmitted through the pre-configured configuration file with the corresponding environment name, which solves the problem that the execution of coded automated use cases has a strong dependence on the environment, and the input parameter information and return expected results that are strongly related to the environment required by the use case cannot be shared between different environments, resulting in the use case being unable to meet the technical problem of execution in different environments, increasing the maintenance workload of the automated use case.

[0059] Furthermore, step S4 specifically includes:

[0060] S41. Obtain the first input parameter data through an SQL statement according to the database access information configured in the configuration file;

[0061] S42. According to the third-party system access information configured in the configuration file, obtain the second input parameter data through the interface address.

[0062] It should be noted that, based on the first embodiment of this application, if the input parameter data to be obtained is from the database, it is necessary to use SQL statements and read the required input parameter data from the database table according to the database access information of the system under test configured in the configuration file, such as the customer number, card number, product number, and other information required by the purchase interface. If the data to be obtained is from a third-party system, it is necessary to obtain the input parameter data through the interface address according to the third-party system access information configured in the configuration file, such as obtaining customer information through the interface address of the account opening interface.

[0063] Furthermore, after step S41, the following steps are included:

[0064] S411. The expected result response code of the use case and the first input parameter data are passed into the interface test template as map type parameters;

[0065] S412. Obtain an actual response message for the first input parameter data, where the actual response message includes actual fields, field values ​​included in the actual fields, and an input parameter response code;

[0066] S413. Obtain a response result based on the input parameter response code and the expected result response code. The response result includes a successful response and a failed response.

[0067] It should be noted that the expected result response code of the use case and the first input parameter data are passed to the interface test template as map type parameters, and the actual response message of the first input parameter data is obtained at the same time. The input parameter response code in the actual response message is compared with the expected result response code. For example, if the input parameter response code fed back by the interface is 00000, which is consistent with the expected result response code, the response result is a successful response, otherwise it is a failed response.

[0068] Furthermore, after step S413, the following steps are further included:

[0069] S414. If the response result is a successful response, then according to the source of the field value of the actual response message, create an expected value corresponding to the actual field according to the preset field value generation rule;

[0070] S415. parse the actual response message and compare the results of each actual field of the actual response message with the corresponding expected value. If the actual fields of the actual response message are consistent with the corresponding expected value, the use case comparison result passes; otherwise, the use case comparison result fails.

[0071] It should be noted that if the expected interface response is successful, the source of the field values ​​in the actual response message is further analyzed, and expected values ​​corresponding to the actual fields are created according to the field value generation rules. The actual response message is then parsed field by field, and each actual field is compared with its corresponding calculated expected value. If the comparison is consistent, the use case comparison result passes; otherwise, the use case comparison result fails.

[0072] Specifically:

[0073] 1. The field values ​​in the actual response message come from: interface input parameters (such as customer number, card number, product number, TA number, amount, etc.), database user information (such as customer name, etc.), product information (such as product name, currency, confirmation days, open period, etc.), and values ​​calculated based on product configuration (such as order status, payment status, etc.).

[0074] 2. Create expected values ​​for the actual response message: Based on the input information such as the customer number, card number, and product number, obtain the field information required for the actual fields of the actual response message from the database. For example, query the customer table by the customer number and card number to obtain customer information (such as customer name), query the product information and type by the product number, and confirm the order status and payment status based on the product type.

[0075] 3. Result comparison: After obtaining the expected value of the actual response message through the input parameters, a one-to-one comparison is performed with the actual fields of the actual response message. If the expected and actual results are consistent, the use case comparison result passes; otherwise, the use case comparison result fails.

[0076] Furthermore, after step S413, the following steps are further included:

[0077] S416. If the response result is a response failure, the expected result response code of the use case and the actual response result are passed to the interface test template as map type parameters;

[0078] S417: Generate an expected response message for the use case, where the expected response message includes expected fields, expected field values, and expected result response codes.

[0079] S418. Compare the expected fields, the field values ​​contained in the expected fields, and the expected result response code with the actual fields, the field values ​​contained in the actual fields, and the input parameter response code respectively. If they are all consistent, the use case comparison result passes; otherwise, the use case comparison result fails.

[0080] It should be noted that if the response result is a failure, the expected result response code of the use case and the actual response result need to be passed to the interface test template as a map type parameter, and the expected result response code and the actual response result need to be compared. At the same time, the expected field results are generated according to the failure scenario, and the field values ​​of each field are verified one by one. Specifically:

[0081] 1. Compare the response code and response information passed in the use case with the response code and response message actually returned by the system. If the results are consistent, the use case passes; otherwise, it fails.

[0082] 2. Based on the customer number, card number, product, and order time, determine whether there is any new order flow in the database; otherwise, the use case fails.

[0083] Furthermore, based on the source of the field value of the actual response message, creating the expected value of the corresponding actual field according to the preset field value generation rule specifically includes:

[0084] The expected value of the corresponding actual field is obtained from the database according to the source of the field value of the actual response message and the database access information.

[0085] See also Figure 2 , Figure 2 This is a schematic diagram of the structure of a test environment switching device for a use case in an embodiment of the present application. Figure 2 As shown, specifically:

[0086] The first creation unit 201 is used to create an environment switch file and set the name of the environment for automated execution in the environment switch file;

[0087] The second creating unit 202 is used to create a configuration file, name the configuration file with the environment name configured in the environment switch file, and configure access information in the configuration file in a fixed format;

[0088] The execution unit 203 is used to read the environment name of the environment switch file when the use case is executed, and obtain the corresponding configuration file according to the environment name;

[0089] The input parameter unit 204 is used to read the input parameter data according to the access information configured in the configuration file;

[0090] The environment switching unit 205 is used to set the environment name of the environment switch file to the environment name corresponding to the switched environment if the environment for executing the use case needs to be switched, and jump to the execution unit.

[0091] The present application embodiment also provides another use case test environment switching device, such as Figure 3 For ease of explanation, only the parts related to the embodiments of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiments of the present application. The terminal can be any terminal device including a mobile phone, a tablet computer, a personal digital assistant (English full name: Personal Digital Assistant, English abbreviation: PDA), a sales terminal (English full name: Point of Sales, English abbreviation: POS), a car computer, etc., taking the mobile phone as an example:

[0092] Figure 3 The block diagram shows a partial structure of a mobile phone related to the terminal provided in the embodiment of the present application. Figure 3 The mobile phone includes components such as a radio frequency (RF) circuit 1010, a memory 1020, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a wireless fidelity (WiFi) module 1070, a processor 1080, and a power supply 1090. Those skilled in the art will appreciate that Figure 3 The mobile phone structure shown in the figure does not constitute a limitation to the mobile phone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0093] The following combination Figure 3 A detailed introduction to the various components of a mobile phone:

[0094] RF circuitry 1010 can be used to receive and transmit signals during information transmission or calls. Specifically, it receives downlink information from the base station and transmits it to processor 1080 for processing. It also transmits uplink data to the base station. Typically, RF circuitry 1010 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, and more. RF circuitry 1010 can also communicate with the network and other devices via wireless communications. The above-mentioned wireless communications may use any communication standard or protocol, including but not limited to Global System of Mobile Communications (Global System of Mobile communication, English abbreviation: GSM), General Packet Radio Service (English full name: General Packet Radio Service, GPRS), Code Division Multiple Access (English full name: Code Division Multiple Access, English abbreviation: CDMA), Wideband Code Division Multiple Access (English full name: Wideband Code Division Multiple Access, English abbreviation: WCDMA), Long Term Evolution (English full name: Long Term Evolution, English abbreviation: LTE), email, Short Messaging Service (English full name: Short Messaging Service, SMS), etc.

[0095] The memory 1020 can be used to store software programs and modules. The processor 1080 executes the various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area may store data created based on the use of the mobile phone (such as audio data, a phone book, etc.). In addition, the memory 1020 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state memory device.

[0096] The input unit 1030 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit 1030 may include a touch panel 1031 and other input devices 1032. The touch panel 1031, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch panel 1031) and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 1031 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction and detects the signal caused by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 1080. It can also receive commands sent by the processor 1080 and execute them. In addition, the touch panel 1031 can be implemented using various types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch panel 1031, the input unit 1030 may further include other input devices 1032. Specifically, the other input devices 1032 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick.

[0097] The display unit 1040 can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 1040 may include a display panel 1041. Optionally, the display panel 1041 may be configured in the form of a liquid crystal display (English full name: Liquid Crystal Display, English abbreviation: LCD), an organic light-emitting diode (English full name: Organic Light-Emitting Diode, English abbreviation: OLED), etc. Further, the touch panel 1031 may cover the display panel 1041. When the touch panel 1031 detects a touch operation on or near it, it is transmitted to the processor 1080 to determine the type of touch event. Subsequently, the processor 1080 provides corresponding visual output on the display panel 1041 according to the type of touch event. Although in Figure 3 In the embodiment, the touch panel 1031 and the display panel 1041 are used as two independent components to realize the input and output functions of the mobile phone, but in some embodiments, the touch panel 1031 and the display panel 1041 can be integrated to realize the input and output functions of the mobile phone.

[0098] The mobile phone may also include at least one sensor 1050, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1041 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 1041 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that the mobile phone can also be configured with, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be described here.

[0099] Audio circuit 1060, speaker 1061, and microphone 1062 provide an audio interface between the user and the phone. Audio circuit 1060 converts received audio data into electrical signals and transmits them to speaker 1061, which then converts them into sound signals for output. Microphone 1062, on the other hand, converts collected sound signals into electrical signals, which are then received by audio circuit 1060 and converted into audio data. The audio data is then processed by processor 1080 and transmitted to, for example, another phone via RF circuit 1010, or stored in memory 1020 for further processing.

[0100] WiFi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse the web and access streaming media through the WiFi module 1070. It provides users with wireless broadband Internet access. Figure 3 A WiFi module 1070 is shown, but it is understandable that it is not an essential component of the mobile phone and can be omitted as needed without changing the essence of the invention.

[0101] Processor 1080 is the control center of the mobile phone, connecting all parts of the mobile phone using various interfaces and circuits. By running or executing software programs and / or modules stored in memory 1020 and accessing data stored in memory 1020, it performs various functions of the mobile phone and processes data, thereby providing overall monitoring of the mobile phone. Optionally, processor 1080 may include one or more processing units; preferably, processor 1080 may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 1080.

[0102] The mobile phone also includes a power supply 1090 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 1080 through a power management system, thereby managing charging, discharging, and power consumption through the power management system.

[0103] Although not shown, the mobile phone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0104] In the embodiment of the present application, the processor 1080 included in the terminal further has the following functions:

[0105] S1. Create an environment switch file and set the environment name for automated execution in the environment switch file;

[0106] S2. Create a configuration file, name the configuration file after the environment name configured in the environment switch file, and configure access information in a fixed format in the configuration file;

[0107] S3. When executing, the use case reads the environment name of the environment switch file and obtains the corresponding configuration file based on the environment name;

[0108] S4. Read the input parameter data according to the access information configured in the configuration file;

[0109] S5. If the environment for executing the use case needs to be switched, the environment name of the environment switch file is set to the environment name corresponding to the environment after switching, and the process returns to step S3.

[0110] An embodiment of the present application also provides a computer-readable storage medium for storing program code, which is used to execute any implementation of a use case test environment switching method in the aforementioned embodiments.

[0111] In an embodiment of the present application, a method, apparatus, device and storage medium for switching a use case test environment are provided. The environment for automated execution of the use case is set by creating an environment switch file and its environment name, and a corresponding configuration file is created based on the environment name. Access information is configured in a fixed format in the configuration file, so that when the execution environment of the use case is switched, the configuration file with the corresponding name can be called based on the environment name of the environment switch file, and the input parameter data is read according to the access information configured in the configuration file, so that the use case can be automatically input in different execution environments. This solves the problem that the execution of coded automated use cases has a strong dependence on the environment, and the input parameter information and expected return results that are strongly related to the environment required by the use case cannot be shared between different environments, thereby causing the use case to be unable to meet the technical problems of execution in different environments, thereby increasing the maintenance workload of the automated use cases.

[0112] Furthermore, the interface input parameters required for automated test cases in the technical solution provided in the embodiment of the present application can be automatically adapted and generated, reducing the need for testers to synchronously adjust the use case input parameters to adapt to the tested environment due to changes in the environment; the technical solution provided in the embodiment of the present application can reduce the difficulty of number generation for testers, and there is no need to manually generate numbers in the third-party system that each environment depends on. The system will automatically read or generate the data generated by the third-party system required by the use case as input parameters; at the same time, testers do not need to write hard-coded response result assertions, and can automatically calculate and match according to the rules of different input parameters and interface generation results, and can automatically compare whether the response message fields and table information are correct.

[0113] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0114] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0115] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0116] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0117] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0118] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0119] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English full name: Read-Only Memory, English abbreviation: ROM), random access memory (English full name: Random Access Memory, English abbreviation: RAM), disk or optical disk and other media that can store program code.

[0120] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for switching a use case test environment, characterized in that: include: S1. Create an environment switch file, and set the name of the environment for automated execution in the environment switch file; S2. Create a configuration file, name the configuration file with the environment name configured in the environment switch file, and configure access information in a fixed format in the configuration file; S3. When executing, the use case reads the environment name of the environment switch file and obtains the corresponding configuration file according to the environment name; S4. Read input parameter data according to the access information configured in the configuration file; S5, if you need to switch the use case execution environment, the environment name of the environment switch file is set to the environment name corresponding to the environment after the switch, and returns to step S3; The step S4 specifically includes: S41. Obtain first input parameter data through an SQL statement according to the database access information configured in the configuration file; S42, according to the third-party system access information configured in the configuration file, obtain the second input parameter data through the interface address; The step S41 then includes: S411: The expected result response code of the use case and the first input parameter data are passed into the interface test template as map type parameters; S412. Obtain an actual response message for the first input parameter data, where the actual response message includes actual fields, field values ​​contained in the actual fields, and an input parameter response code; S413, according to the input response code and the expected result response code to obtain a response result, the response result includes a successful response and a failed response; S414: If the response result is a successful response, create an expected value corresponding to the actual field according to the source of the field value of the actual response message and the preset field value generation rule.

2. The method for switching a use case test environment according to claim 1, wherein: After step S414, the following steps are further included: S415. parse the actual response message, and compare the results of each actual field of the actual response message with the corresponding expected value. If each actual field of the actual response message is consistent with the corresponding expected value, the use case comparison result passes; otherwise, the use case comparison result fails.

3. The method for switching a use case test environment according to claim 1, wherein: After step S413, the following steps are further included: S416. If the response result is a response failure, the expected result response code of the use case and the actual response result are passed into the interface test template as map type parameters; S417: Generate an expected response message for the use case, where the expected response message includes an expected field, a field value contained in the expected field, and the expected result response code; S418. Compare the expected field, the field value contained in the expected field, and the expected result response code with the actual field, the field value contained in the actual field, and the input parameter response code respectively. If they are all consistent, the use case comparison result passes; otherwise, the use case comparison result fails.

4. The method for switching a use case test environment according to claim 2, wherein: The sources of the field values ​​of the actual response message include interface input parameters, user information and product information in the database, and calculations based on product configuration.

5. The method for switching a use case test environment according to claim 2, wherein: The step of creating the expected value of the corresponding actual field according to the source of the field value of the actual response message and the preset field value generation rule specifically includes: The expected value of the corresponding actual field is obtained from the database according to the source of the field value of the actual response message and the database access information.

6. A use case test environment switching processing device, characterized in that: include: A first creation unit is configured to create an environment switch file, and set an environment name for automated execution in the environment switch file; A second creating unit is configured to create a configuration file, name the configuration file with the environment name configured in the environment switch file, and configure access information in a fixed format in the configuration file; An execution unit, configured to read the environment name of the environment switch file when executing a use case, and obtain the corresponding configuration file according to the environment name; An input parameter unit, configured to read input parameter data according to the access information configured in the configuration file; An environment switching unit for setting the environment name of the environment switch file to the environment name corresponding to the switched environment if the environment for executing the use case needs to be switched, and jumping to the execution unit; The input parameter unit is specifically used for: Obtain the first input parameter data through an SQL statement according to the database access information configured in the configuration file; Obtain the second input parameter data through the interface address according to the third-party system access information configured in the configuration file; After obtaining the first input parameter data through the SQL statement according to the database access information configured in the configuration file, the method further includes: Pass the expected result response code of the use case and the first input parameter data into the interface test template as map type parameters; Obtain an actual response message for the first input parameter data, the actual response message including actual fields, field values ​​contained in the actual fields, and an input parameter response code; Get a response result based on the input response code and the expected result response code, the response result includes a successful response and a failed response; If the response result is a successful response, then based on the source of the field value of the actual response message, an expected value corresponding to the actual field is created according to a preset field value generation rule.

7. A use case test environment switching processing device, characterized in that: The device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the use case test environment switching processing method according to any one of claims 1 to 5 according to the instructions in the program code.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store program code, and the program code is used to execute the use case test environment switching processing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Application test method and apparatus, computer device and storage medium

    CN107908543A

  • Data processing method and device and device for data processing

    CN110858173A