CN116361157A - Automated testing method and device, electronic equipment and computer readable storage medium - Google Patents

Automated testing method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN116361157A
CN116361157A CN202310242182.2A CN202310242182A CN116361157A CN 116361157 A CN116361157 A CN 116361157A CN 202310242182 A CN202310242182 A CN 202310242182A CN 116361157 A CN116361157 A CN 116361157A
Authority
CN
China
Prior art keywords
test
cases
case
test case
operations
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
CN202310242182.2A
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.)
Wuhan Sipuling Technology Co Ltd
Original Assignee
Wuhan Sipuling 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 Wuhan Sipuling Technology Co Ltd filed Critical Wuhan Sipuling Technology Co Ltd
Priority to CN202310242182.2A priority Critical patent/CN116361157A/en
Publication of CN116361157A publication Critical patent/CN116361157A/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
    • G06F11/368Test management for test version control, e.g. updating test cases to a new software version
    • 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
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention relates to an automatic test method, an automatic test device, electronic equipment and a computer readable storage medium, wherein the method comprises the following steps: generating a plurality of test cases for software to be tested with the same business logic flow based on an automatic test tool, wherein each test case comprises a plurality of test operations; taking any one of the plurality of test cases as a first test case, taking the rest of the plurality of test cases as a second test case, merging the test operations of the plurality of test cases into the first test case according to the same business logic flow, and deleting redundant test operations; the second test case is decorated based on a decorator so that the number of test cases corresponds to a manual test. The invention reduces the redundancy of the automatic test codes and improves the efficiency of the automatic test.

Description

