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

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

Info

Publication number
CN111679965A
CN111679965A CN202010327124.6A CN202010327124A CN111679965A CN 111679965 A CN111679965 A CN 111679965A CN 202010327124 A CN202010327124 A CN 202010327124A CN 111679965 A CN111679965 A CN 111679965A
Authority
CN
China
Prior art keywords
mirror image
code
test
automatic test
acquiring
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010327124.6A
Other languages
Chinese (zh)
Inventor
刘丽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An International Smart City Technology Co Ltd
Original Assignee
Ping An International Smart City Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An International Smart City Technology Co Ltd filed Critical Ping An International Smart City Technology Co Ltd
Priority to CN202010327124.6A priority Critical patent/CN111679965A/en
Publication of CN111679965A publication Critical patent/CN111679965A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses an automatic testing method, an automatic testing device, computer equipment and a storage medium, wherein the method comprises the following steps: when receiving an automatic test request, acquiring first address information of a code management warehouse; according to the first address information, acquiring a designated code corresponding to the automatic test request from a code management warehouse through a code management tool in a preset container cloud platform; generating an automatic test script corresponding to the designated code according to the designated code; pulling a preset Docker mirror image from the mirror image warehouse, and deploying the Docker mirror image in a container cloud platform; copying an automatic test script into a Docker mirror image in a container cloud platform to generate a corresponding pod; an automated test script is executed in the pod. The pod for carrying out the automatic test is generated by using the container technology and the mirror image technology, so that the reusability and maintainability of the test running environment of the automatic test are effectively ensured, and the test efficiency and test stability of the automatic test are improved.

Description

