Disclosure of Invention
Aiming at the problems existing in the prior art, the invention aims to provide a method for automatically testing interfaces based on RPA, which can complete the automatic flow design by only opening the RPA and dragging out nodes and configuring the nodes through automatically testing on the basis of the RPA, and has relatively simple and convenient operation.
The invention is realized in such a way that a method for carrying out interface automation test based on RPA is based on RPA, and comprises the following steps:
S1, making a test plan, namely analyzing the requirements of interface tests, determining the targets and the ranges of the tests, identifying test resources, determining test types and methods, making test strategies and determining quality standards;
s2, building a test framework, namely building an environment suitable for interface test, wherein the environment comprises configuration hardware equipment, installation of an operating system and installation of a development tool;
S3, compiling a test script, namely firstly creating an automatic test flow by utilizing an RPA design tool, and then compiling the automatic script by utilizing an RPA development tool according to the designed test flow, wherein the script is used for simulating user operation, sending a request and receiving a response;
S4, integrated testing, namely combining an automatic testing process with a Continuous Integration (CI) process and a Continuous Deployment (CD) process to ensure that codes can automatically execute testing and timely find problems;
S5, executing a test script, namely running the written test script and performing automatic test;
s6, analyzing test results, namely analyzing test execution results, verifying whether the functions of the software accord with expectations or not, and simultaneously evaluating the effect of automatic test;
And S7, maintaining and updating the test script to ensure the continuity and effectiveness of the test.
Optionally, the hardware devices in the S2 building test framework comprise a server, a client device and a network device,
The development tools include automated, performance, and security test tools to support different types of testing.
Optionally, the step S3 of writing the test script is realized based on a script language of RPA, and the automatic test procedure creation comprises the steps of starting an RPA design tool, creating a project procedure, dragging out nodes and configuration information and conditions;
The automated testing includes interface automated testing and UI automated testing.
Optionally, the step of automatically testing the interface includes:
s31, organizing and managing parameters and expected results by using an interface test platform and form data;
S32, performing system login to obtain token identity verification, which is based on an information verification mode of RPA;
s33, acquiring parameters of the interface, and splicing the parameters into the interface;
s34, inquiring whether to configure SQL database inquiry language, and judging whether to use database configuration nodes to connect the database;
S35, configuring HTTP request nodes, assembling the acquired parameter information, and carrying out test interface requests;
s36, acquiring a field which is configured in the form data and participates in the assertion, extracting a field value to be asserted, comparing an expected result with an actual result, and filling the actual value of the test result into the form data;
the parameters and expected results include the address of the access API, the type of interface request, the entry, the database query result sql, the field name of the assertion, the expected result and whether testing is required
The UI automation test includes:
S37, acquiring a browser to be tested, and opening a corresponding browser by using a node;
s38, using navigation to a website to open the website;
s39, acquiring verification and logging in;
s310, acquiring actual values of the display values and the attribute values of the webpage elements, and comparing expected values.
Optionally, the S4 integrated test includes version control, automatic construction, trigger mechanism, execution test, result report, and continuous deployment;
the version control ensures that all test scripts and related resources are stored in the version control system;
Setting a CI server for automatically constructing an interface automatic test project;
The trigger mechanism is used for determining the time for triggering construction and testing of the CI server through a polling mechanism;
executing an automatic test script on the CI server;
the result report is that a detailed report is generated for the tested result;
The continuous deployment is to deploy the codes passing the test into the production environment so as to shorten the release period and improve the delivery speed.
Optionally, the automatic construction includes the steps of:
Step one, selecting corresponding construction tools according to the language and the framework of the project;
Step two, defining construction tasks and processes;
Integrating the construction process into a Continuous Integration (CI) tool;
step four, setting codes to be submitted to specific events in a code warehouse for triggering automatic construction;
Step five, after the triggering condition is met, the CI tool automatically detects codes, executes the construction script and generates corresponding output;
Step six, an automatic test is included in the construction process so as to ensure the code quality;
And step seven, after the construction is successful and all tests are passed, the test environment is further automatically deployed.
Optionally, in the step five automatic code detection process, the Jenkins automation server divides the construction process into a plurality of stages through a parallel construction mechanism, and the stages are respectively executed in parallel on a plurality of computers under the control of the server;
the automatic code detection in the fifth step and the automatic detection in the sixth step comprise incremental construction, wherein the incremental construction comprises the following steps:
Detecting a file which is changed from the last construction through a version control system;
when compiling the code again, only compiling the source code which is changed;
Running unit tests and integrated tests associated with the change code to ensure that the change does not introduce new errors;
and deploying the compiled file and the changed configuration into a test environment.
Optionally, the step of analyzing the S6 detection result includes:
After the test execution is completed, collecting all relevant test results including the execution condition (passing or failing), error information and screenshot of the test case;
Identifying failed test cases and analyzing failure reasons;
checking whether any abnormal conditions exist for the passed test cases;
Evaluating the test coverage rate, checking whether all the functional points are detected, and detecting whether missing test scenes exist or not, so as to judge whether corresponding test cases need to be supplemented or not;
According to the analysis result, corresponding improvement measures are formulated, including software defect repair, test case optimization and test strategy adjustment;
After implementing the improvement measure, re-executing the test case to verify whether the problem is solved;
The whole test process and results are consolidated into reports for knowing the overall condition and quality level of the test.
Optionally, the test coverage includes a demand coverage and a code coverage;
the evaluation of the requirement coverage rate is used for analyzing the corresponding relation between the requirement and the test case, so that the requirement is ensured to be completely converted into the test case and executed;
and the evaluation of the code coverage rate adopts a Git version control system, and a coverage rate report with incremental information is generated by combining coverage rate information.
Compared with the prior art, the invention has the beneficial effects that:
1. The RPA tool creates an automatic test script through a graphical interface and predefined operation without writing any code. The tester can define a complex test flow simply by dragging, clicking and configuring.
RPA tools are often designed to be intuitive and easy to use, and even a tester without any programming experience can quickly get his hands on. Through simple training and practice, the testers can master the basic skills of the automatic test.
2. The labor cost is reduced, and the automatic test can replace part of manual test work, so that the dependence on a large number of test staff is reduced. Enterprises can concentrate limited test resources on more complex and challenging test tasks, improving test efficiency and quality.
The test period is shortened, and the RPA tool can quickly construct and execute the automatic test script, so that the test period is greatly shortened. This helps the enterprise to release the product faster, preempt the market.
The automatic test reduces the possibility of human errors and improves the accuracy and reliability of the test. Meanwhile, through automatic error positioning and reporting, a tester can find out the problem and repair the problem more quickly, so that reworking time and cost are reduced.
3. Maintainability of scripts RPA tools typically provide script editing and management functionality so that testers can easily modify and maintain automated test scripts. When the test requirement changes, the tester only needs to simply adjust the script without writing a new script from the beginning, and the integration and expansibility that the RPA tool can be integrated with other test tools and systems generally to form a complete test solution. Meanwhile, with the development of technology and the change of test requirements, the RPA tool can be expanded and upgraded to meet new test requirements.
4. The RPA has a unique verification mode for a login system to be verified, can perform targeted system verification, and is convenient for a login interface to acquire a token.
Other features of the present invention and its advantages will become apparent from the following detailed description of exemplary embodiments of the invention, which proceeds with reference to the accompanying drawings.
Detailed Description
For a further understanding of the invention, its features and advantages, reference is now made to the following examples, which are illustrated in the accompanying drawings.
As shown in fig. 1 to 3, a method for performing an automated interface test based on RPA according to an embodiment of the present invention includes the following steps:
S1, making a test plan, namely analyzing the requirements of interface tests, determining the targets and the ranges of the tests, identifying test resources, determining test types and methods, making test strategies and determining quality standards;
s2, building a test framework, namely building an environment suitable for interface test, wherein the environment comprises configuration hardware equipment, installation of an operating system and installation of a development tool;
S3, compiling a test script, namely firstly creating an automatic test flow by utilizing an RPA design tool, and then compiling the automatic script by utilizing an RPA development tool according to the designed test flow, wherein the script is used for simulating user operation, sending a request and receiving a response;
S4, integrated testing, namely combining an automatic testing process with a Continuous Integration (CI) process and a Continuous Deployment (CD) process to ensure that codes can automatically execute testing and timely find problems;
S5, executing a test script, namely running the written test script and performing automatic test;
s6, analyzing test results, namely analyzing test execution results, verifying whether the functions of the software accord with expectations or not, and simultaneously evaluating the effect of automatic test;
And S7, maintaining and updating the test script to ensure the continuity and effectiveness of the test.
It should be noted that, at present, enterprises perform automated testing, and first, high initial investment and maintenance costs are required:
development of automated test frameworks, tools, and test scripts requires significant time and resources. For some small projects or rapidly iterated projects, automated testing may not be the most economical option.
As software systems are updated and changed, test scripts need to be continually updated and maintained, which also adds additional costs.
Secondly, the technical threshold is high, and the requirements on personnel skills are strict:
automated testing requires a tester to have certain programming and scripting capabilities, as well as in-depth knowledge of the test framework and tool usage. This requires that at least some of the members of the test team have a high level of skill.
When the skill of the tester is insufficient, the quality of the test script is possibly low, thereby affecting the accuracy and reliability of the test result
Third, strict dependence on test environment:
automated testing requires high consistency of the test environment, and any environmental differences may result in test failures. Accordingly, a great deal of effort is required in configuring and maintaining the test environment.
When a software operating environment changes (e.g., operating system upgrades, browser updates, etc.), the automated test scripts may need to be modified and adapted accordingly.
Fourth, special processing is needed for the system which can only log in with the verification code or the short message verification code.
Common processing methods are 1) requiring the development team to provide a version of the removal verification code or to set a generic verification code in the code. 2) Some third party verification code identification tools are used.
Further, automated testing essentially creates test scripts to test the code written by development, which does not cost significantly less than developing a product. The use of RPA can greatly shorten development time.
Furthermore, after the automatic test script is developed by the traditional automatic test, a professional automatic test engineer is required to maintain in a later operation stage, when an interface or an element is changed, the script is required to be changed, and meanwhile, the robustness of the script is required to be continuously improved. In the case of RPA, only a general procedure is required to be designed, and only the Xpath of an element needs to be picked up again by using the element picking function in the following step.
Specifically, the hardware devices in the S2 set up test framework comprise a server, a client device and a network device,
The development tools include automated, performance, and security test tools to support different types of testing.
Furthermore, the hardware requirements for building the test framework are mainly used for ensuring the stability and reliability of the test environment and simulating the real user use environment. The performance requirements are that the hardware resources such as servers, computers or mobile devices need to have enough processing capacity, memory capacity and storage space to run the test framework and execute the test cases, the compatibility requirements are that various operating systems, browser versions and mobile device models may be required in order to simulate the use environments of different users, and the network requirements are that network bandwidth and connection stability are critical to performing automated tests and accessing network resources (such as API tests).
Further, the software requirements include test tools for selecting proper test frames and tools, such as JUnit, selenium, appium, according to test types (such as unit test, integration test, functional test, etc.), development tools for compiling and maintaining test scripts, integrated Development Environments (IDE), compilers, code editors, etc., management tools for organizing test cases, tracking test results, and coordinating team cooperation, and auxiliary tools for hardware test, which may require specific instruments and equipment, such as oscilloscopes, spectrometers, etc.
In general, by meeting these hardware and software requirements, an effective test framework can be established that helps to improve test efficiency, discover potential problems, and ensure software quality.
The automatic test algorithm provided by the invention is shown in fig. 2 and 3, wherein the step S3 of writing test scripts is realized based on the script language of RPA, and the step S of creating the automatic test flow comprises the steps of starting an RPA design tool, creating a project flow, dragging out nodes, configuration information and conditions;
The automated testing includes interface automated testing and UI automated testing.
Further, the automatic test of the interface is mainly aimed at testing the back end or service interface of the system. Such testing methods typically do not care about the user interface, but rather verify that the interfaces between the various modules of the system are functioning properly. The interface test generally adopts a gray box test method, i.e. a test case is designed to call an API, and whether a request and a response meet expectations is checked, and the interface test has higher stability and efficiency because data and functions are focused on. Once the interface is well defined, the test case can be repeatedly executed multiple times without frequent modification;
Unlike interface automation testing, UI automation testing is closer to the behavior of a real user. It verifies whether the function of the application is operating properly by simulating the user's operation on the software interface. UI testing typically requires the use of tools such as Selenium to drive a browser or other user interface and to check that the results of the various user interactions are correct.
The interface automatic test step comprises the following steps:
s31, organizing and managing parameters and expected results by using an interface test platform and form data;
S32, performing system login to obtain token identity verification, which is based on an information verification mode of RPA;
s33, acquiring parameters of the interface, and splicing the parameters into the interface;
s34, inquiring whether to configure SQL database inquiry language, and judging whether to use database configuration nodes to connect the database;
S35, configuring HTTP request nodes, assembling the acquired parameter information, and carrying out test interface requests;
s36, acquiring a field which is configured in the form data and participates in the assertion, extracting a field value to be asserted, comparing an expected result with an actual result, and filling the actual value of the test result into the form data;
the parameters and expected results include the address of the access API, the type of interface request, the entry, the database query result sql, the field name of the assertion, the expected result and whether testing is required
The UI automation test includes:
S37, acquiring a browser to be tested, and opening a corresponding browser by using a node;
s38, using navigation to a website to open the website;
s39, acquiring verification and logging in;
s310, acquiring actual values of the display values and the attribute values of the webpage elements, and comparing expected values.
By adopting the scheme, the automatic test flow based on the RPA is simple to operate, the automatic flow design can be completed by only opening the RPA and pulling out the node and configuring, and the RPA has the scheme aiming at the verification system:
Aiming at the system of the verification code picture, an HTTP interface request node is used, a correct url and a request mode are configured to request to a verification code picture interface, a response is received, the code of the verification code picture is extracted from the response, then the code/decode node is used for decoding the verification code picture into a picture, a verification code identification node is configured, a corresponding verification code type is selected according to the verification code type, the verification code picture obtained in the last step is taken as a node reference, and an identification result can be obtained after the node is executed. Then using an HTTP request interface to configure an account password and a verification code identification result, and requesting a login interface to acquire a token;
Aiming at the system of the short message verification code, rong Zhi RPA is provided with a short message box, and a user can realize the automatic receiving and processing of the verification code by only inserting a telephone card into the short message box. Firstly, configuring an HTTP interface request node in Rong Zhi RPA, requesting the node to send an authentication code interface by using the HTTP interface request node, then acquiring a short message authentication code by using a received short message authentication code, and then acquiring a token by using an HTTP request login interface;
And Rong Zhi RPA can set task execution mode, timing, cron expression and other operations.
In the invention, the S4 integrated test comprises version control, automatic construction, a trigger mechanism, execution test, result report and continuous deployment;
the version control ensures that all test scripts and related resources are stored in the version control system;
it should be noted that version control is a key practice to ensure that all test scripts and related resources are properly stored and managed, and by tracking all code changes and histories, version control ensures that teams can work cooperatively while reducing the risk of errors and data loss during development. For example, when a developer edits code, the version control system may take snapshots for the code files and permanently save the snapshots so that they may be recalled later as needed. The technology not only helps the team to effectively manage project progress, but also improves development efficiency and code quality.
Setting a CI server for automatically constructing an interface automatic test project;
the automatic construction is to set up the interface automatic test project of the automatic construction of CI server, guarantee to carry on the process of constructing, testing and disposing immediately after the code is submitted, the automatic construction is a part of Continuous Integration (CI), aim to realize constructing and testing immediately after the code is changed, in order to guarantee the stability and consistency of the software function.
The trigger mechanism is used for determining the time for triggering construction and testing of the CI server through a polling mechanism;
The Polling mechanism (Polling) is a processing mode for making CPU query every peripheral equipment in turn according to a certain period to see if there is data input or output requirement, and its working principle is that the CPU continuously inquires about every I/O equipment according to a certain sequence, if the equipment has requirement, it can make correspondent data processing, if not, the CPU can continuously query next equipment
Executing an automatic test script on the CI server;
the result report is that a detailed report is generated for the tested result;
The continuous deployment is to deploy the codes passing the test into the production environment so as to shorten the release period and improve the delivery speed.
The method and the system have the advantages that the integrated test can check interaction and integration among a plurality of modules, the interface problem and the integrated problem which cannot be revealed in the unit test are found, so that the test coverage rate is improved, more potential problems such as data transmission errors, functional conflicts, logic errors and the like are facilitated to be discovered, the stability and the reliability of the system are guaranteed, the overall software quality is improved, the integrated test can be carried out at the early stage of software development to find problems early, the problem of the later integration is avoided, the development efficiency is improved, the reworking cost is reduced, the unit test can be carried out before the integrated test, the effect of the integrated test is guaranteed, the code error correction cost is reduced, the integrated test has good flexibility, different strategies and implementation modes such as a large explosion method and an increment method (top-down, bottom-up and sandwich method) can be adopted, and the most suitable test strategy can be selected according to the specific conditions of projects.
In summary, the integrated test is not only helpful to improve the overall quality and development efficiency of the software, but also ensure the correctness and stability of the system. By effectively integrating the test, the risk and cost after the software is released can be reduced to the maximum extent
Specifically, the automatic construction includes the steps of:
Step one, selecting corresponding construction tools according to the language and the framework of the project;
Build Tools (Build Tools) are software Tools for automating the process of building a software project, which can automatically perform a series of Build tasks such as compiling code, running tests, packaging and distributing, play a vital role in modern software development, and from automated compiling, testing to optimized deployment, the Build Tools significantly improve development efficiency and software quality.
Step two, defining construction tasks and processes;
Integrating the construction process into a Continuous Integration (CI) tool;
step four, setting codes to be submitted to specific events in a code warehouse for triggering automatic construction;
Step five, after the triggering condition is met, the CI tool automatically detects codes, executes the construction script and generates corresponding output;
Step six, an automatic test is included in the construction process so as to ensure the code quality;
And step seven, after the construction is successful and all tests are passed, the test environment is further automatically deployed.
In the step five, in the automatic code flow detection, a Jenkins automation server divides a construction process into a plurality of stages through a parallel construction mechanism, and the stages are respectively executed in parallel on a plurality of computers under the control of the server;
Furthermore, the parallel construction can improve the calculation speed, namely the construction task is decomposed into a plurality of subtasks to be executed in parallel, and the calculation resources of the multi-core processor and the computers can be fully utilized, so that the construction time is obviously shortened, the calculation capability is improved, the construction task is more flexible and flexible, and the project requirements of different scales and complexity can be met.
Under the condition of the multi-core processor, CPU resources can be fully utilized by parallel construction, and the throughput and the resource utilization rate of the system are improved.
The parallel construction brings remarkable advantages to the software development process by improving the computing speed, expanding computing resources, improving the reliability and stability, improving the resource utilization rate, reducing the waiting time, optimizing the user experience, saving the memory consumption and reducing the response time.
Specifically, the automatic code detection in the fifth step and the automatic detection in the sixth step include incremental construction, and the incremental construction includes the following steps:
Detecting a file which is changed from the last construction through a version control system;
when compiling the code again, only compiling the source code which is changed;
Running unit tests and integrated tests associated with the change code to ensure that the change does not introduce new errors;
and deploying the compiled file and the changed configuration into a test environment.
Further, incremental construction is achieved by monitoring changes in the inputs. If the input is detected to be changed, the construction system can re-execute the related tasks, otherwise, the construction of the unchanged part can be skipped, and the result of the last construction is directly used.
This approach significantly improves the efficiency of construction, especially in large projects. In the incremental build process, each build task is divided into three parts, input, the task itself, and output. The input may be source code, configuration files, etc., and the output is typically a compiled class file or a packaged archive file.
Furthermore, incremental construction is not only applied to the compilation stage, but also to the testing and deployment stages. In a continuous integration and continuous deployment (CI/CD) process, incremental construction can quickly feed back construction and test results, helping development teams to discover and solve problems in time.
In general, incremental construction is an important construction optimization technology in modern software development, and by intelligently identifying and processing the change part, the construction efficiency is remarkably improved, the feedback period is shortened, and the requirement of rapid iterative development is met.
Specifically, the step of analyzing the S6 detection result includes:
After the test execution is completed, collecting all relevant test results including the execution condition (passing or failing), error information and screenshot of the test case;
Identifying failed test cases and analyzing failure reasons;
checking whether any abnormal conditions exist for the passed test cases;
Evaluating the test coverage rate, checking whether all the functional points are detected, and detecting whether missing test scenes exist or not, so as to judge whether corresponding test cases need to be supplemented or not;
According to the analysis result, corresponding improvement measures are formulated, including software defect repair, test case optimization and test strategy adjustment;
After implementing the improvement measure, re-executing the test case to verify whether the problem is solved;
The whole test process and results are consolidated into reports for knowing the overall condition and quality level of the test.
The test coverage rate comprises a demand coverage rate and a code coverage rate;
the evaluation of the requirement coverage rate is used for analyzing the corresponding relation between the requirement and the test case, so that the requirement is ensured to be completely converted into the test case and executed;
and the evaluation of the code coverage rate adopts a Git version control system, and a coverage rate report with incremental information is generated by combining coverage rate information.
Further, the test coverage rate is an important test technical index, and is used for balancing the coverage condition of the test case on the software codes, and the test coverage rate shows how many proportion of codes are actually operated and tested when the test case is executed. This helps identify which code regions have not yet been tested, or are under-tested, requiring additional test cases to cover, and by testing coverage we can evaluate the quality of the test cases as an indicator of risk of evaluating the project to ensure quality and reliability of the software.
In summary, the invention performs the automated interface test based on the RPA, first analyzes the test requirements according to the software requirement specification and the system test cases, determines which test scenes and test cases, and designs the automated test cases capable of covering all the requirement points;
maintaining url of the interface, interface request type, entering into the database, inquiring result sql, field name asserted, expected result, whether testing is needed or not, logging in the interface to obtain token,
If the interface is maintained by the interface automation platform mode, the interface is sequentially acquired by using HTTP request interface in the RPA, and variable processing related nodes are used for carrying out parameter entering processing and splicing;
Acquiring table data or whether query SQL is configured in an interface platform mode, if so, connecting a database by using a database configuration node, and executing the acquired SQL by using an execution SQL node;
then configuring HTTP request nodes, configuring acquired URLs, entries, token and the like, and requesting test interfaces;
Finally, the fields which are configured in the form data and participate in the assertion are obtained, the field values to be asserted are extracted from the response values requested by the previous interface by using the regular extraction nodes, the expected results and the actual results are compared by using the nodes such as variable comparison and the like, and the test results, the actual values and the like are written into the form data, so that the automatic flow design is completed. Compared with the existing automatic test, the automatic test device has the advantages that the automatic test device is more superior to common testers, the functions of script editing and management are provided, so that testers can conveniently modify and maintain the automatic test scripts, part of manual test work is replaced, and dependence on a large number of testers is reduced.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made therein without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.