Automated testing method and device, electronic equipment and computer readable storage medium
Technical Field
The present invention relates to the field of automated testing technologies, and in particular, to an automated testing method and apparatus, an electronic device, and a computer readable storage medium.
Background
In software testing activities, automated testing is often used to replace part of manual testing to achieve the goal of improving testing efficiency.
An automated test program based on a Web page often requires simulating operations such as opening the page, inputting, clicking, jumping and the like by a user. For automated test procedures, these simulated manual operations are time consuming, and may take tens of seconds or even tens of seconds to execute a use case. When the use case reaches a certain order of magnitude, the execution process of the whole test item may reach tens of hours or even tens of hours. In the same business logic flow, a large number of repeated and redundant test operations exist in different test cases, which greatly limits the execution efficiency of automated test projects and the flexibility of the deployment of the automated tests into the software development flow.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an automated testing method for solving the problem of low execution efficiency caused by redundant operations in test cases in the automated test.
In order to solve the above problems, the present invention provides an automated testing method, comprising: generating a plurality of test cases for software to be tested with the same business logic flow based on an automatic test tool, wherein each test case comprises a plurality of test operations;
taking any one of the plurality of test cases as a first test case, taking the rest of the plurality of test cases as a second test case, merging the test operations of the plurality of test cases into the first test case according to the same business logic flow, and deleting redundant test operations;
the second test case is decorated based on a decorator so that the number of test cases corresponds to a manual test.
In some possible implementations, generating a plurality of test cases for software to be tested having a same business logic flow based on an automated test tool, each test case including a plurality of test operations, includes:
acquiring the operation of a user on a control on a Web page of software to be tested, and generating test operation;
and generating a plurality of test cases according to the plurality of test operations.
In some possible implementations, the operation of the control by the user includes: at least one of entry of a text box, clicking of a button, and clicking of a hyperlink.
In some possible implementations, the number of test cases are executed to obtain a log file.
In some possible implementations, the executing the number of test cases includes:
judging whether the second test case is executed or not, if so, taking out the executed log file, and if not, calling the first test case and executing.
In some possible implementations, decorating the second test case based on a decorator includes:
a decorator code is defined and written before the second test case.
In some possible implementations, the number of test cases includes:
creating a user test case, editing the user test case, and deleting the user test case.
In another aspect, the present invention also provides an apparatus for automated testing, including:
the test case acquisition unit is used for generating a plurality of test cases for the software to be tested with the same business logic flow based on the automatic test tool, wherein each test case comprises a plurality of test operations;
the test case distribution unit is used for taking any one of the plurality of test cases as a first test case, taking the rest of the plurality of test cases as a second test case, merging the test operations of the plurality of test cases into the first test case according to the same business logic flow, and deleting redundant test operations;
and the test case decorating unit is used for decorating the second test cases based on a decorator so that the plurality of test cases correspond to manual tests.
In another aspect, the invention also provides an electronic device comprising a memory and a processor, wherein,
the memory is used for storing programs;
the processor is coupled to the memory and is configured to execute the program stored in the memory to implement the steps of an automated test method described in any one of the implementations.
In another aspect, the present invention also provides a computer readable storage medium storing a computer readable program or instructions that, when executed by a processor, implement the steps of an automated test method according to any one of the above implementations.
The beneficial effects of adopting the embodiment are as follows: according to the automatic test method provided by the invention, a plurality of test cases are generated according to an automatic test tool, then the plurality of test cases are combined into one test case according to the business logic flow of the plurality of test cases, and the rest test cases are decorated by a decorator, so that the automatic test cases correspond to manual tests. The invention combines the test case operations of the same business logic flow and deletes the redundant test operation, thereby reducing the code redundancy and improving the efficiency of automatic test execution.
Drawings
FIG. 1 is a flow chart of an automated test method according to one embodiment of the present invention;
FIG. 2 is a schematic structural view of an embodiment of an automated testing apparatus according to the present invention;
fig. 3 is a schematic structural diagram of an embodiment of an electronic device according to the present invention.
Detailed Description
Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form a part hereof, and together with the description serve to explain the principles of the invention, and are not intended to limit the scope of the invention.
For automated test procedures, these simulated manual operations are time consuming, and may take tens of seconds or even tens of seconds to execute a use case. When the use case reaches a certain order of magnitude, the execution process of the whole test item may reach tens of hours or even tens of hours. In the same business logic flow, there are a large number of repeated and redundant test operations, such as deduplication operations, in different test cases.
Therefore, in the software automation test in the prior art, there is a problem that the automation test efficiency is low due to a large number of repeated and redundant test operations.
In order to solve the above problems, embodiments of the present invention provide an automated testing method, an apparatus, an electronic device, and a computer readable storage medium, and will now be described in detail.
Fig. 1 is a flowchart of a method according to an embodiment of an automated testing method provided by the present invention, as shown in fig. 1, an automated testing method includes:
s101, generating a plurality of test cases for software to be tested with the same business logic flow based on an automatic test tool, wherein each test case comprises a plurality of test operations;
s102, taking any one of the plurality of test cases as a first test case, taking the rest of the plurality of test cases as a second test case, merging the test operations of the plurality of test cases into the first test case according to the same business logic flow, and deleting redundant test operations;
s103, decorating the second test cases based on a decorator so that the plurality of test cases correspond to manual tests.
Compared with the prior art, the automatic test method provided by the embodiment has the advantages that a plurality of test cases are generated according to an automatic test tool, then the plurality of test cases are combined into one test case according to the business logic flow of the plurality of test cases, and the rest of test cases are decorated by a decorator, so that the automatic test cases correspond to manual tests. The invention combines the test case operations of the same business logic flow and deletes the redundant test operation, thereby reducing the code redundancy and improving the efficiency of automatic test execution.
In step S101, a Web automation test includes a Selenium, robotframe work, cuum, and the like. For example, selenium is a tool for Web application testing. The Selenium test runs directly in the browser as if the real user were operating. The supported browsers include IEs (7, 8,9, 10, 11), mozilla Firefox, safari, google Chrome, opera, edge, etc. The main functions of this tool include: testing compatibility with browsers-testing applications see if they can work well on top of different browsers and operating systems. Test system functions-create regression tests verify software functions and user requirements. Supporting automatic recording action and automatic generation of test scripts in different languages, such as Net, java, perl.
In some embodiments of the present invention, a plurality of test cases are generated for software to be tested having a same business logic flow based on an automated test tool, each test case including a plurality of test operations, including:
acquiring the operation of a user on a control on a Web page of software to be tested, and generating test operation;
and generating a plurality of test cases according to the plurality of test operations.
In some embodiments of the present invention, the operation of the control by the user includes: at least one of entry of a text box, clicking of a button, and clicking of a hyperlink. In other embodiments, the user's operation of the control also includes selection of a radio box, selection of a check box, and the like.
In some embodiments of the present invention, the plurality of test cases are executed to obtain a log file.
In some embodiments of the present invention, the executing the number of test cases includes:
judging whether the second test case is executed or not, if so, taking out the executed log file, and if not, calling the first test case and executing.
In order to make the automated test cases correspond to the manual tests. Decorators are a grammatical format of Python. In some embodiments of the invention, decorating the second test case based on a decorator includes:
a decorator code is defined and written before the second test case.
In some embodiments of the invention, the number of test cases includes:
creating a user test case, editing the user test case, and deleting the user test case.
To further illustrate the automated testing method of embodiments of the present invention, a specific embodiment will now be described.
Assume that there are 3 manual test cases, for example, take a create user, an edit user and a delete user as examples, and the corresponding operation requirements are as follows:
1. creating a user: creating a user and checking whether the user can log in;
2. editing users: editing a user and checking whether the user can log in with the edited user;
3. deleting the user: deleting the user and checking whether the user has failed to log in
Firstly, generating a plurality of test cases for software to be tested with the same business logic flow based on an automatic test tool, namely: the following codes are generated from the recordings of automated test equipment:
Figure BDA0004124668880000061
Figure BDA0004124668880000071
then, merging the test operations of the plurality of test cases into the first test case and deleting redundant test operations according to the same business logic flow, namely: merging the test operations of the same business logic flow, namely merging the test operations in two test cases, namely test_wait_user () and test_delete_user (), into test_create_user (), and deleting redundant test operations to obtain the following code:
Figure BDA0004124668880000072
Figure BDA0004124668880000081
in order to correspond the automated test to the manual test, a decorator was designed to decorate two test cases, test_wait_user () and test_delete_user (), the code defining the decorator is as follows:
Figure BDA0004124668880000082
this decorator can decorate both test cases, test_wait_user () and test_delete_user (), these 2 cases point to test_create_user, indicating that this case is referenced because the relevant test contents have been covered in the test_create_user. For the test contents, the test contents are put in the use case description. A decorator @ refed is also needed to indicate that this use case is the use case being referenced. The complete use case is as follows:
Figure BDA0004124668880000083
Figure BDA0004124668880000091
the corresponding relation of the use cases is solved, and the execution process of the automatic use cases is performed next. Since the automation cases are independent from each other, the following conditions are satisfied for realizing the logic overall:
1) Regardless of the order in which the use cases are executed, each use case can get a test result, and the referencing and the referenced use cases are executed only once;
2) Whether the referenced or referenced use case is specified solely for execution, test results may be obtained with the execution content pointing to the referenced use case.
Specific execution logic is illustrated as follows:
1) When the test_create_user is executed, it is checked whether the use case is executed
the test_wait_user or the test_delete_user references are executed, if the content in the test_wait_user is not executed, if the content is referenced and executed, the executed log is directly obtained;
2) When the test_wait_user or the test_delete_user is executed, checking whether the referenced use case test_create_user is executed or not, calling the test_create_user to execute if the referenced use case test_create_user is not executed, and directly acquiring an executed log if the referenced use case test_create_user is executed.
In this embodiment, it can be seen that the total of three test cases, namely, test_create_user, test_wait_user and test_delete_user, is reduced from 10 test operations to 6 test operations, so that the execution efficiency can be improved by 40%.
In order to better implement an automated testing method in the embodiment of the present invention, correspondingly, as shown in fig. 2, on the basis of the automated testing method, an apparatus for automated testing is further provided in the embodiment of the present invention, where an apparatus 200 for automated testing includes:
the test case acquisition unit 201 is configured to generate a plurality of test cases for software to be tested having the same service logic flow based on an automated test tool, where each test case includes a plurality of test operations;
the test case allocation unit 202 is configured to take any one of the plurality of test cases as a first test case, take the rest of the plurality of test cases as a second test case, merge the test operations of the plurality of test cases into the first test case according to the same business logic flow, and delete redundant test operations;
the test case decorating unit 203 is configured to decorate the second test case based on a decorator, so that the plurality of test cases correspond to a manual test.
The automatic test device 200 provided in the foregoing embodiment may implement the technical solution described in the foregoing embodiment of an automatic test method, and the specific implementation principle of each module or unit may refer to the corresponding content in the foregoing embodiment of an automatic test method, which is not described herein again.
As shown in fig. 3, the present invention further provides an electronic device 300 accordingly. The electronic device 300 comprises a processor 301, a memory 302 and a display 303. Fig. 3 shows only some of the components of the electronic device 300, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead.
The processor 301 may in some embodiments be a central processing unit (Central Processing Unit, CPU), microprocessor or other data processing chip for executing program code or processing data stored in the memory 302, such as an automated test method of the present invention.
In some embodiments, processor 301 may be a single server or a group of servers. The server farm may be centralized or distributed. In some embodiments, the processor 301 may be local or remote. In some embodiments, processor 301 may be implemented in a cloud platform. In an embodiment, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an inter-internal, multiple clouds, or the like, or any combination thereof.
The memory 302 may be an internal storage unit of the electronic device 300 in some embodiments, such as a hard disk or memory of the electronic device 300. The memory 302 may also be an external storage device of the electronic device 300 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the electronic device 300.
Further, the memory 302 may also include both internal storage units and external storage devices of the electronic device 300. The memory 302 is used for storing application software and various types of data for installing the electronic device 300.
The display 303 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like in some embodiments. The display 303 is used for displaying information at the electronic device 300 and for displaying a visual user interface. The components 301-303 of the electronic device 300 communicate with each other via a system bus.
In one embodiment, when the processor 301 executes an automated test program in the memory 302, the following steps may be implemented:
generating a plurality of test cases for software to be tested with the same business logic flow based on an automatic test tool, wherein each test case comprises a plurality of test operations;
any one test case in the plurality of test cases is a first test case, the rest test cases in the plurality of test cases are second test cases, and the test operations of the plurality of test cases are combined into the first test case and redundant test operations are deleted according to the same business logic flow;
the second test case is decorated based on a decorator so that the number of test cases corresponds to a manual test.
It should be understood that: the processor 301 may perform other functions in addition to the above, in performing an automated test in the memory 302, see in particular the description of the corresponding method embodiments above.
Further, the type of the electronic device 300 is not particularly limited, and the electronic device 300 may be a mobile phone, a tablet computer, a personal digital assistant (personal digital assistant, PDA), a wearable device, a laptop (laptop), or other portable electronic devices. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices that carry IOS, android, microsoft or other operating systems. The portable electronic device described above may also be other portable electronic devices, such as a laptop computer (laptop) or the like having a touch-sensitive surface, e.g. a touch panel. It should also be appreciated that in other embodiments of the invention, the electronic device 300 may not be a portable electronic device, but rather a desktop computer having a touch-sensitive surface (e.g., a touch panel).
Those skilled in the art will appreciate that all or part of the flow of the methods of the embodiments described above may be accomplished by way of a computer program to instruct associated hardware, where the program may be stored on a computer readable storage medium. Wherein the computer readable storage medium is a magnetic disk, an optical disk, a read-only memory or a random access memory, etc.
The present invention is not limited to the above-mentioned embodiments, and any changes or substitutions that can be easily understood by those skilled in the art within the technical scope of the present invention are intended to be included in the scope of the present invention.