Automatic testing method and device, computer equipment and storage medium
Technical Field
The application relates to the technical field of internet, in particular to an automatic testing method, an automatic testing device, computer equipment and a storage medium.
Background
Automated testing, which may cover a portion of test cases, has become increasingly important in the testing phase, thereby relieving the testing personnel of version delivery pressure. Existing automated test procedures typically require deployment of a test execution environment, such as a code execution environment, a dependency library, and various software, on an automated test server to execute automated test scripts. However, after the test running environment of the automated test script is successfully deployed on the automated test server, if the automated test server is abnormal and needs to perform system reinstallation, all the deployed configuration data will be lost, so that the subsequent automated test cannot be performed normally at all. If the test operation environment needs to be recovered, the deployment process of the test operation environment needs to be executed again, the reusability of the test operation environment is not high, and the test efficiency of the automatic test is low. Moreover, the current quick recovery of the test operation environment is a difficult, time-consuming and labor-consuming matter for the tester, and the maintenance cost of the test operation environment is high.
Disclosure of Invention
The present application mainly aims to provide an automated testing method, an automated testing device, a computer device, and a storage medium, and aims to solve the technical problems that in the existing automated testing process, if an automated testing server is abnormal and needs to be reinstalled, a deployment process of a testing operation environment needs to be executed again, so that the reusability of the testing operation environment is not high, the maintenance cost of the testing operation environment is high, and the testing efficiency of automated testing is low.
The application provides an automatic testing method, which comprises the following steps:
when receiving an automatic test request, acquiring first address information of a code management warehouse;
according to the first address information, acquiring an appointed code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform;
generating an automatic test script corresponding to the designated code according to the designated code;
pulling a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform;
copying the automatic test script to a Docker mirror image in the container cloud platform to generate a corresponding pod;
executing the automated test script in the pod.
Optionally, before the step of obtaining, by a code management tool in a preset container cloud platform, a designated code corresponding to the automated test request from the code management repository according to the first address information, the method includes:
receiving an input test code corresponding to an automated test;
screening out method names from the test codes, wherein the number of the method names comprises one or more;
extracting method data corresponding to the method name from a pre-created pytest decorator;
updating the test code by using the method data to obtain the specified code;
and sending the specified code to a Gitlab server so as to store the specified code into the code management warehouse through the Gitlab server.
Optionally, before the step of extracting the method data corresponding to the method name from the pre-created pytest decorator, the method includes:
acquiring a public method corresponding to the automated testing;
packaging the public method into a pytest decorator;
the pytest decorator is stored in a pre-created first designated file.
Optionally, the step of generating, according to the designated code, an automation test script corresponding to the designated code includes:
performing a compilation operation on the specified code;
acquiring a compiling result generated after the specified code executes the compiling operation;
acquiring a script template corresponding to the automatic test request from a preset script database;
and generating the automatic test script according to the compiling result and the script template.
Optionally, before the step of pulling a preset Docker image from an image warehouse and deploying the Docker image in the container cloud platform, the method includes:
acquiring a dependency library of a python program, and packaging the python dependency library into a second specified file corresponding to the specified file type;
acquiring an input Dockerfile file;
placing the second specified file and the Dockerfile file in the same pre-established specified directory;
acquiring a basic mirror image, wherein the basic mirror image comprises an operating environment of a python program;
packing the dependent libraries of the python programs in the specified directory into the basic mirror image through a Docker build command to obtain a corresponding Docker mirror image;
sending the Docker mirror image to the mirror image warehouse for storage through a Docker push command;
the step of pulling the preset Docker mirror image from the mirror image warehouse comprises the following steps:
acquiring second address information of the mirror image warehouse;
and pulling the Docker mirror image from the mirror image warehouse according to the second address information.
Optionally, before the step of obtaining the first address information of the code management repository when the automated test request is received, the method includes:
monitoring the cloud container platform within a preset time period to acquire corresponding state information of the cloud container platform;
judging whether the container state of the cloud container platform is abnormal or not according to the state information;
and if the container state of the cloud container platform is judged not to be abnormal, generating an acquisition instruction for acquiring the first address information of the code management warehouse.
Optionally, after the step of executing the automated test script in the pod, the method further comprises:
acquiring an operation result of the automatic test script;
comparing the actual output corresponding to the operation result with the expected output to obtain a comparison result;
generating a test report of the automatic test script according to the running result and the comparison result;
and displaying the test report.
The application also provides an automatic testing arrangement, includes:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring first address information of a code management warehouse when receiving an automatic test request;
a second obtaining module, configured to obtain, according to the first address information, an assigned code corresponding to the automated test request from the code management repository through a code management tool in a preset container cloud platform;
the first generation module is used for generating an automatic test script corresponding to the specified code according to the specified code;
the deployment module is used for pulling a preset Docker mirror image from the mirror image warehouse and deploying the Docker mirror image in the container cloud platform;
the second generation module is used for copying the automatic test script into a Docker mirror image in the container cloud platform to generate a corresponding pod;
an execution module to execute the automated test script in the pod.
The present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the above-mentioned method.
The automated testing method, the automated testing device, the computer equipment and the storage medium have the following beneficial effects:
according to the automatic testing method, the automatic testing device, the computer equipment and the storage medium, when an automatic testing request is received, first address information of a code management warehouse is obtained; according to the first address information, acquiring an appointed code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform; generating an automatic test script corresponding to the designated code according to the designated code; pulling a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform; copying the automatic test script to a Docker mirror image in the container cloud platform to generate a corresponding pod; executing the automated test script in the pod. The present application increases the mobility of the test environment for automated testing by using container technology as well as mirroring technology to generate a pod for automated testing. When the pod is abnormal, a new pod can be quickly generated to redeploy the test operation environment for executing the automatic test, the test operation environment can not be lost, the reusability and maintainability of the test operation environment of the automatic test are ensured, the traditional automatic test method is effectively prevented from redeploying the test operation environment when the test operation environment deployed on the automatic test server is abnormal, and the test efficiency and the test stability of the automatic test are improved.
Drawings
FIG. 1 is a schematic flow chart of an automated testing method according to an embodiment of the present application;
FIG. 2 is a schematic structural diagram of an automated testing apparatus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It should be noted that all directional indicators (such as upper, lower, left, right, front and rear … …) in the embodiments of the present application are only used to explain the relative position relationship between the components, the movement situation, etc. in a specific posture (as shown in the drawings), and if the specific posture is changed, the directional indicator is changed accordingly, and the connection may be a direct connection or an indirect connection.
Referring to fig. 1, an automated testing method according to an embodiment of the present application includes:
s1: when receiving an automatic test request, acquiring first address information of a code management warehouse;
s2: according to the first address information, acquiring an appointed code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform;
s3: generating an automatic test script corresponding to the designated code according to the designated code;
s4: pulling a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform;
s5: copying the automatic test script to a Docker mirror image in the container cloud platform to generate a corresponding pod;
s6: executing the automated test script in the pod.
As described above in steps S1-S6, the execution subject of the embodiment of the method is an automated testing apparatus. In practical applications, the automatic testing apparatus may be implemented by a virtual device, such as a software code, or by an entity device in which a relevant execution code is written or integrated, and may perform human-computer interaction with a user through a keyboard, a mouse, a remote controller, a touch panel, or a voice control device. The automated testing device provided by the embodiment can rapidly and conveniently deploy the corresponding test running environment in the container cloud platform by generating the pod when the test running environment of the automated testing server is abnormal, so as to ensure the normal operation of the automated testing. Specifically, when an automated test request is received, first address information of a code management repository is first acquired. And then acquiring the specified code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform according to the first address information. Before the automated testing request is received, the container cloud platform is created in advance. The container cloud platform comprises a code management tool and a mirror image warehouse, and can be automatically created through a preset container creation script by means of a container technology and a cluster scheduling editing management technology. And after the specified code is obtained, generating an automatic test script corresponding to the specified code according to the specified code. The automatic test script may be generated according to a compiling result generated by compiling the specified code and a script template corresponding to the automatic test request. And after the automatic test script is obtained, acquiring a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform. And after the Docker mirror image deployment is finished, copying the automatic test script into the Docker mirror image in the container cloud platform to generate a corresponding pod. The pod can be regarded as a test running environment required for performing an automated test by running an automated test script. And finally, after the pod is generated, executing the automatic test script in the pod to realize the test flow of the automatic test. If an exception occurs during the execution of the automatic test script in the pod, the automatic test flow can be re-executed to quickly generate a new pod, and the automatic test script is executed through the new pod. In addition, when a new automatic test request is received, the steps are repeatedly executed. The present embodiment increases the mobility of the test environment for automated testing by using container technology as well as mirroring technology to generate a pod for automated testing. When the pod is abnormal, a new pod can be quickly generated to redeploy the test operation environment for executing the automatic test, the test operation environment can not be lost, the reusability and maintainability of the test operation environment of the automatic test are ensured, the traditional automatic test method is effectively prevented from redeploying the test operation environment when the test operation environment deployed on the automatic test server is abnormal, and the test efficiency and the test stability of the automatic test are improved.
Further, in an embodiment of the present application, before the step S2, the method includes:
s200: receiving an input test code corresponding to an automated test;
s201: screening out method names from the test codes, wherein the number of the method names comprises one or more;
s202: extracting method data corresponding to the method name from a pre-created pytest decorator;
s203: updating the test code by using the method data to obtain the specified code;
s204: and sending the specified code to a Gitlab server so as to store the specified code into the code management warehouse through the Gitlab server.
As described in the foregoing steps S200 to S204, before the step of obtaining the designated code corresponding to the automated test request from the code management repository through a code management tool in a preset container cloud platform according to the first address information, a process of generating the designated code is further included. Specifically, a test code corresponding to an automated test is first received that is input by a user. And then screening out method names from the test codes, wherein the number of the method names comprises one or more. Method data corresponding to the above-described method name is then extracted from the pre-created pytest decorator. Wherein the pytest decorator is obtained by encapsulating a common method related to automated testing. After the method data is obtained, the first test code is updated by using the method data to obtain the designated code. And finally, the specified code is sent to a Gitlab server so that the Gitlab server stores the specified code in the code management warehouse, and then the specified code can be used for generating an automatic test script for carrying out an automatic test. According to the method and the device, the user does not need to repeatedly write the public method and write all data contained in the public method into the test code, the user only needs to transmit the name of the public method, and the specified code is obtained according to the test code containing the name of the method by using the pytest decorator in the follow-up intelligence, so that the workload of repeatedly writing the code of the user is effectively reduced, and the limitation of writing the test code is reduced.
Further, in an embodiment of the present application, before the step S202, the method includes:
s2020: acquiring a public method corresponding to the automated testing;
s2021: packaging the public method into a pytest decorator;
s2022: the pytest decorator is stored in a pre-created first designated file.
As described in the above steps S2020 to S2022, a creation process of creating the pytest decorator is further included before the above step of extracting the method data corresponding to the above method name from the pre-created pytest decorator. Specifically, a common method corresponding to the automated test is first acquired. The method for obtaining the public method is not particularly limited, and the public method may be obtained by querying network resources related to an automated test, or may be obtained by receiving a common public method input by a developer. After the public method is obtained, the public method is packaged into a pytest decorator. Wherein the pytest decorator is defined in front of the function by using the pytest. When a user writes a test function, the function name can be used as an incoming parameter, and the pytest decorator will use the return value of the function as an incoming parameter of the test function in an injection-dependent manner. And finally, storing the pytest decorator in a pre-created first designated file, wherein the first designated file can be a conttest. The pytest decorator is stored in the first appointed file, so that the test code which is written by a user and contains the method name can be processed according to the pytest decorator in the subsequent automatic test process, and the appointed script which is used for the automatic test subsequently is generated.
Further, in an embodiment of the present application, the step S3 includes:
s300: performing a compilation operation on the specified code;
s301: acquiring a compiling result generated after the specified code executes the compiling operation;
s302: acquiring a script template corresponding to the automatic test request from a preset script database;
s303: and generating the automatic test script according to the compiling result and the script template.
As described in steps S300 to S303, the step of generating an automation test script corresponding to the designated code according to the designated code may specifically include: the compilation operation is first performed on the above specified code. And then, obtaining a compiling result generated after the specified code executes the compiling operation, wherein the compiling result can be obtained by compiling the code through a compiler, and the compiling method can adopt the existing common code compiling scheme and is not described herein any more. And after the compiling result is obtained, acquiring a script template corresponding to the automatic test request from a preset script database. And various types of script template files are stored in the script database. And finally, according to the compiling result and the script template, generating the automatic test script so as to copy the generated automatic test script into a Docker mirror image in the container cloud platform in the following process, generating a corresponding pod, and further executing the automatic test script in the pod to complete automatic test. Specifically, the automated test script may be obtained by referring to a script template corresponding to the automated test request and inputting the compiling result to a corresponding position of the script template.
Further, in an embodiment of the present application, before the step S4, the method includes:
s400: acquiring a dependency library of a python program, and packaging the python dependency library into a second specified file corresponding to the specified file type;
s401: acquiring an input Dockerfile file;
s402: placing the second specified file and the Dockerfile file in the same pre-established specified directory;
s403: acquiring a basic mirror image, wherein the basic mirror image comprises an operating environment of a python program;
s404: packing the dependent libraries of the python programs in the specified directory into the basic mirror image through a Docker build command to obtain a corresponding Docker mirror image;
s405: sending the Docker mirror image to the mirror image warehouse for storage through a Docker push command;
the step of pulling the preset Docker image from the image warehouse in the step S4 includes:
s410: acquiring second address information of the mirror image warehouse;
s411: and pulling the Docker mirror image from the mirror image warehouse according to the second address information.
As described in steps S400 to S405 above, before the step of pulling the preset Docker image from the image repository, a generation process of generating the Docker image is further included, specifically, a dependent library of a python program is first obtained, and the dependent library of the python program is packaged into a second specified file corresponding to the specified file type. The above-mentioned dependent library of the python program is some method data which is already developed based on the python language in the prior art, and the dependent library of the python program can be obtained by downloading from related network resources (such as an official website of the python language). In addition, the specified file type is specifically a tar. And then acquiring the Dockerfile written and input by a developer, and placing the second specified file and the Dockerfile in the same specified directory. The Dockerfile file is a construction file for constructing a Docker mirror image, and is a script file composed of a series of commands and parameters, and the Dockerfile file can be obtained by being written and input by developers according to actual service requirements. In addition, when the Docker image is constructed, the commands contained in the Dockerfile file, such as the python installation command and the installation command of the dependent library of the python program, are sequentially executed. And then obtaining a basic mirror image, wherein the basic mirror image comprises the operating environment of the python program, if a user needs to add some data in the operating environment of the python or modify some data in the operating environment of the python, the basic mirror image needs to be modified correspondingly again, and then the modified basic mirror image is obtained to replace the previous basic mirror image. After the base mirror image and the specified directory are obtained, packing the dependent libraries of the python programs in the specified directory into the base mirror image through a Docker build command to obtain a corresponding Docker mirror image. For example, the Docker build command may be a Dockerbuild-t mirror repository address/mirror name, i.e. a mirror version. And finally, the Docker mirror image is sent to a preset mirror image warehouse for storage through a Docker push command, so that the preset Docker mirror image can be rapidly pulled from the mirror image warehouse in the subsequent automatic test process, and the Docker mirror image is deployed in the container cloud platform. After the Docker image is generated, the Docker image needs to be saved and used subsequently, for example, the Docker image can be pushed to a mirror warehouse for saving, and the Docker image cannot be lost after saving, so that the security of the Docker image is ensured. In addition, for example, the Docker push command may be a Docker mirror warehouse address/mirror name, i.e. a mirror version. Further, as described in the foregoing steps S410 to S411, the step of obtaining the preset Docker image may specifically include: first, second address information of the mirror image warehouse is obtained, and then the Docker mirror image is pulled from the mirror image warehouse according to the second address information.
In an embodiment of the present application, before the step S1, the method includes:
s100: monitoring the cloud container platform within a preset time period to acquire corresponding state information of the cloud container platform;
s101: judging whether the container state of the cloud container platform is abnormal or not according to the state information;
s102: and if the container state of the cloud container platform is judged not to be abnormal, generating an acquisition instruction for acquiring the first address information of the code management warehouse.
As described in steps S100 to S102, when receiving the automatic test request, before performing the acquiring process of acquiring the first address information of the code management repository, it is further required to monitor whether the pre-created container cloud platform can operate normally, so as to ensure that the automatic test can be performed successfully according to the cloud container platform subsequently. Specifically, the cloud container platform is monitored within a preset time period, and state information corresponding to the cloud container platform is acquired. The preset time period is not particularly limited, and may be set according to actual requirements, for example, the preset time period may be set within 10 minutes after the cloud container platform is successfully created. In addition, the state information may be obtained by obtaining and analyzing related operation data of the cloud container platform, where the related operation data may specifically include a CPU usage rate, a memory usage rate, a network throughput, a space utilization rate, and the like. And then judging whether the container state of the cloud container platform is abnormal or not according to the state information. The state information may specifically include normal operation or abnormal operation, and the state information may be determined as normal operation by comparing the relevant operation data with a preset standard threshold, if the relevant operation data is within the range of the standard threshold, and otherwise, as abnormal operation. And if the container state of the cloud container platform is judged not to be abnormal, generating an acquisition instruction for acquiring the first address information of the code management warehouse. In another embodiment, if it is determined that the container state of the cloud container platform is abnormal, a preset container creation script is called to automatically create a cloud container platform identical to the cloud container platform, and then the newly created cloud container platform is used to execute a subsequent automated testing process, so that the container cloud platform can be quickly and intelligently rebuilt after the container state of the container cloud platform is abnormal, and a more reliable automated testing process can be subsequently performed through the newly generated cloud container platform.
Further, in an embodiment of the present application, after the step S6, the method includes:
s600: acquiring an operation result of the automatic test script;
s601: comparing the actual output corresponding to the operation result with the expected output to obtain a comparison result;
s602: generating a test report of the automatic test script according to the running result and the comparison result;
s603: and displaying the test report.
As described in steps S600 to S603, after the step of executing the automated test script in the pod, a corresponding test report may be generated according to an operation result generated after the automated test script is executed. Specifically, the running result of the automated test script is obtained first. And then comparing the actual output corresponding to the operation result with the expected output to obtain a comparison result. The running result of the automatic test script is an actual result corresponding to the automatic test, the preset output is an expected result corresponding to the automatic test, and the actual result is compared with the expected result to obtain the specific test condition of the automatic test. And when the comparison result is obtained, generating a test report of the automatic test script according to the comparison result. The content of the test report may specifically include actual output data and difference data between the actual output and the expected output. After the test report is generated, the test report is finally displayed, so that a user can clearly know specific test data of the automatic test and clearly know specific test conditions according to the test report, and a subsequent user can correspondingly improve a subsequent automatic test process according to the test report.
Referring to fig. 2, an embodiment of the present application further provides an automatic testing apparatus, including:
the system comprises a first acquisition module 1, a first storage module and a second acquisition module, wherein the first acquisition module is used for acquiring first address information of a code management warehouse when receiving an automatic test request;
a second obtaining module 2, configured to obtain, according to the first address information, an assigned code corresponding to the automated test request from the code management warehouse through a code management tool in a preset container cloud platform;
the first generation module 3 is used for generating an automatic test script corresponding to the specified code according to the specified code;
the deployment module 4 is used for pulling a preset Docker mirror image from a mirror image warehouse and deploying the Docker mirror image in the container cloud platform;
the second generation module 5 is configured to copy the automatic test script into a Docker mirror image in the container cloud platform, and generate a corresponding pod;
and the execution module 6 is used for executing the automatic test script in the pod.
In this embodiment, the implementation processes of the functions and actions of the first obtaining module, the second obtaining module, the first generating module, the deploying module, the second generating module and the executing module in the automatic testing apparatus are specifically detailed in the implementation processes corresponding to steps S1 to S6 in the automatic testing method, and are not described herein again.
Further, in an embodiment of the present application, the automatic testing apparatus includes:
the first receiving module is used for receiving an input test code corresponding to the automatic test;
the screening module is used for screening out method names from the test codes, wherein the number of the method names comprises one or more;
the extracting module is used for extracting method data corresponding to the method name from a pre-created pytest decorator;
the updating module is used for updating the test code by using the method data to obtain the specified code;
and the first sending module is used for sending the specified code to a Gitlab server so as to store the specified code into the code management warehouse through the Gitlab server.
In this embodiment, the implementation processes of the functions and functions of the first receiving module, the screening module, the extracting module, the updating module, and the first sending module in the automatic testing apparatus are specifically detailed in the implementation processes corresponding to steps S200 to S204 in the automatic testing method, and are not described herein again.
Further, in an embodiment of the present application, the automatic testing apparatus includes:
the third acquisition module is used for acquiring a public method corresponding to the automatic test;
a packaging module for packaging the public method into a pytest decorator;
and the storage module is used for storing the pytest decorator in a pre-created first designated file.
In this embodiment, the implementation process of the functions and functions of the third obtaining module, the encapsulating module and the storage module in the automatic testing apparatus is specifically described in the implementation process corresponding to steps S2020 to S2022 in the automatic testing method, and is not described herein again.
Further, in an embodiment of the present application, the first generating module includes:
a compiling unit for performing a compiling operation on the specified code;
a first obtaining unit, configured to obtain a compiling result generated after the specified code performs the compiling operation;
the second acquisition unit is used for acquiring a script template corresponding to the automatic test request from a preset script database;
and the generating unit is used for generating the automatic test script according to the compiling result and the script template.
In this embodiment, the implementation processes of the functions and functions of the compiling unit, the first obtaining unit, the second obtaining unit, and the generating unit in the automatic testing apparatus are specifically detailed in the implementation processes corresponding to steps S300 to S303 in the automatic testing method, and are not described herein again.
Further, in an embodiment of the present application, the automatic testing apparatus includes:
the fourth acquisition module is used for acquiring a dependency library of the python program and packaging the python dependency library into a second specified file corresponding to the specified file type;
the fifth acquisition module is used for acquiring the input Dockerfile file;
the placing module is used for placing the second specified file and the Dockerfile file in the same pre-created specified directory;
the sixth acquisition module is used for acquiring a basic mirror image, wherein the basic mirror image comprises an operating environment of a python program;
the packaging module is used for packaging the dependent library of the python program in the specified directory into the basic mirror image through a Docker build command to obtain a corresponding Docker mirror image;
the second sending module is used for sending the Docker mirror image to the mirror image warehouse for storage through a Docker push command;
the deployment module includes:
a third obtaining unit, configured to obtain second address information of the mirror image warehouse;
and the pulling unit is used for pulling the Docker mirror image from the mirror image warehouse according to the second address information.
In this embodiment, the implementation processes of the functions and functions of the fourth obtaining module, the fifth obtaining module, the placing module, the sixth obtaining module, the packing module and the second sending module in the automatic testing apparatus are specifically detailed in the implementation processes corresponding to steps S400 to S405 in the automatic testing method, and are not described herein again. The implementation process of the functions and actions of the third obtaining unit and the pulling unit in the automatic testing apparatus is specifically detailed in the implementation process corresponding to steps S410 to S411 in the automatic testing method, and is not described herein again.
Further, in an embodiment of the present application, the automatic testing apparatus includes:
the seventh acquisition module is used for monitoring the cloud container platform within a preset time period and acquiring the corresponding state information of the cloud container platform;
the judging module is used for judging whether the container state of the cloud container platform is abnormal or not according to the state information;
and the third generating module is used for generating an obtaining instruction for obtaining the first address information of the code management warehouse if the container state of the cloud container platform is judged not to be abnormal.
In this embodiment, the implementation processes of the functions and functions of the seventh obtaining module, the determining module and the third generating module in the automatic testing apparatus are specifically detailed in the implementation processes corresponding to steps S100 to S102 in the automatic testing method, and are not described herein again.
Further, in an embodiment of the present application, the automatic testing apparatus includes:
the eighth obtaining module is used for obtaining the running result of the automatic test script;
the comparison module is used for comparing the actual output corresponding to the operation result with the expected output to obtain a comparison result;
the fourth generation module is used for generating a test report of the automatic test script according to the running result and the comparison result;
and the display module is used for displaying the test report.
In this embodiment, the implementation processes of the functions and functions of the eighth obtaining module, the comparing module, the fourth generating module and the displaying module in the automatic testing apparatus are specifically detailed in the implementation processes corresponding to steps S600 to S603 in the automatic testing method, and are not described herein again.
Referring to fig. 3, a computer device, which may be a server and whose internal structure may be as shown in fig. 3, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is designed to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data such as first address information, a designated code, a Docker mirror image and the like. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an automated testing method.
The processor executes the steps of the automated testing method:
when receiving an automatic test request, acquiring first address information of a code management warehouse;
according to the first address information, acquiring an appointed code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform;
generating an automatic test script corresponding to the designated code according to the designated code;
pulling a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform;
copying the automatic test script to a Docker mirror image in the container cloud platform to generate a corresponding pod;
executing the automated test script in the pod.
Those skilled in the art will appreciate that the structure shown in fig. 3 is only a block diagram of a part of the structure related to the present application, and does not constitute a limitation to the apparatus and the computer device to which the present application is applied.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements an automated testing method, and specifically:
when receiving an automatic test request, acquiring first address information of a code management warehouse;
according to the first address information, acquiring an appointed code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform;
generating an automatic test script corresponding to the designated code according to the designated code;
pulling a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform;
copying the automatic test script to a Docker mirror image in the container cloud platform to generate a corresponding pod;
executing the automated test script in the pod.
To sum up, the automated testing method, the automated testing device, the computer device, and the storage medium provided in the embodiments of the present application acquire first address information of a code management repository when receiving an automated testing request; according to the first address information, acquiring an appointed code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform; generating an automatic test script corresponding to the designated code according to the designated code; pulling a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform; copying the automatic test script to a Docker mirror image in the container cloud platform to generate a corresponding pod; executing the automated test script in the pod. The embodiment of the application increases the mobility of the test environment for the automated testing by using the container technology and the mirroring technology to generate the pod for the automated testing. When the pod is abnormal, a new pod can be quickly generated to redeploy the test operation environment for executing the automatic test, the test operation environment can not be lost, the reusability and maintainability of the test operation environment of the automatic test are ensured, the traditional automatic test method is effectively prevented from redeploying the test operation environment when the test operation environment deployed on the automatic test server is abnormal, and the test efficiency and the test stability of the automatic test are improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by hardware associated with instructions of a computer program, which may be stored on a non-volatile computer-readable storage medium, and when executed, may include processes of the above embodiments of the methods. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (10)

