Test method and device, electronic device, computer readable storage medium

By using a gatling testing tool in an asynchronous manner in internet application testing, script address information is obtained and test scripts are executed in a second process. This solves the problems of cumbersome and poor visibility in existing testing methods and achieves efficient test result generation and analysis.

CN116149981BActive Publication Date: 2026-04-24MASHANG 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
MASHANG CONSUMER FINANCE CO LTD
Filing Date
2022-08-18
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Existing internet application testing methods are cumbersome and lack visibility of test results. In particular, performance degrades when there are many concurrent users, resulting in low testing efficiency.

Method used

An asynchronous approach is adopted to obtain the script address information of the test script, start the preset test tool in the first process, and execute the test script in the second process. The target test results are generated by the gatling test tool, reducing manual operation by the user and improving testing efficiency.

Benefits of technology

By asynchronously executing test scripts and automatically generating test results, the testing process is simplified, testing efficiency and visibility are improved, user operations are reduced, and the convenience and efficiency of testing are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116149981B_ABST
    Figure CN116149981B_ABST
Patent Text Reader

Abstract

The application provides a test method and device, electronic equipment and computer readable storage medium. The method comprises: obtaining script address information of a test script to be executed in a first process, the test script being used for testing a target object, and the script address information being information indicating a storage address of the test script; starting a preset test tool through a first target instruction in the first process according to the script address information, and executing the test script based on the preset test tool in a second process to test the target object; and detecting output logs generated when the test script is executed by the preset test tool in the second process in the first process to generate a target test result corresponding to the target object. The embodiments of the application can conveniently and efficiently test the target object and obtain the target test result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of testing technology, and in particular to a testing method and apparatus, electronic equipment, and computer-readable storage medium. Background Technology

[0002] With the continuous development of Internet technology, Internet applications usually need to be developed and iterated rapidly to meet user needs. During the iteration process of Internet applications, each version of the Internet application usually needs to be tested before it is launched, such as functional testing and stress testing, to ensure that the version of the Internet application meets the functional and performance requirements.

[0003] Currently, testing internet applications typically requires users to first write test cases and generate test scripts. Then, users run these test scripts using testing tools to test the application before it goes live. Finally, they manually analyze the test results to determine if the application meets the deployment requirements. This testing method is cumbersome and inconvenient.

[0004] The above example, using an internet application as the object to be tested, illustrates the problems with existing testing methods. It should be noted that this testing method may also suffer from the same issues when the object to be tested is another web object implemented based on HTTP requests. Summary of the Invention

[0005] This application provides a testing method and apparatus, an electronic device, and a computer-readable storage medium to conveniently and efficiently test a target object and obtain test results.

[0006] Firstly, this application provides a testing method, which includes:

[0007] In the first process, the script address information of the test script to be executed is obtained, wherein the test script is used to test the target object, and the script address information is information indicating the storage address of the test script;

[0008] Based on the script address information, the test script is executed in the first process through the first target instruction, and in the second process based on the preset test tool to test the target object;

[0009] In the first process, the output logs generated when the test script is executed by the preset test tool in the second process are detected, and a target test result corresponding to the target object is generated.

[0010] Secondly, this application provides a testing apparatus, which includes:

[0011] The acquisition unit is used to acquire the script address information of the test script to be executed in the first process, wherein the test script is used to test the target object, and the script address information is information indicating the storage address of the test script;

[0012] The execution unit is configured to run the test script in the first process according to the script address information via a first target instruction, and execute the test script in the second process based on the preset test tool to test the target object;

[0013] The detection unit is used to generate a target test result corresponding to the target object by detecting the output logs generated when the test script is executed by the preset test tool in the second process in the first process.

[0014] Thirdly, this application provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the test method described in the first aspect.

[0015] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the test method of the first aspect described above.

[0016] In the embodiments provided in this application, when an electronic device tests a target object, it obtains the script address information of a test script used to test the target object in a first process; based on the script address information, it starts a preset test tool using a first target instruction, and executes the test script based on the preset test tool in a second process; and generates a target test result by detecting the output logs generated when the test script is executed by the preset test tool in the second process in the first process. Since the electronic device can start a second process outside the current first process after starting the preset test tool in the first process using the first target instruction based on the script address information of the test script, and then execute the test script based on the preset test tool in the second process to test the target object, i.e., testing the target object asynchronously, this eliminates the need for the user to manually start the test script. Furthermore, during the execution of the test script based on the preset test tool in the second process, the output logs generated when the test script is executed by the preset test tool are detected in the first process, and the target test result corresponding to the target object is generated based on the output logs after detection, which helps improve testing efficiency.

[0017] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description

[0018] The accompanying drawings are provided to further illustrate the present application and form part of the specification. They are used together with the embodiments of the present application to explain the application and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the detailed example embodiments described with reference to the accompanying drawings, in which:

[0019] Figure 1 A flowchart of a testing method provided in an embodiment of this application;

[0020] Figure 2 A flowchart for generating test scripts provided in this application embodiment;

[0021] Figure 3 This is a schematic diagram of the test script configuration provided in an embodiment of this application;

[0022] Figure 4 A flowchart for obtaining target test results provided in an embodiment of this application;

[0023] Figure 5 A first schematic diagram of the target test results provided in the embodiments of this application;

[0024] Figure 6 A second schematic diagram illustrating the target test results provided in the embodiments of this application;

[0025] Figure 7 A block diagram of a testing apparatus provided in an embodiment of this application;

[0026] Figure 8 This is a block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0027] To enable those skilled in the art to better understand the technical solutions of this application, exemplary embodiments of this application are described below in conjunction with the accompanying drawings, including various details of the embodiments of this application to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0028] Where there is no conflict, the various embodiments of this application and the features thereof may be combined with each other.

[0029] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.

[0030] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application. As used herein, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the stated feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded. Terms such as “connected” or “linked” are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.

[0031] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this application, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined herein.

[0032] In related technologies, when testing target objects—that is, web objects implemented based on HTTP requests, such as internet applications—the automated testing tool JMeter is typically used. This testing method first requires users to write test cases and generate test scripts through numerous complex configuration options. Furthermore, when users run the test scripts on the target object using JMeter, JMeter usually uses one thread to simulate one user's actions. This results in a large number of concurrent threads in the system when there are many simulated users, potentially leading to a decrease in test performance. In addition, the test results generated by JMeter are not very visually appealing and often require professional developers to analyze and understand. Therefore, the testing methods in related technologies are inconvenient and inefficient due to their cumbersome testing steps and poor visibility of test results. Moreover, when the number of concurrent users is high, performance degradation can further reduce testing efficiency.

[0033] To address the above problems, this application provides a testing method, please refer to the embodiments below. Figure 1 This is a flowchart of a testing method provided in an embodiment of this application. The method can be applied to an electronic device, which can be a server, a physical server, or a virtual server. Of course, with the continuous advancement of technology, the electronic device can also be a terminal device; that is, the method can also be applied independently to a terminal device, for example, to an edge terminal device in an edge computing scenario. No special limitation is made here. In this embodiment, unless otherwise specified, the application of the method to a server is used as an example for explanation.

[0034] like Figure 1 As shown, the testing method provided in this application embodiment may include the following steps S101-S103, which will be described in detail below.

[0035] Step S101: Obtain the script address information of the test script to be executed in the first process. The test script is used to test the target object, and the script address information is information indicating the storage address of the test script.

[0036] In computer technology, a process is a single execution of a program on a specific set of data. It is the basic unit for resource allocation and scheduling in a system and forms the foundation of the operating system architecture. In early process-oriented computer architectures, the process was the fundamental execution entity of a program; in current thread-oriented computer architectures, the process is a container for threads. A program is a description of instructions, data, and their organization, while a process is the entity within that program.

[0037] In the embodiments of this application, the first process may be an entity in an operating system used to carry a test program implemented based on the test method of the embodiments of this application, wherein the operating system may be, for example, a Linux operating system.

[0038] The testing script can be a set of instructions that are pre-configured by the user and contain a series of instructions for testing the target object.

[0039] Script address information can be used to indicate the storage address of the test script. This script address information can be an absolute address or a relative address, i.e., a logical address.

[0040] For example, if the script address information is an absolute address, it can be in the form of " / root / home / script / test script name".

[0041] For example, when the script address information is a relative address, it can be in the form of "test script name" or ". / test script name" to indicate that the test script is in the same location as the current first process.

[0042] The target object is a web object implemented based on HTTP requests. It receives HTTP requests sent by the user and responds to those requests through backend logic. The target object can be, for example, an internet application or a specific page within an internet application, such as the login API address of a login page; alternatively, it can also be an internal enterprise application implemented based on an HTTP request or the URL of that application.

[0043] For example, in internet finance applications, to enhance business security, companies typically use financial risk control models to approve loan orders generated by financial applications. These models can be mathematical models that acquire various relevant feature data of the input object to output risk control information, such as a risk control score. The approval process generally involves the financial application using the loan order as the input parameter to call the financial risk control model's API, requesting the model to calculate the risk control score to determine whether to approve the loan order. Since the API call address of the financial risk control model may receive a large number of calls in a short period, the target object in this application scenario can be the API call address corresponding to the financial risk control model.

[0044] For example, in e-commerce application scenarios, the login interface address corresponding to the login page of an e-commerce application or a flash sale page of a product may receive a large number of access requests in a short period of time. Therefore, in order to improve the stability and robustness of the application and avoid system anomalies when such login interface addresses receive a large number of access requests, the target object in this application scenario can be the application page login interface address.

[0045] As explained above, in this embodiment, the target object may include the calling address corresponding to the financial risk control model and / or the application page login interface address. Of course, depending on the application scenario, the target object may also be other web objects implemented based on HTTP requests; no special limitations are made here.

[0046] In this embodiment of the application, obtaining the script address information of the test script to be executed in the first process can be: using the script address information as an input parameter of the test program carried by the first process, and obtaining the script address information by obtaining the input parameter.

[0047] For example, if the test program is written in Shell script and its name is pro01.sh, and the script address is a relative address "script01", the script address can be used as an input parameter during the test program's execution in the operating system via the command ". / pro01.sh script01". Then, in the process corresponding to the test program, the script address can be obtained using the command "set script_name[lindex$argv 0]", where "$argv 0" represents retrieving the first input parameter of the current test program. Of course, in practice, other data can be specified as input parameters for the test program; no special limitations are imposed here.

[0048] After obtaining the script address information of the test script, the test script can be executed to test the target object based on the script address information.

[0049] Step S102: Based on the script address information, a preset test tool is started in the first process through the first target instruction, and a test script is executed in the second process based on the preset test tool to test the target object.

[0050] The first target instruction can be an instruction implemented based on a preset encoded instruction. This preset encoded instruction can be used to asynchronously run an operation object. In this application, the operation object is a preset test tool.

[0051] The second process is a process that is newly launched in the operating system during the operation of the first process based on the first target instruction. It is used to carry an instance of the preset test tool. In the second process, the test script is executed through the preset test tool.

[0052] Considering that in related technologies, when using the JMeter testing tool to run test scripts to test target objects, excessive concurrent threads may cause system performance degradation, complex configuration items, and poor visibility of the test results, this application embodiment selects the Gatling testing tool, an automated testing tool with stronger concurrency, easier configuration, and better visibility of test results in report form, to replace JMeter used in related technologies, in order to solve the above-mentioned problems in related technologies. That is, in this application embodiment, the preset testing tool can be the Gatling testing tool; of course, with the continuous advancement of technology, the preset testing tool can also be other testing tools, which are not specifically limited here.

[0053] In other words, to address the inconvenience and low efficiency of manually running test scripts in JMeter and manually obtaining and analyzing test results when testing target objects in related technologies, this application embodiment addresses this issue. After obtaining the script address information of the test script in the first process currently carrying the test program, during the execution of the first process, a first target instruction can be executed to trigger the operating system in the electronic device to launch a second process carrying an instance of a preset test tool. The second process automatically executes the test script based on the preset test tool to test the target object; that is, the test script is executed asynchronously. Since the test script is executed asynchronously in the first process via the first target instruction, the instruction set in the first process does not need to be blocked during the execution of the test script based on the preset test tool in the newly launched second process. Instead, the test process can be monitored in real time by detecting the output logs generated when the test script is executed by the preset test tool in the second process. Upon completion of the test in the second process, test results are automatically generated based on the relevant log information in the output logs, reducing user operations and improving testing efficiency.

[0054] Step S103: In the first process, detect the output logs generated when the test script is executed by the preset test tool in the second process, and generate the target test result corresponding to the target object.

[0055] The output log refers to the log data output by the preset test tool during the execution of the test script in the second process, which represents information such as test progress and test results.

[0056] The target test results may include information indicating whether the test passed or succeeded, and the response values ​​of the target object during the test, such as response time (RT) and calls per second (QPS).

[0057] As can be seen from the above description, the testing method provided in this application embodiment involves the first process in the electronic device, after obtaining the script address information, starting a second process asynchronously and executing the test script in the second process based on a preset testing tool to test the target object. This method can save users from manually starting the test script while automatically generating the target test result by the electronic device itself detecting the output logs generated when the test script is executed by the preset testing tool in the second process. This further saves users from manually obtaining and analyzing the test results, thereby improving testing efficiency.

[0058] In this embodiment of the application, unless otherwise specified, the example used is a test script for stress testing of a target object. Please refer to... Figure 2 This is a flowchart of the test script generation process provided in the embodiments of this application. Figure 2 As shown in the embodiment of this application, the test script mentioned in step S101 can be obtained through the following steps: Step S201, obtain the script name of the test script, the call address information of the target object, the input parameter information corresponding to the target object, and the scene parameter information corresponding to the test script; Step S202, generate the test script based on the script name, the call address information, the input parameter information, and the scene parameter information.

[0059] The target object's call address information, i.e., the target object's baseurl, can be the Uniform Resource Locator (URL) of the call interface corresponding to the target object, for example, it can be in the form of "http: / / ip address:port".

[0060] The input parameter information corresponding to the target object is the information of the parameters required by the target object at runtime. There are no special restrictions on this input parameter information here. For example, the input parameter information can also be empty.

[0061] The scenario parameter information corresponding to the test script is a parameter used to describe the test scenario of the target object.

[0062] In this embodiment, the scenario parameter information can be at least one of user concurrency, test task execution time, and test result judgment conditions, wherein the test result judgment conditions are the conditions that instruct the testing tool to determine whether the test passes or fails. Preferably, the scenario parameter information can simultaneously include user concurrency, test task execution time, and test result judgment conditions.

[0063] For easier understanding, please refer to Figure 3 This is a schematic diagram of the test script configuration provided in the embodiments of this application. Figure 3 As shown, in this embodiment, the electronic device can provide, for example, at the front end... Figure 3 The method shown allows users to input various configuration parameters for the test script to obtain the script name, call address information, input parameter information, and scenario parameter information.

[0064] For example, it can be like Figure 3 As shown, the script name is "script01", the call address is "http: / / 192.168.xy:8080", and the input parameters are as follows. Figure 3The information shown includes the user concurrency count as "20", the test task execution time as "30 seconds", and the test result judgment condition as "jsonPath("$.code").is("200")". After obtaining the above configuration information, click the "Generate Script" button to obtain the test script.

[0065] It should be noted that, Figure 3 The illustration shown is merely one specific implementation method for obtaining a test script provided in this application. In practice, the test script can also be generated through other methods or by configuring other configuration information, and no special limitation is made here.

[0066] Furthermore, as can be seen from the above description, the first target instruction in step S102 can be an instruction implemented based on a preset encoding instruction, which is used to asynchronously run the operation object. In this embodiment, the step of starting the preset test tool in the first process through the first target instruction according to the script address information, and executing the test script based on the preset test tool in the second process includes: in the first process, starting the preset test tool using the preset encoding instruction, and setting the script address information as the input parameter of the preset test tool, so as to test the target object by executing the test script based on the preset test tool in the second process.

[0067] In this embodiment, the preset encoding instruction can be the spawn instruction in the expect function of the shell encoding language.

[0068] The `spawn` instruction in the `expect` function of the shell programming language is based on the ToolCommand Language (TCL), such as `scp`, `ssh`, and `telnet`. It can be applied to scenarios that automate interactive operations.

[0069] In this embodiment of the application, the first process uses a preset encoding instruction to start a preset test tool and sets the script address information as the input parameter of the preset test tool. The specific program instruction executed can be "spawn shgatling.sh -s$script_name", where gatling.sh is the startup script corresponding to the gatling test tool, and $script_name is the script address information of the test script.

[0070] As can be seen from the above description, in this embodiment of the application, by using a first target instruction similar to "spawn sh gatling.sh -s$script_name" implemented based on the above-mentioned spawn instruction, a second process can be started by the electronic device in the electronic device during the execution of the first process. In the second process, a test script is executed based on a preset test tool. This allows the electronic device to start the gatling test tool in an asynchronous manner, which has stronger concurrency performance, more convenient configuration items, and better test result visibility, to run the test script to test the target object. This saves user operations and greatly improves test efficiency.

[0071] In step S103 above, the detection of the output log generated when the test script is executed by the preset test tool in the second process to generate the target test result corresponding to the target object includes: detecting the output log through the second target instruction in the first process to generate the target test result corresponding to the target object, wherein the second target instruction is the execution that is executed immediately after the first target instruction, and the output log is the log generated during the execution of the test script in the second process.

[0072] That is, since during the process of testing the target object by executing a test script based on an automated testing tool, such as the gatling testing tool used in this application embodiment, after the test script is executed and the target test result, i.e., the test report, is generated, the corresponding output log usually also contains the web address information of the output test report, the first process can detect the output log generated when the test script is executed during the asynchronous execution of the test script, and then generate the target test result based on the log information after outputting the log information corresponding to the target test result in the output log, so as to save user operations.

[0073] Please refer to Figure 4 This is a flowchart of obtaining target test results provided in an embodiment of this application. Figure 4 As shown in the embodiments of this application, the target test result can be obtained through the following steps:

[0074] Step S401: Obtain the first keyword information corresponding to the target test result, wherein the first keyword information is the keyword information corresponding to the state in which the test script is executed normally.

[0075] The first keyword information is essential text information in the log information corresponding to the target test result when the test script is executed normally. For example, considering that the automated testing tool will include the text "results" and "index.html" in its log information after generating the target test result, this keyword information can be "results" and "index.html".

[0076] Step S402: In the scope corresponding to the second target instruction, use the first regular expression to match the first keyword information in the output log.

[0077] The scope of a second target instruction refers to the range of functions that the instruction applies to. Generally, in programming languages, if a programming instruction is not selected using the "{}" symbol, its scope is the range of the statement in which the instruction currently resides; if selected using the "{}" symbol, its scope is the range of the one or more lines of statements selected by that symbol.

[0078] Regular expressions, also known as grammatical expressions, are text patterns that include ordinary characters (such as letters from a to z) and special characters (called "metacharacters"), and are a concept in computer science. Regular expressions use a single string to describe and match a series of strings that match a certain syntax rule, and are typically used to search for and replace text that conforms to a specific pattern (rule).

[0079] The first regular expression described in this application embodiment is used to retrieve whether information matching the first keyword information is stored in the output log.

[0080] Step S403: If the first keyword information is found to exist in the output log based on the first regular expression, the target test result is obtained through the third target instruction according to the first keyword information.

[0081] That is, in the embodiments of this application, during the execution of the test script by the preset test tool in the second process, in the first process, in the scope of the second target instruction corresponding to the first target instruction, i.e. the spawn instruction, the output log of the test script is detected by matching the first keyword information using the first regular expression, so as to detect whether the test script has been executed normally and output the test results in the second process, thereby saving the user from the problems of not being timely and not convenient due to manually viewing the test results.

[0082] The second target instruction can be the expect instruction corresponding to the spawn instruction. That is, after executing the first target instruction implemented using the spawn instruction, the expect instruction corresponding to the spawn instruction is used to detect the corresponding output log in the second process, and the target test result is obtained by using the instruction implemented using the spawn instruction to asynchronously obtain the target test result.

[0083] In this embodiment, obtaining the target test result through the third target instruction in step S403 can be: obtaining the webpage address information corresponding to the target test result based on the first keyword information; obtaining the target test result based on the third target instruction and the webpage address information, wherein the target test result includes: result information indicating whether the test passed, and / or, performance parameter information of the target object, wherein the performance parameter information includes at least one of response time and calls per second.

[0084] The webpage address information refers to the URL address corresponding to the target test result. That is, in this embodiment, the target test result can be provided in the form of a web page. For example, when the preset testing tool is the gatling testing tool, its test result is usually provided in the form of result id / index.html when the test script is executed normally, for example, in the form of "$GATLING_HOME / results / xxxx-id / index.html", where $GATLING_HOME represents the storage address of the gatling testing tool in the electronic device.

[0085] For example, after the first target command "spawn sh gatling.sh -s$script_name", the target test results can be obtained using the following command:

[0086]

[0087] In the above instructions, " / *\ / results\ / (.*)\ / index.html" is the first regular expression used to match the first keyword information "results" and "index.html" in the output log corresponding to the test script; "$expect_out(1,string)" represents the web page address information of the test report obtained by matching; "spawn curl "$report_hook&report_file=$report_file"" is the third target instruction used to obtain the target test result; $report_hook is a pre-obtained URL address used to notify the test service to obtain the target test result, and this URL address can be obtained as an input parameter of the test program.

[0088] The above describes how to detect the corresponding output logs and obtain the target test result during the execution of the test script by the preset test tool in the second process, thereby saving user operations and improving test efficiency. It should be noted that in the above embodiments, after obtaining various information, such as the first keyword information and the target test result information, the information can be output for user viewing via the "send_user" command; and exceptions in the second process can be detected via the exception handling command "-re "Exception in the head" to improve the robustness of the test method and facilitate user error checking; that is, in some embodiments, during the process of detecting the output logs through the second target command to generate the target test result corresponding to the target object, the method may further include: obtaining the second keyword information, wherein the second keyword information is the keyword information corresponding to the case where the test script's execution is abnormal; matching the second keyword information in the output logs using a second regular expression within the scope corresponding to the second target command; and outputting execution exception result information when the second keyword information is found in the output logs based on the second regular expression, wherein the execution exception result information indicates that the test script's execution is abnormal.

[0089] In this implementation, the second keyword information can be "Exception in thead" as described above, and the second regular expression can be "-re"Exception in thead" as described above.

[0090] In some embodiments, after obtaining the target test result based on the method described in any of the above embodiments, the method further includes: displaying the target test result. This is to provide users with more visually appealing test results, making it easier for them to view and decide when the target object is ready for online use.

[0091] Please refer to Figure 5 and Figure 6 These are, respectively, first and second schematic diagrams of the target test results provided in the embodiments of this application. Figure 5 As shown in the embodiments of this application, the target test result may include the target object response time, i.e., the 95th percentile corresponding to RT, i.e. the 95th index. By comparing the 95th index with a preset threshold, it can be determined whether the target object meets the online requirements.

[0092] For example, if the target object is the calling address corresponding to a financial risk control model, and its 95th response time metric is as follows: Figure 5 If the displayed value is 14 milliseconds, which is less than the preset threshold of 1.5 seconds, then the financial risk control model can be determined to meet the requirements for going live.

[0093] like Figure 6 As shown in the embodiments of this application, the target test results may also include the response time distribution of the target object, so that users can view the response time distribution of the target object more intuitively.

[0094] For example, when the target object is the calling address corresponding to a financial risk control model, through Figure 6 As shown, 90% of its response time is distributed between 0 and 10 milliseconds, indicating good performance.

[0095] Of course, in actual implementation, the target test results may also include response curves generated based on the response time of the target object, without any special restrictions here.

[0096] It is understood that the various method embodiments mentioned above in this application can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this application will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.

[0097] In addition, this application also provides a testing device, an electronic device, and a computer-readable storage medium, all of which can be used to implement any of the testing methods provided in this application. The corresponding technical solutions and descriptions are described in the corresponding section of the method and will not be repeated here.

[0098] Figure 7 This is a block diagram of a testing device provided in an embodiment of this application.

[0099] Reference Figure 7 This application provides a testing device 700, which includes an acquisition unit 701, a running unit 702, and a detection unit 703.

[0100] The acquisition unit 701 is used to acquire the script address information of the test script to be executed in the first process, wherein the test script is used to test the target object, and the script address information is information indicating the storage address of the test script.

[0101] In some embodiments, the test script is used to perform stress testing on the target object; the test device 700 further includes a test script generation unit, used to: obtain the script name of the test script, the call address information of the target object, the input parameter information corresponding to the target object, and the scene parameter information corresponding to the test script; and generate the test script based on the script name, call address information, input parameter information, and scene parameter information.

[0102] The execution unit 702 is used to start a preset test tool in the first process through the first target instruction according to the script address information, and execute the test script based on the preset test tool in the second process to test the target object.

[0103] In some embodiments, the first target instruction is an instruction implemented based on a preset encoding instruction, which is used to asynchronously run the operation object; when the running unit 702 starts the preset test tool in the first process according to the script address information through the first target instruction, it can be used to: start the preset test tool in the first process using the preset encoding instruction, and set the script address information as the input parameter of the preset test tool, so as to test the target object by executing the test script based on the preset test tool in the second process.

[0104] The detection unit 703 is used to detect the output logs generated when the test script is executed by the preset test tool in the second process in the first process, so as to generate the target test result corresponding to the target object.

[0105] In some embodiments, when the detection unit 703 detects the output logs generated when the test script is executed by a preset test tool in the second process to generate a target test result corresponding to the target object, it can be used to: detect the output logs in the first process through a second target instruction to generate a target test result corresponding to the target object, wherein the second target instruction is an instruction executed immediately after the first target instruction, and the output logs are logs generated during the execution of the test script in the second process.

[0106] In some embodiments, when the detection unit 703 detects the output log through the second target instruction to generate a target test result corresponding to the target object, it can be used to: obtain the first keyword information corresponding to the target test result, wherein the first keyword information is the keyword information corresponding to the state in which the test script is executed normally; in the scope corresponding to the second target instruction, use a first regular expression to match the first keyword information in the output log; if the first keyword information is found to exist in the output log based on the first regular expression, obtain the target test result through the third target instruction according to the first keyword information.

[0107] In some embodiments, the preset encoding instruction includes the spawn instruction in the expect function of the shell encoding language, the second target instruction includes the expect instruction corresponding to the spawn instruction, and the third target instruction includes an instruction for asynchronously obtaining the target test result based on the spawn instruction. When the detection unit 703 obtains the target test result through the third target instruction, it can be used to: obtain the web page address information corresponding to the target test result according to the first keyword information; obtain the target test result based on the third target instruction and the web page address information, wherein the target test result includes: result information indicating whether the test passed, and / or, performance parameter information of the target object, the performance parameter information including at least one of response time and calls per second.

[0108] In some embodiments, the testing apparatus 700 further includes an exception capture unit, configured to: acquire second keyword information, wherein the second keyword information is keyword information corresponding to the case where the test script has an exception during execution; in the scope corresponding to the second target instruction, use a second regular expression to match the second keyword information in the output log; and if the second keyword information is found to exist in the output log based on the second regular expression, output execution exception result information, wherein the execution exception result information indicates that the test script has an exception during execution.

[0109] Figure 8 This is a block diagram of an electronic device provided in an embodiment of this application.

[0110] Reference Figure 8 This application provides an electronic device 800, which includes: at least one processor 801; at least one memory 802; and one or more I / O interfaces 803 connected between the processor 801 and the memory 802; wherein the memory 802 stores one or more computer programs that can be executed by the at least one processor 801, and the one or more computer programs are executed by the at least one processor 801 to enable the at least one processor 801 to perform the above-described test method.

[0111] This application also provides a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the above-described testing method. The computer-readable storage medium can be volatile or non-volatile.

[0112] This application also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code. When the computer-readable code is run in the processor of an electronic device, the processor in the electronic device executes the above-described test method.

[0113] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer storage media (or non-transitory media) and communication media (or transient media).

[0114] As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technologies, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable program instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0115] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0116] The computer program instructions used to perform the operations of this application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), are personalized by utilizing state information from the computer-readable program instructions. These electronic circuits can execute the computer-readable program instructions to implement various aspects of this application.

[0117] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0118] Various aspects of this application are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0119] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0120] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0121] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0122] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for general illustrative purposes only and should not be construed as limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in conjunction with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in conjunction with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this application as set forth by the appended claims.

Claims

1. A testing method, characterized in that, include: In the first process, the script address information of the test script to be executed is obtained, wherein the test script is used to test the target object, and the script address information is information indicating the storage address of the test script; Based on the script address information, a preset test tool is launched in the first process via a first target instruction, and the test script is executed in the second process based on the preset test tool to test the target object; wherein, the second process is a process newly launched in the operating system by the first process during its operation based on the first target instruction, which is used to carry an instance of the preset test tool; In the first process, the output logs generated when the test script is executed by the preset test tool in the second process are detected, so as to generate target test results corresponding to the target object.

2. The method according to claim 1, characterized in that, The first target instruction is an instruction implemented based on a preset encoded instruction, which is used to asynchronously start the operation object; The step of launching a preset test tool in the first process via a first target instruction based on the script address information includes: In the first process, the preset testing tool is started using the preset encoding instruction, and the script address information is set as the input parameter of the preset testing tool, so that the test script is executed based on the preset testing tool to test the target object in the second process.

3. The method according to claim 2, characterized in that, The step of detecting the output logs generated when the test script is executed by the preset test tool in the second process, in order to generate target test results corresponding to the target object, includes: In the first process, the output log is detected by the second target instruction to generate the target test result corresponding to the target object, wherein the second target instruction is the instruction executed immediately after the first target instruction, and the output log is the log generated during the execution of the test script in the second process.

4. The method according to claim 3, characterized in that, The step of detecting the output log through the second target instruction to generate the target test result corresponding to the target object includes: Obtain the first keyword information corresponding to the target test result, wherein the first keyword information is the keyword information corresponding to the state in which the test script is executed normally; Within the scope corresponding to the second target instruction, the first regular expression is used to match the first keyword information in the output log; If the first keyword information is found to exist in the output log based on the first regular expression, the target test result is obtained through the third target instruction according to the first keyword information.

5. The method according to claim 4, characterized in that, The preset encoding instruction includes the spawn instruction in the expect function of the shell encoding language, the second target instruction includes the expect instruction corresponding to the spawn instruction, and the third target instruction includes an instruction based on the spawn instruction for asynchronously obtaining the target test result; The process of obtaining the target test result through the third target instruction includes: Based on the first keyword information, obtain the webpage address information corresponding to the target test result; Based on the third target instruction and the webpage address information, the target test result is obtained, wherein the target test result includes: result information indicating whether the test passed, and / or, performance parameter information of the target object, wherein the performance parameter information includes at least one of response time and calls per second.

6. The method according to claim 4, characterized in that, The method further includes: In the process of detecting the output log through the second target instruction to generate the target test result corresponding to the target object, the second keyword information is obtained, wherein the second keyword information is the keyword information corresponding to the case where the test script has an abnormality in its execution; Within the scope corresponding to the second target instruction, a second regular expression is used to match the second keyword information in the output log; If the second keyword information is found in the output log based on the second regular expression, an abnormal execution result is output, wherein the abnormal execution result indicates that the test script is abnormal.

7. The method according to claim 1, characterized in that, The test script is used to perform stress testing on the target object; the test script is obtained through the following steps: Obtain the script name of the test script, the call address information of the target object, the input parameter information corresponding to the target object, and the scene parameter information corresponding to the test script; The test script is generated based on the script name, the call address information, the input parameter information, and the scene parameter information.

8. A testing device, characterized in that, include: The acquisition unit is used to acquire the script address information of the test script to be executed in the first process, wherein the test script is used to test the target object, and the script address information is information indicating the storage address of the test script; The execution unit is configured to, according to the script address information, launch a preset test tool in the first process via a first target instruction, and execute the test script based on the preset test tool in the second process to test the target object; wherein, the second process is a process newly launched in the operating system by the first process during its operation based on the first target instruction, and is used to carry an instance of the preset test tool; The detection unit is used to detect the output logs generated when the test script is executed by the preset test tool in the second process in the first process, and generate target test results corresponding to the target object.

9. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the test method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the test method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Electronic equipment testing method and device, electronic equipment and storage medium

    CN112612664A