Claims (10)

1. An automated testing method, comprising:
generating a plurality of test cases for software to be tested with the same business logic flow based on an automatic test tool, wherein each test case comprises a plurality of test operations;
taking any one of the plurality of test cases as a first test case, taking the rest of the plurality of test cases as a second test case, merging the test operations of the plurality of test cases into the first test case according to the same business logic flow, and deleting redundant test operations;
the second test case is decorated based on a decorator so that the number of test cases corresponds to a manual test.
2. The automated testing method of claim 1, wherein generating a plurality of test cases for software to be tested having a same business logic flow based on the automated testing tool, each test case including a plurality of test operations, comprises:
acquiring the operation of a user on a control on a Web page of software to be tested, and generating test operation;
and generating a plurality of test cases according to the plurality of test operations.
3. An automated testing method according to claim 2, wherein the user manipulation of the control comprises: at least one of entry of a text box, clicking of a button, and clicking of a hyperlink.
4. The automated test method of claim 1, further comprising:
and executing the test cases to obtain a log file.
5. The automated test method of claim 4, wherein the executing the plurality of test cases comprises:
judging whether the second test case is executed or not, if so, taking out the executed log file, and if not, calling the first test case and executing.
6. The automated test method of claim 1, wherein decorating the second test case based on a decorator comprises:
a decorator code is defined and written before the second test case.
7. The automated test method of claim 1, wherein the plurality of test cases comprises:
creating a user test case, editing the user test case, and deleting the user test case.
8. An automated test equipment, comprising:
the test case acquisition unit is used for generating a plurality of test cases for the software to be tested with the same business logic flow based on the automatic test tool, wherein each test case comprises a plurality of test operations;
the test case distribution unit is used for taking any one of the plurality of test cases as a first test case, taking the rest of the plurality of test cases as a second test case, merging the test operations of the plurality of test cases into the first test case according to the same business logic flow, and deleting redundant test operations;
and the test case decorating unit is used for decorating the second test cases based on a decorator so that the plurality of test cases correspond to manual tests.
9. An electronic device comprising a memory and a processor, wherein,
the memory is used for storing programs;
the processor, coupled to the memory, is configured to execute the program stored in the memory to implement the steps of an automated test method according to any of the preceding claims 1 to 7.
10. A computer readable storage medium storing a computer readable program or instructions which when executed by a processor is capable of carrying out the steps of an automated test method according to any one of claims 1 to 7.
CN202310242182.2A 2023-03-09 2023-03-09 Automated testing method and device, electronic equipment and computer readable storage medium Pending CN116361157A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310242182.2A CN116361157A (en) 2023-03-09 2023-03-09 Automated testing method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310242182.2A CN116361157A (en) 2023-03-09 2023-03-09 Automated testing method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN116361157A true CN116361157A (en) 2023-06-30

Family

ID=86906186

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310242182.2A Pending CN116361157A (en) 2023-03-09 2023-03-09 Automated testing method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN116361157A (en)

Similar Documents

Publication Publication Date Title
CN109542399B (en) Software development method and device, terminal equipment and computer readable storage medium
US20170052824A1 (en) Method and system for process automation in computing
CN110688142B (en) Method, device and storage medium for publishing application programming interface
US20160306612A1 (en) Determining errors and warnings corresponding to a source code revision
CN107357593A (en) Source code file construction method, device, electric terminal and readable storage medium storing program for executing
CN109388376B (en) Software development risk assessment method, device, equipment and readable storage medium
CN105528418A (en) Design document generation method and apparatus
US7761841B1 (en) Enhanced data loading for test management tool
US10572247B2 (en) Prototype management system
CN112905262A (en) Configuration method and device of aerospace measurement and control system
CN110688145B (en) Android MVP code automatic generation method and device, medium and electronic equipment
CN102982217A (en) Processing method and device of screen print
CN104182266B (en) A kind of application installation method and device
US20140057231A1 (en) Break-fix simulator
US20170140009A1 (en) Caching linked queries for optimized compliance management
US20150378784A1 (en) Work flow level job input/output
US20150081874A1 (en) Operation process creation program, operation process creation method, and information processing device
Uluca Angular 6 for Enterprise-Ready Web Applications: Deliver production-ready and cloud-scale Angular web apps
CN116361157A (en) Automated testing method and device, electronic equipment and computer readable storage medium
CN105446785A (en) Method and system for unloading application program
CN114398282A (en) Test script generation method, device, equipment and storage medium
CN108241607A (en) Automatically imported method, server and the storage medium of test of heuristics case
CN113886741A (en) Method for typesetting formula and related product
CN113312900A (en) Data verification method and device
CN112988583A (en) Method and device for testing syntax compatibility of database

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