1. An automated testing method, comprising:
when receiving an automatic test request, acquiring first address information of a code management warehouse;
according to the first address information, acquiring an appointed code corresponding to the automatic test request from the code management warehouse through a code management tool in a preset container cloud platform;
generating an automatic test script corresponding to the designated code according to the designated code;
pulling a preset Docker mirror image from a mirror image warehouse, and deploying the Docker mirror image in the container cloud platform;
copying the automatic test script to a Docker mirror image in the container cloud platform to generate a corresponding pod;
executing the automated test script in the pod.
2. The automated testing method according to claim 1, wherein before the step of obtaining the specified code corresponding to the automated testing request from the code management repository through a code management tool in a preset container cloud platform according to the first address information, the method includes:
receiving an input test code corresponding to an automated test;
screening out method names from the test codes, wherein the number of the method names comprises one or more;
extracting method data corresponding to the method name from a pre-created pytest decorator;
updating the test code by using the method data to obtain the specified code;
and sending the specified code to a Gitlab server so as to store the specified code into the code management warehouse through the Gitlab server.
3. The automated testing method of claim 2, wherein said step of extracting method data corresponding to said method name from a pre-created pytest decorator is preceded by the steps of:
acquiring a public method corresponding to the automated testing;
packaging the public method into a pytest decorator;
the pytest decorator is stored in a pre-created first designated file.
4. The automated testing method of claim 1, wherein the step of generating an automated testing script corresponding to the specified code based on the specified code comprises:
performing a compilation operation on the specified code;
acquiring a compiling result generated after the specified code executes the compiling operation;
acquiring a script template corresponding to the automatic test request from a preset script database;
and generating the automatic test script according to the compiling result and the script template.
5. The automated testing method of claim 1, wherein the step of pulling a preset Docker image from an image repository and deploying the Docker image in the container cloud platform is preceded by the step of:
acquiring a dependency library of a python program, and packaging the python dependency library into a second specified file corresponding to the specified file type;
acquiring an input Dockerfile file;
placing the second specified file and the Dockerfile file in the same pre-established specified directory;
acquiring a basic mirror image, wherein the basic mirror image comprises an operating environment of a python program;
packing the dependent libraries of the python programs in the specified directory into the basic mirror image through a Docker build command to obtain a corresponding Docker mirror image;
sending the Docker mirror image to the mirror image warehouse for storage through a Docker push command;
the step of pulling the preset Docker mirror image from the mirror image warehouse comprises the following steps:
acquiring second address information of the mirror image warehouse;
and pulling the Docker mirror image from the mirror image warehouse according to the second address information.
6. The automated testing method of claim 1, wherein the step of obtaining the first address information of the code management repository when the automated testing request is received is preceded by:
monitoring the cloud container platform within a preset time period to acquire corresponding state information of the cloud container platform;
judging whether the container state of the cloud container platform is abnormal or not according to the state information;
and if the container state of the cloud container platform is judged not to be abnormal, generating an acquisition instruction for acquiring the first address information of the code management warehouse.
7. The automated testing method of claim 1, wherein the step of executing the automated test script in the pod is followed by:
acquiring an operation result of the automatic test script;
comparing the actual output corresponding to the operation result with the expected output to obtain a comparison result;
generating a test report of the automatic test script according to the running result and the comparison result;
and displaying the test report.
8. An automated testing apparatus, comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring first address information of a code management warehouse when receiving an automatic test request;
a second obtaining module, configured to obtain, according to the first address information, an assigned code corresponding to the automated test request from the code management repository through a code management tool in a preset container cloud platform;
the first generation module is used for generating an automatic test script corresponding to the specified code according to the specified code;
the deployment module is used for pulling a preset Docker mirror image from the mirror image warehouse and deploying the Docker mirror image in the container cloud platform;
the second generation module is used for copying the automatic test script into a Docker mirror image in the container cloud platform to generate a corresponding pod;
an execution module to execute the automated test script in the pod.
9. A computer device comprising a memory and a processor, the memory having stored therein a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method according to any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, the computer program, when being executed by a processor, realizing the steps of the method of any one of claims 1 to 7.
CN202010327124.6A 2020-04-23 2020-04-23 Automatic testing method and device, computer equipment and storage medium Pending CN111679965A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010327124.6A CN111679965A (en) 2020-04-23 2020-04-23 Automatic testing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010327124.6A CN111679965A (en) 2020-04-23 2020-04-23 Automatic testing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111679965A true CN111679965A (en) 2020-09-18

