Automatic testing method, device, system, equipment and medium
By deploying business business scripts and base method scripts on the executor and the test host respectively, and managing these scripts with Github, the problem of low execution efficiency in existing automated test methods is solved, efficient automated test communication is achieved, and testing efficiency is improved.
Patent Information
- Application Number
- CN202411792099.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-05-30
AI Technical Summary
In the existing automated testing methods, the executor needs to transmit a large amount of information to the test host, resulting in wasted network communication resources and thus reducing test efficiency.
By deploying business business scripts and base method scripts on the executor and the test host respectively, using Github to store and manage these scripts, efficient communication between the executor and the test host is achieved and unnecessary network communication is reduced.
It effectively saves network communication resources between the executor and the test host during the automated testing process, improves testing efficiency, and solves the problem of low execution efficiency in the existing technology.
Smart Images

Figure CN120066947A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to testing technologies, and more particularly to an automated testing method, apparatus, system, device, and medium. Background Art
[0002] Automated testing is a software testing method that uses automated testing frameworks, test scripts, and test tools to execute test cases to verify whether the functions, performance, security, and other aspects of the software meet expectations.
[0003] The automated testing methods provided by the prior art mainly include: using an execution machine to perform automated testing on a test host. Specifically, the test script is deployed on the execution machine, and the task scheduler on the execution machine is responsible for scheduling and executing the script, establishing a connection with the host, sending commands, and implementing the use case step processing logic in the script on the execution machine.
[0004] However, in the above method, the test script is deployed on the execution machine, and the execution machine sends test commands to the test host according to the test script for testing. Affected by factors such as network latency, the execution efficiency may be low. Summary of the Invention
[0005] Embodiments of the present application propose an automated testing method, apparatus, system, device, and medium to solve the problem of low execution efficiency of the execution machine for performing automated testing on the test host.
[0006] In a first aspect, embodiments of the present application provide an automated testing method applied to an execution machine, the method including:
[0007] Obtain a business script for automated testing from Github;
[0008] Establish a communication connection with the test host;
[0009] Trigger the flask application service of the test host to start listening. The flask application service is implemented by a base method script, and the base method script is obtained by the test host from the Github;
[0010] Create an http connection instance with the test host according to the business script;
[0011] Send an http request to the test host through the http connection instance. The http request carries test cases, and the test cases are set by the business script;
[0012] Receive the test results returned by the test host, where the test results are obtained by the test host executing the test cases and encapsulated according to the base method script.
[0013] In a second aspect, an embodiment of the present application provides an automated testing method applied to a test host. The method includes:
[0014] Obtain the base method script for automated testing from Github;
[0015] Establish a communication connection with the executor;
[0016] Trigger the flask application service to pull up the listening according to the base method script;
[0017] Create an http connection instance with the executor. The http connection instance is initiated and created by the executor according to the business script, and the business script is obtained by the executor from the Github;
[0018] Receive the http request sent by the executor through the http connection instance through the flask application service, and parse the test cases from the http request. The test cases are set by the business script;
[0019] Execute the test cases, obtain the test results, encapsulate the test results using the base method script, and return them to the executor.
[0020] In a third aspect, an embodiment of the present application provides an automated testing device applied to an executor. The device includes:
[0021] A business script acquisition module for obtaining the business script for automated testing from Github;
[0022] A communication connection module for establishing a communication connection with the test host;
[0023] A trigger module for triggering the flask application service of the test host to pull up the listening. The flask application service is implemented by the base method script, and the base method script is obtained by the test host from the Github;
[0024] An http connection instance creation module for creating an http connection instance with the test host according to the business script;
[0025] A sending module, configured to send an HTTP request to the test host through the HTTP connection instance, where the HTTP request carries a test case, and the test case is set by the business service script;
[0026] A receiving module, configured to receive a test result returned by the test host, where the test result is obtained by the test host executing the test case and is encapsulated and generated according to the base method script;
[0027] In a fourth aspect, an embodiment of the present application provides an automated testing device applied to a test host. The device includes:
[0028] A base method script acquisition module, configured to obtain a base method script for automated testing from Github;
[0029] A communication connection module, configured to establish a communication connection with an execution machine;
[0030] A triggering module, configured to trigger a flask application service to start listening according to the base method script;
[0031] An HTTP connection instance creation module, configured to create an HTTP connection instance with the execution machine, where the HTTP connection instance is initiated and created by the execution machine according to a business service script, and the business service script is obtained by the execution machine from the Github;
[0032] A receiving module, configured to receive, through the flask application service, an HTTP request sent by the execution machine through the HTTP connection instance, and parse the test case from the HTTP request, where the test case is set by the business service script;
[0033] A sending module, configured to execute the test case, obtain a test result, encapsulate the test result using the base method script, and return it to the execution machine.
[0034] In a fifth aspect, an embodiment of the present application provides an automated testing system. The system includes:
[0035] Github, configured to store and manage business service scripts and base method scripts;
[0036] An execution machine, which is used to obtain the business script for the business from the Github, establish a communication connection with the test host, trigger the flask application service of the test host to start listening, create an http connection instance with the test host according to the business script, and send an http request to the test host through the http connection instance. The http request carries test cases, and the test cases are set by the business script, and receive the test results returned by the test host;
[0037] The test host is used to obtain the base method script from the Github, trigger the flask application service to start listening according to the base method script, receive the http request through the flask application service, parse the test cases from the http request, execute the test cases, obtain the test results, encapsulate the test results using the base method script, and return them to the execution machine.
[0038] In a sixth aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device, on which one or more programs are stored. When the one or more programs are executed by the one or more processors, the one or more processors implement the methods described in any one of the first aspect and the second aspect.
[0039] In a seventh aspect, an embodiment of the present application provides a computer-readable medium, on which a computer program is stored. When the program is executed by a processor, it implements the methods described in any one of the first aspect and the second aspect.
[0040] The automated testing method, device, system, equipment, and medium provided by the embodiments of the present application are used for automated testing scripts including two: business scripts and base method scripts. Among them, the business scripts are deployed on the execution machine, and the base method scripts are deployed on the test host, so that the execution machine does not need to transmit too much information during the process of automated testing of the test host, such as information related to the flask application service, etc., thus saving the network communication resources between the execution machine and the test during the automated testing process and improving the execution efficiency of the automated testing process. It solves the problem that the existing testing scripts are all deployed on the execution machine, resulting in low execution efficiency of the execution machine for automated testing of the test host. In addition, since the technical solution provided by the embodiments of the present application is implemented based on the python flask framework, it makes up for the defect that interactive scripts cannot be developed based on python modules when the execution machine and the test host are separated, and is compatible with the shell, cmd, and powershell commands on the test host side in the existing automated testing. The functional scenarios of the test host for automated testing are horizontally extended through python modules (built-in, extended, custom, open-source toolkits), and it has the advantages of separated automation. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] By reading the detailed description of the non-restrictive embodiments with reference to the following drawings, other features, purposes, and advantages of the present application will become more obvious:
[0042] Figure 1 is a flowchart of an embodiment of the automated testing method of the present application;
[0043] Figure 2 is a flowchart of another embodiment of the automated testing method of the present application;
[0044] Figure 3 is a schematic structural diagram of an embodiment of the automated testing device of the present application;
[0045] Figure 4 is a schematic structural diagram of another embodiment of the automated testing device of the present application;
[0046] Figure 5 is a schematic structural diagram of an embodiment of the automated testing system of the present application;
[0047] Figure 6 is a schematic structural diagram of the electronic device for implementing the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0048] All actions of obtaining signals, information, or data in this application are carried out on the premise of complying with the corresponding data protection regulations and policies of the country where it is located and with the authorization given by the owner of the corresponding device.
[0049] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention and do not limit the invention. Additionally, it should be noted that for ease of description, only parts related to the relevant invention are shown in the drawings.
[0050] It should be noted that, without conflict, the embodiments in this application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and embodiments.
[0051] Please refer to Figure 1 , which shows a flow 100 of an embodiment of the automation method according to the present application. The automation test method can be applied to an execution machine, and the execution machine can be applied to various electronic devices with data processing functions. For example, the above-mentioned electronic devices may include, but are not limited to, cloud servers, physical servers, etc. The execution subject of the automation test method can be a processor in the above-mentioned electronic device.
[0052] As Figure 1 shown, the method for collecting switch configuration information includes the following steps:
[0053] Step 101: Obtain business scripts for automated testing from Github.
[0054] In this embodiment, GitHub is an online hosting platform based on Git, providing a series of collaboration tools for open-source projects and individual developers, such as code review, issue tracking, project management, Wiki pages, etc. GitHub also provides a graphical user interface, making it easier for users to use the functions of Git.
[0055] Among them, Git is an open-source distributed version control system that allows developers to track and manage the source code history and supports collaborative development by multiple people. The core functions of Git include version control, branch management, merging, and conflict resolution, etc.
[0056] In this embodiment, Github is used to store and manage scripts for automated testing. The scripts include: business scripts and base method scripts. Since GitHub can provide various security measures to protect users' code and data, for example, increasing account security through two-factor authentication and using encryption technology to protect data transmission, etc., the use of GitHub in this application embodiment to store and manage business scripts and base method scripts has higher security.
[0057] In this embodiment, the business scripts and base method scripts can be written by users on the script development terminal and uploaded to Github by the script development terminal, specifically to the code repository managed by Github.
[0058] In this embodiment, a Jenkins project can be deployed on the execution host, and step 101 can use Jenkins to obtain business scripts from Github.
[0059] In this embodiment, a Jenkins project refers to a software project built and managed using the open-source automation server Jenkins. Jenkins is an open-source continuous integration and continuous delivery (CI / CD) tool that can automate the building, testing, and deployment of software projects.
[0060] Exemplarily, the method for deploying a jenkins project on an execution machine may include:
[0061] 1. Prepare the environment
[0062] Install JDK: Jenkins is developed based on Java, so a JDK environment needs to be installed.
[0063] Install Git / SVN client: Used to pull code from the code repository.
[0064] Install Maven client: If the project uses the Maven build tool, then Maven needs to be installed.
[0065] 2. Download and install Jenkins
[0066] Visit the Jenkins official website to download the war package.
[0067] Deploy the war package to a web server such as Tomcat to run, or directly run `java -jar jenkins.war --httpPort=8080` in the command line to start the Jenkins service.
[0068] 3. Configure Jenkins
[0069] Open the browser and enter the Jenkins web interface, usually `http: / / localhost:8080` or the specified port.
[0070] Complete the initial setup according to the prompts, including setting the administrator password, selecting recommended plugins to install, etc.
[0071] 4. Create a Jenkins task
[0072] After logging in to Jenkins, click "New Item" and enter the task name.
[0073] On the task configuration page, fill in the source code management information, such as the Git repository address and authentication information.
[0074] Configure the build trigger, for example: select "GitHub hook trigger for GITScm polling" to trigger the build via Webhook.
[0075] Write the build script, usually using a Shell script to perform operations such as compilation, testing, packaging, and deployment.
[0076] 5. Deploy the application
[0077] According to the project requirements, configure the deployment environment, such as the path on the Linux server, scripts to start and stop the project, etc.
[0078] Configure post-build actions in the Jenkins task, specify to send the build artifacts (such as war packages) to the target server, and execute the deployment script.
[0079] 6. Test and optimize
[0080] After the deployment is completed, perform functional testing and performance testing to ensure the application runs properly.
[0081] According to the test results and actual requirements, optimize and adjust the Jenkins task and deployment process.
[0082] Of course, the above is only an example of deploying a Jenkins project. In the actual usage process, the Jenkins project can be deployed according to requirements.
[0083] In this embodiment, the business script can be a business script (business script) based on the unitest or pytest framework, usually a test script for automating the testing of specific business logic. These scripts will simulate user operations, verify the correctness of the business process, and ensure that the business requirements of the software are met.
[0084] In this embodiment, the business script has two main functions:
[0085] One part is: the definition of the http connection class and methods in the business framework, as well as the definition of the external operation class and methods.
[0086] The other part is: providing the implementation steps of test cases.
[0087] Exemplarily, the implementation steps of test cases may include:
[0088] The business framework defines the http connection class methods, encapsulates the operations required by the test case steps as methods, combines restful requests in the methods, sends requests and processes responses. This step can be regarded as the atomic operation of the test case steps.
[0089] According to the requirements of the test case, call the http connection class methods to form the test case steps.
[0090] In this embodiment, the base method script has two main functions:
[0091] One part is: starting the flask service to listen, request routing, and request response.
[0092] The other part is: providing method implementation.
[0093] In this embodiment, the method implementation needs to extract the operations of the test host and encapsulate them as python functions. The method implementation can include 3 categories, namely: commands on the test host side, methods of built-in and extended python modules, and methods of python custom modules and open-source toolkits.
[0094] For operations such as process memory, CPU, and disk on the host side, directly call shell commands, \powershell commands, \cmd commands and process the results. If python modules and toolkits are required, introduce encapsulation according to the disassembly requirements of the test case steps. The execution results can directly return data in json format, or call the host command ConvertFrom-Json to convert the format, use python to perform regular extraction on the command results and then convert the format, and return to the executor.
[0095] Step 102: Establish a communication connection with the test host.
[0096] In this embodiment, step 102 can establish a communication connection with the test host using the Secure Shell (SSH) protocol and / or the Telecommunication Network Protocol (Telnet).
[0097] In this embodiment, SSH is an encrypted protocol that can provide secure data transmission. It uses technologies such as public-key encryption and key exchange to ensure that data is encrypted during transmission, thereby protecting user privacy and data security.
[0098] In this embodiment, Telnet is a plaintext protocol, and all data is transmitted in plaintext. It only supports authentication based on username and password, and the transmitted data is plaintext.
[0099] In summary, in step 102, either SSH or Telnet can be used to establish a communication connection with the test host.
[0100] Step 103: Trigger the flask application service on the test host to start listening. The flask application service is implemented by the base method script, and the base method script is obtained by the test host from Github.
[0101] Step 104: Create an http connection instance with the test host according to the business script.
[0102] In this embodiment, the execution machine can specify the host IP of the test host and the flask listening port on the test host to create an http connection instance from the execution machine to the host. Among them, the http connection class is defined in the business script business framework of the business.
[0103] Step 105: Send an http request to the test host through the http connection instance. The http request carries test cases, and the test cases are set by the business script.
[0104] In this embodiment, if automated testing operations need to be performed on the test host, then step 105 calls the http connection instance method of the test host. The methods are all defined and implemented in the class. For example: open a file on the test host, host1_app.openfile(filepath, openflag). In the openfile method, combine the restful request: instance IP, instance port, OS, method, parameters, and send an http request to the test host.
[0105] Step 106: Receive the test results returned by the test host. The test results are obtained by the test host executing test cases and are encapsulated and generated according to the base method script.
[0106] Optionally, in this embodiment, after step 102 and before step 103, it may further include: checking whether the base method script and tools in the test host are the latest versions, and sending an update instruction to the test host.
[0107] Through the above steps, it can be ensured that the test host checks whether the base method script and tools are the latest versions each time automated testing is performed, thereby avoiding problems such as incomplete or inaccurate testing caused by outdated versions of the base method script and tools.
[0108] The automated testing method provided by the embodiments of the present application uses two scripts for automated testing: the business script and the base method script. Among them, the business script is deployed on the execution machine, and the base method script is deployed on the test host, so that the execution machine does not need to transmit excessive information during the process of performing automated testing on the test host, such as information related to the flask application service, etc., thereby saving network communication resources between the execution machine and the test during the automated testing process and improving the execution efficiency of the automated testing process. This solves the problem that the execution efficiency of the existing technology for the execution machine to perform automated testing on the test host is relatively low because all test scripts are deployed on the execution machine. In addition, since the technical solution provided by the embodiments of the present application is implemented based on the python flask framework, it makes up for the defect in the prior art that it is impossible to develop interactive scripts based on python modules when the execution machine and the test host are separated, and is compatible with the shell, cmd, and powershell commands on the test host side in the automated testing provided by the prior art. It horizontally expands the functional scenarios of the test host's automated testing through python modules (built-in, extended, custom, open-source toolkits), and has the advantages of separated automation.
[0109] Please refer to Figure 2 , which shows the process 200 of another embodiment of the automated method according to the present application. This automated testing method can be applied to a test host, and the test host can be applied to various electronic devices with data processing functions. For example, the above-mentioned electronic devices may include, but are not limited to, cloud servers, physical servers, etc. The execution subject of this automated testing method can be the processor in the above-mentioned electronic device.
[0110] As Figure 2 shown, the method for collecting switch configuration information includes the following steps:
[0111] Step 201: Obtain the base method script for automated testing from Github.
[0112] Step 202: Establish a communication connection with the execution machine.
[0113] Step 203: Trigger the flask application service to start listening according to the base method script.
[0114] Step 204: Create an http connection instance with the execution machine. The http connection instance is created by the execution machine according to the business script, and the business script is obtained by the execution machine from Github.
[0115] Step 205: Receive the http request sent by the execution machine through the http connection instance via the flask application service, and obtain the test case by parsing the http request. The test case is set by the business script.
[0116] Step 206: Execute the test case, obtain the test result, encapsulate the test result using the base method script, and return it to the execution machine.
[0117] In this embodiment, after the flask application service on the test host receives the http request, it parses the URL and routes it to the function under the OS. For example, for the openfile method, it calls the open method of python Fcntl to open the file and returns the file handle, and returns the file handle as the response to the execution machine.
[0118] Optionally, after step 202 and before step 203, the following steps may also be included:
[0119] Receive the update instruction sent by the execution machine, and check whether the base method script and the tool are the latest versions.
[0120] In the case where the base method script is not the latest version, obtain the latest version of the base method script from Github; and / or,
[0121] In the case where the tool is not the latest version, obtain the latest version of the tool from the File Transfer Protocol (FTP) tool repository.
[0122] Through the above steps, the test host can check whether the base method script and the tool are the latest versions every time automated testing is performed, thus avoiding the problem of incomplete or inaccurate testing caused by outdated versions of the base method script and the tool.
[0123] The automated testing method provided in this embodiment is the same asFigure 1 corresponding to the automated test method shown, for its specific implementation and description, reference can be made to Figure 1 the automated test method shown, which will not be elaborated here.
[0124] The automated test method provided by the embodiments of the present application uses two scripts for automated testing: the business script and the base method script. Among them, the business script is deployed on the execution machine, and the base method script is deployed on the test host, so that the execution machine does not need to transmit too much information during the process of automated testing of the test host, such as information related to the flask application service, etc., thus saving the network communication resources between the execution machine and the test during the automated testing process and improving the execution efficiency of the automated testing process. It solves the problem that the test scripts in the prior art are all deployed on the execution machine, resulting in low execution efficiency of the execution machine for automated testing of the test host. In addition, since the technical solution provided by the embodiments of the present application is implemented based on the python flask framework, it makes up for the defect that interactive scripts cannot be developed based on python modules when the execution machine and the test host are separated, and is compatible with the shell, cmd, and powershell commands on the test host side in the automated testing provided by the prior art. The functional scenarios of the automated testing of the test host are horizontally extended through python modules (built-in, extended, custom, open-source toolkits), and it has the advantages of separated automation.
[0125] In order to enable those skilled in the art to more clearly understand the above Figure 1 and Figure 2 the automated test method provided by the embodiments shown, the following will be described through specific examples.
[0126] Apply Figure 1 and Figure 2 The method for automated testing using the technical solutions shown may include:
[0127] 1. The execution machine issues a command to Host 1 through an ssh connection: start the flask application service and listen on port xxx.
[0128] 2. The execution machine creates an http connection instance from the execution machine to Host 1: specify the IP of Host 1 and the flask listening port xxx on Host 1.
[0129] 3. The execution machine calls the http instance method openfile: form an http request according to the IP of Host 1, the flask listening port on Host 1, the name of the openfile method defined in the base script, and the parameters (file path to be opened filepath, file opening method openflag), and send it to Host 1.
[0130] 4. The host 1 receives an http request, parses the request, routes it to the openfile method. In the method, the open method of pythonFcntl is used to open the file to obtain a handle, and the status and the handle are returned to the executor.
[0131] 5. The executor calls the http instance method lockfile: According to the IP of the host 1, the flask listening port on the host 1, the lockfile method name defined in the base script, and the parameters (file handle filehandle, locking method lockflag, locking range lockrange), an http request is formed and sent to the host 1.
[0132] 6. The host 1 receives the http request, parses the request, routes it to the lockfile method. In the method, the lock method of pythonFcntl is used to lock the file, and the status is returned to the executor.
[0133] 7. Continue to repeat the above steps 1-6 on the host 2, host 3... host N to test the interactive lock service of the host 1, host 2, host 3... host N.
[0134] The technical solution provided by the above embodiments can connect multiple hosts and use the Python lock module and host-side commands to perform interactive lock service tests; in the automation solution provided by the prior art, by connecting to the linux host through ssh, it is impossible to complete calling the python module to lock, return the file handle, and continue to hold the handle in the same process to lock and unlock and close the file, and during the period of holding the relevant handle and lock, continue to serially or parallelly operate other hosts or execute external steps according to the requirements of the use case.
[0135] All kinds of custom or open-source python modules and toolkits can be used in this framework to implement interactive tests, making up for the functions that the host-side commands are not sufficient to support testing. For example, host encryption and decryption, security inspection and protection, message construction and parsing can all be implemented through this framework.
[0136] Please refer to Figure 3 , as an implementation of the methods shown in the respective figures, the present application provides an embodiment of an automated test device. This device embodiment corresponds to the methods shown in the above Figure 1 embodiments, and this device can be specifically applied to various electronic devices.
[0137] As Figure 3 shown, the automated test device 300 of this embodiment includes:
[0138] The business script acquisition module 301 is used to obtain business scripts for automated testing from Github;
[0139] The communication connection module 302 is used to establish a communication connection with the test host;
[0140] The trigger module 303 is used to trigger the flask application service of the test host to start listening. The flask application service is implemented by the base method script, and the base method script is obtained by the test host from the Github;
[0141] The http connection instance creation module 304 is used to create an http connection instance with the test host according to the business script;
[0142] The sending module 305 is used to send an http request to the test host through the http connection instance. The http request carries test cases, and the test cases are set by the business script;
[0143] The receiving module 306 is used to receive the test results returned by the test host. The test results are obtained by the test host executing the test cases and are encapsulated and generated according to the base method script.
[0144] Optionally, the automated testing device 300 in this embodiment may further include:
[0145] The novelty search module is used to check whether the base method script and tools in the test host are the latest versions and send an update instruction to the test host.
[0146] Optionally, the business script is used for:
[0147] Defining http connection classes and methods, as well as external operation classes and methods in the business framework; and providing test case implementation steps;
[0148] Among them, the test case implementation steps include:
[0149] The business framework defines http connection class methods, encapsulates the operations required by the test case steps as methods, combines restful requests in the methods, sends the requests, and processes the responses;
[0150] According to the requirements of the test cases, call the http connection class methods to form test case steps.
[0151] The automated testing device provided by the embodiments of the present application uses two scripts for automated testing: the business script and the base method script. Among them, the business script is deployed on the execution machine, and the base method script is deployed on the test host. During the process of the execution machine performing automated testing on the test host, there is no need to transmit excessive information, such as information related to the flask application service, etc., thus saving the network communication resources between the execution machine and the test during the automated testing process and improving the execution efficiency of the automated testing process. It solves the problem that the test scripts in the prior art are all deployed on the execution machine, resulting in a low execution efficiency of the execution machine for performing automated testing on the test host. In addition, since the technical solution provided by the embodiments of the present application is implemented based on the python flask framework, it makes up for the defect that an interactive script cannot be developed based on the python module when the execution machine and the test host are separated, and is compatible with the shell, cmd, and powershell commands on the test host side in the automated testing provided by the prior art. The functional scenarios of the automated testing of the test host are horizontally extended through python modules (built-in, extended, custom, open-source toolkits), and it has the advantages of separated automation.
[0152] Please refer to Figure 4 , as an implementation of the methods shown in the respective figures, the present application provides another embodiment of an automated testing device. This device embodiment corresponds to the method shown in the above Figure 2 embodiment, and this device can be specifically applied to various electronic devices.
[0153] As Figure 4 shown, the automated testing device 400 of this embodiment includes:
[0154] The base method script acquisition module 401 is used to acquire the base method script for automated testing from Github;
[0155] The communication connection module 402 is used to establish a communication connection with the execution machine;
[0156] The trigger module 403 is used to trigger the flask application service to start listening according to the base method script;
[0157] The http connection instance creation module 404 is used to create an http connection instance with the execution machine. The http connection instance is initiated and created by the execution machine according to the business script, and the business script is acquired by the execution machine from the Github;
[0158] A receiving module 405, configured to receive, through the flask application service, an http request sent by the executor through the http connection instance, and parse a test case from the http request, where the test case is set by the business business script;
[0159] A sending module 406, configured to execute the test case, obtain a test result, encapsulate the test result using the base method script, and return it to the executor.
[0160] Optionally, the automated test device 400 of this embodiment may further include:
[0161] An update module, configured to receive an update instruction sent by the executor, and check whether the base method script and the tool are the latest versions; in the case where the base method script is not the latest version, obtain the latest version of the base method script from the Github; and / or, in the case where the tool is not the latest version, obtain the latest version of the tool from the File Transfer Protocol (FTP) tool repository.
[0162] Optionally, the base method script is used for:
[0163] Pulling up a flask service for listening, request routing, and request response; and,
[0164] Providing implementation methods, including: test host - side commands, python built - in and extended module methods, as well as python custom module and open - source toolkit methods.
[0165] The automated testing device provided by the embodiment of the present application uses two scripts for automated testing: the business script and the base method script. Among them, the business script is deployed on the execution machine, and the base method script is deployed on the test host, so that the execution machine does not need to transmit too much information during the process of automated testing of the test host, such as information related to the flask application service, etc., thus saving the network communication resources between the execution machine and the test during the automated testing process and improving the execution efficiency of the automated testing process. This solves the problem that the test scripts in the prior art are all deployed on the execution machine, resulting in a low execution efficiency of the execution machine for automated testing of the test host. In addition, since the technical solution provided by the embodiment of the present application is implemented based on the python flask framework, it makes up for the defect in the prior art that an interactive script cannot be developed based on the python module when the execution machine and the test host are separated, and is compatible with the shell, cmd, and powershell commands on the test host side in the automated testing provided by the prior art. The functional scenarios of the automated testing of the test host are horizontally extended through python modules (built-in, extended, custom, open-source toolkits), and it has the advantages of separated automation.
[0166] Please refer to Figure 5 , as an implementation of the methods shown in the respective figures, the present application provides an embodiment of an automated testing system. This system embodiment corresponds to the methods shown in the above embodiments, and the respective components of this system can be specifically applied to various electronic devices.
[0167] As Figure 5 shown, the automated testing system 500 of this embodiment includes:
[0168] Github501, which is used to store and manage the business script and the base method script;
[0169] The execution machine 502 is used to obtain the business script from the Github501, establish a communication connection with the test host 503, trigger the flask application service of the test host 503 to pull up the listening, create an http connection instance with the test host according to the business script, send an http request to the test host 503 through the http connection instance, the http request carries the test case, the test case is set by the business script, and receive the test result returned by the test host 503;
[0170] The test host 503 is used to obtain the base method script from the Github 501, trigger the flask application service to pull up the listening according to the base method script, receive the http request through the flask application service, parse the test cases from the http request, execute the test cases, obtain the test results, encapsulate the test results using the base method script, and return them to the executor 502.
[0171] Optionally, the test host 502 is further used to send an update instruction to the test host 503;
[0172] The test host 503 is further used to receive the update instruction, check whether the base method script and the tool are the latest versions; in the case where the base method script is not the latest version, obtain the latest version of the base method script from the Github; and / or, in the case where the tool is not the latest version, obtain the latest version of the tool from the File Transfer Protocol (FTP) tool repository.
[0173] Optionally, the business script is used for:
[0174] Defining http connection classes and methods, as well as external operation classes and methods in the business framework; and providing the implementation steps of the test cases;
[0175] Among them, the implementation steps of the test cases include:
[0176] In the business framework, defining http connection class methods, encapsulating the operations required by the test case steps into methods, combining restful requests in the methods, sending down the requests and processing the responses;
[0177] According to the requirements of the test cases, calling the http connection class methods to form the test case steps.
[0178] Optionally, the base method script is used for:
[0179] Pulling up the listening of the flask service, request routing, and request response; and,
[0180] Providing implementation methods, including: commands on the test host side, methods of built-in and extended python modules, as well as methods of python custom modules and open-source toolkits.
[0181] The automated test system provided by the embodiments of the present application includes two scripts for automated testing: the business script and the base method script. Among them, the business script is deployed on the execution machine, and the base method script is deployed on the test host, so that the execution machine does not need to transmit excessive information during the process of automated testing of the test host, such as information related to the flask application service, etc., thus saving the network communication resources between the execution machine and the test during the automated testing process and improving the execution efficiency of the automated testing process. It solves the problem that the test scripts in the prior art are all deployed on the execution machine, resulting in low execution efficiency of the execution machine for automated testing of the test host. In addition, since the technical solution provided by the embodiments of the present application is implemented based on the python flask framework, it makes up for the defect that interactive scripts cannot be developed based on python modules when the execution machine and the test host are separated, and can be compatible with the shell, cmd, and powershell commands on the test host side in the automated testing provided by the prior art. The functional scenarios of the automated testing of the test host are horizontally extended through python modules (built-in, extended, custom, open-source toolkits), and it has the advantages of separated automation.
[0182] The following refers to Figure 6 , which shows a schematic structural diagram of an electronic device for implementing some embodiments of the present application. Figure 6 The shown electronic device is only an example and should not bring any limitation to the functions and usage scope of the embodiments of the present application.
[0183] As Figure 6 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0184] Generally, the following devices can be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a disk, a hard disk, etc.; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6An electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had. Figure 6 Each block shown in Figure 6 may represent a device or, as needed, multiple devices.
[0185] In particular, according to some embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of the present application include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program contains program code for performing the methods shown in the flowcharts. In such some embodiments, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, the above-mentioned functions defined in the methods of some embodiments of the present application are performed.
[0186] It should be noted that the computer-readable medium described in some embodiments of the present application may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present application, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in some embodiments of the present application, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0187] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.
[0188] The above computer-readable medium can be included in the above electronic device; or can exist separately without being assembled into the electronic device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device is caused to: obtain a business service script for automated testing from Github; establish a communication connection with a test host; trigger the flask application service of the test host to start listening. The flask application service is implemented by a base method script, and the base method script is obtained by the test host from the Github; create an http connection instance with the test host according to the business service script; send an http request to the test host through the http connection instance. The http request carries test cases, and the test cases are set by the business service script; receive the test results returned by the test host. The test results are obtained by the test host executing the test cases and are encapsulated and generated according to the base method script. Alternatively, the electronic device is caused to: obtain a base method script for automated testing from Github; establish a communication connection with an execution machine; trigger the flask application service to start listening according to the base method script; create an http connection instance with the execution machine. The http connection instance is initiated and created by the execution machine according to a business service script, and the business service script is obtained by the execution machine from the Github; receive, through the flask application service, the http request sent by the execution machine through the http connection instance, and parse the test cases from the http request. The test cases are set by the business service script; execute the test cases, obtain the test results, encapsulate the test results using the base method script, and return them to the execution machine.
[0189] Computer program code for performing the operations of some embodiments of the present application may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++; and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partially on the user's computer, execute as a stand-alone software package, execute partially on the user's computer and partially on a remote computer, or execute entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network connection, or may be connected to an external computer (e.g., through the Internet using an Internet service provider), and the above networks include local area networks (LANs) or wide area networks (WANs).
[0190] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system for performing the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0191] The units described in some embodiments of the present application may be implemented in software or in hardware. The described units may also be provided in a processor. For example, it may be described as: a processor includes a first determination unit, a second determination unit, a selection unit, and a third determination unit. Among them, the names of these units do not constitute a limitation on the unit itself in some cases.
[0192] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system on a chip (SOC), complex programmable logic devices (CPLD), and so on.
[0193] The above description is only some preferred embodiments of the present application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present application is not limited to the technical solutions formed by the specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) disclosed in the embodiments of the present application that have similar functions.
Claims
1. An automated testing method, characterized in that: Applied to an execution machine, the method comprises: Get the business scripts for automated testing from Github; Establish a communication connection with the test host; Triggering the flask application service of the test host to start listening, the flask application service is implemented by a base method script, and the base method script is obtained by the test host from the Github; Create an http connection instance with the test host according to the business script; Sending an http request to the test host through the http connection instance, wherein the http request carries a test case, and the test case is set by the business script; The test result returned by the test host is received, wherein the test result is obtained by the test host executing the test case and is generated according to the base method script encapsulation.
2. The method according to claim 1, characterized in that After establishing the communication connection with the test host, and before triggering the flask application service of the test host to start listening, it also includes: Check whether the base method script and tool in the test host are the latest versions, and send an update instruction to the test host.
3. The method according to claim 1, characterized in that The business script is used to: HTTP connection class and method definitions in the business framework, as well as external operation class and method definitions; And, provide test case implementation steps; The test case implementation steps include: Business framework, define HTTP connection class methods, encapsulate the operations required by the test case steps into methods, combine RESTful requests in the methods, send requests and process responses; According to the test case requirements, call the http connection class method to form the test case steps.
4. An automated testing method, characterized in that: Applied to a test host, the method comprises: Get the base method script for automated testing from Github; Establish a communication connection with the execution machine; According to the base method script, the flask application service is triggered to start monitoring; Creating an http connection instance with the execution machine, wherein the http connection instance is initiated and created by the execution machine according to a business script, and the business script is obtained by the execution machine from Github; Receiving, through the flask application service, an http request sent by the executor through the http connection instance, parsing the http request to obtain a test case, wherein the test case is set by the business script; Execute the test case, obtain the test result, encapsulate the test result using the base method script, and return it to the execution machine.
5. The method according to claim 4, characterized in that After establishing the communication connection with the execution machine, before triggering the flask application service to start listening according to the base method script, it also includes: Receive an update instruction sent by the execution machine, and check whether the base method script and tool are the latest versions; If the base method script is not the latest version, obtain the latest version of the base method script from Github; and / or, If the tool is not the latest version, the latest version of the tool is obtained from the FTP tool repository.
6. The method according to claim 1, characterized in that The base method script is used to: The flask service starts listening, request routing, and request response; and, Provides implementation methods, including: testing host-side commands, Python built-in and extension module methods, and Python custom modules and open source toolkit methods.
7. An automated testing device, characterized in that: Applied to an execution machine, the device comprises: The business script acquisition module is used to obtain business scripts for automated testing from Github; A communication connection module, used to establish a communication connection with a test host; A trigger module is used to trigger the flask application service of the test host to start listening, wherein the flask application service is implemented by a base method script, and the base method script is obtained by the test host from the Github; An http connection instance creation module, used to create an http connection instance with the test host according to the business script; A sending module, used for sending an http request to the test host through the http connection instance, wherein the http request carries a test case, and the test case is set by the business script; The receiving module is used to receive the test result returned by the test host, wherein the test result is obtained by the test host executing the test case and is generated by encapsulating the base method script.
8. An automated testing device, characterized in that: Applied to a test host, the device comprises: The base method script acquisition module is used to obtain the base method script for automated testing from Github; A communication connection module, used for establishing a communication connection with an execution machine; A trigger module is used to trigger the flask application service to start monitoring according to the base method script; An http connection instance creation module is used to create an http connection instance with the execution machine, wherein the http connection instance is created by the execution machine according to a business script, and the business script is obtained by the execution machine from Github; A receiving module, used for receiving, through the flask application service, an http request sent by the execution machine through the http connection instance, and parsing the http request to obtain a test case, wherein the test case is set by the business script; The sending module is used to execute the test case, obtain the test result, encapsulate the test result using the base method script, and return it to the execution machine.
9. An automated testing system, characterized in that: The system comprises: Github, used to store and manage business scripts and base method scripts; An execution machine is used to obtain the business script for the test host from the Github, establish a communication connection with the test host, trigger the flask application service of the test host to pull up the listener, create an http connection instance with the test host according to the business script, send an http request to the test host through the http connection instance, the http request carries a test case, the test case is set by the business script, and receive the test result returned by the test host; The test host is used to obtain the base method script from the Github, trigger the flask application service to start listening according to the base method script, receive the HTTP request through the flask application service, parse the HTTP request to obtain the test case, execute the test case, obtain the test result, encapsulate the test result using the base method script, and return it to the executor.
10. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-3 or 4-6.