Family

ID=72451773

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010327124.6A Pending CN111679965A (en) 2020-04-23 2020-04-23 Automatic testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111679965A (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112395363A (en) * 2020-12-04 2021-02-23 北京有竹居网络技术有限公司 Data synchronization method, device, equipment and readable storage medium
CN112596750A (en) * 2020-12-28 2021-04-02 上海安畅网络科技股份有限公司 Application testing method and device, electronic equipment and computer readable storage medium
CN112650555A (en) * 2020-12-25 2021-04-13 苏州浪潮智能科技有限公司 Development and test method, system and medium for management platform
CN112951314A (en) * 2021-02-01 2021-06-11 上海航天计算机技术研究所 Loadable general RAM self-testing method based on TSC695 processor
CN113010441A (en) * 2021-04-29 2021-06-22 成都新希望金融信息有限公司 Model publishing method and device, electronic equipment and storage medium
CN113052463A (en) * 2021-03-25 2021-06-29 平安银行股份有限公司 Workflow verification method and device, computer equipment and storage medium
CN113064827A (en) * 2021-04-12 2021-07-02 京东数科海益信息科技有限公司 Test platform deployment method, device, equipment and storage medium
CN113110992A (en) * 2021-04-06 2021-07-13 四川新网银行股份有限公司 Method for managing test environment
CN114201413A (en) * 2022-02-18 2022-03-18 苏州浪潮智能科技有限公司 Automatic testing method and system and electronic equipment
WO2022088710A1 (en) * 2020-10-29 2022-05-05 华为技术有限公司 Mirror image management method and apparatus
CN115048313A (en) * 2022-06-30 2022-09-13 中国电信股份有限公司 Automatic testing method and device, computer readable storage medium and electronic equipment
CN115098222A (en) * 2022-06-22 2022-09-23 支付宝(杭州)信息技术有限公司 Script execution method, device and equipment
CN115412458A (en) * 2022-08-29 2022-11-29 山石网科通信技术股份有限公司 Network equipment testing method and device and electronic equipment
CN117648198A (en) * 2024-01-30 2024-03-05 北京比格大数据有限公司 Application adaptation method, device, equipment and storage medium

Cited By (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022088710A1 (en) * 2020-10-29 2022-05-05 华为技术有限公司 Mirror image management method and apparatus
CN112395363A (en) * 2020-12-04 2021-02-23 北京有竹居网络技术有限公司 Data synchronization method, device, equipment and readable storage medium
CN112395363B (en) * 2020-12-04 2024-03-26 北京有竹居网络技术有限公司 Data synchronization method, device, equipment and readable storage medium
CN112650555B (en) * 2020-12-25 2022-09-20 苏州浪潮智能科技有限公司 Development and test method, system and medium for management platform
CN112650555A (en) * 2020-12-25 2021-04-13 苏州浪潮智能科技有限公司 Development and test method, system and medium for management platform
CN112596750B (en) * 2020-12-28 2022-04-26 上海安畅网络科技股份有限公司 Application testing method and device, electronic equipment and computer readable storage medium
CN112596750A (en) * 2020-12-28 2021-04-02 上海安畅网络科技股份有限公司 Application testing method and device, electronic equipment and computer readable storage medium
CN112951314B (en) * 2021-02-01 2023-05-05 上海航天计算机技术研究所 Loadable general RAM self-test method based on TSC695 processor
CN112951314A (en) * 2021-02-01 2021-06-11 上海航天计算机技术研究所 Loadable general RAM self-testing method based on TSC695 processor
CN113052463A (en) * 2021-03-25 2021-06-29 平安银行股份有限公司 Workflow verification method and device, computer equipment and storage medium
CN113052463B (en) * 2021-03-25 2023-09-26 平安银行股份有限公司 Workflow verification method, workflow verification device, computer equipment and storage medium
CN113110992A (en) * 2021-04-06 2021-07-13 四川新网银行股份有限公司 Method for managing test environment
CN113110992B (en) * 2021-04-06 2023-06-06 四川新网银行股份有限公司 Method for managing test environment
CN113064827A (en) * 2021-04-12 2021-07-02 京东数科海益信息科技有限公司 Test platform deployment method, device, equipment and storage medium
CN113010441A (en) * 2021-04-29 2021-06-22 成都新希望金融信息有限公司 Model publishing method and device, electronic equipment and storage medium
CN113010441B (en) * 2021-04-29 2024-05-07 成都新希望金融信息有限公司 Model issuing method and device, electronic equipment and storage medium
CN114201413A (en) * 2022-02-18 2022-03-18 苏州浪潮智能科技有限公司 Automatic testing method and system and electronic equipment
CN115098222A (en) * 2022-06-22 2022-09-23 支付宝(杭州)信息技术有限公司 Script execution method, device and equipment
CN115048313A (en) * 2022-06-30 2022-09-13 中国电信股份有限公司 Automatic testing method and device, computer readable storage medium and electronic equipment
CN115048313B (en) * 2022-06-30 2023-12-08 中国电信股份有限公司 Automatic test method and device, computer readable storage medium and electronic equipment
CN115412458A (en) * 2022-08-29 2022-11-29 山石网科通信技术股份有限公司 Network equipment testing method and device and electronic equipment
CN115412458B (en) * 2022-08-29 2023-11-03 山石网科通信技术股份有限公司 Network equipment testing method and device and electronic equipment
CN117648198A (en) * 2024-01-30 2024-03-05 北京比格大数据有限公司 Application adaptation method, device, equipment and storage medium
CN117648198B (en) * 2024-01-30 2024-05-10 北京比格大数据有限公司 Application adaptation method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111679965A (en) Automatic testing method and device, computer equipment and storage medium
US10185546B2 (en) Service extraction and application composition
US9098636B2 (en) White-box testing systems and/or methods in web applications
CN109901834B (en) Document page generation method, device, computer equipment and storage medium
CN108319460B (en) Method and device for generating application program installation package, electronic equipment and storage medium
CN112685035B (en) Project development method and device, computer readable storage medium and electronic equipment
US11113050B2 (en) Application architecture generation
US20080276221A1 (en) Method and apparatus for relations planning and validation
CN111008132B (en) Application debugging method and device for Android system, computer equipment and storage medium
EP3447635A1 (en) Application architecture generation
CN113835713B (en) Source code packet downloading method, device, computer equipment and storage medium
US9026997B2 (en) Systems and methods for executing object-oriented programming code invoking pre-existing objects
EP3314409A1 (en) Tracing dependencies between development artifacts in a software development project
CN113721973A (en) Configuration file generation method, device, equipment and medium
CN107918587A (en) The adjustment method and system of a kind of application program
CN115437643A (en) Project code conversion method, device, equipment and storage medium
CN115048082A (en) Micro front-end system construction method and device, server and readable storage medium
CN114564385A (en) Software testing method and device, computer equipment and storage medium
CN114003486A (en) Plug-in debugging method, client, server and storage medium
CN113254040A (en) Front-end framework updating method, device, equipment and storage medium
CN115454399A (en) Front-end project construction method, device, equipment and medium
CN115857962A (en) Software project processing method and device, electronic equipment and readable storage medium
CN115934500A (en) Pipeline construction method and device, computer equipment and storage medium
CN112765040A (en) Page testing method, system, computer equipment and storage medium
CN117806699A (en) Application program packaging and publishing management method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination