CN112631911A - 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
CN112631911A
CN112631911A CN202011532148.1A CN202011532148A CN112631911A CN 112631911 A CN112631911 A CN 112631911A CN 202011532148 A CN202011532148 A CN 202011532148A CN 112631911 A CN112631911 A CN 112631911A
Authority
CN
China
Prior art keywords
test
case
test case
queue
cases
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
CN202011532148.1A
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 Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011532148.1A priority Critical patent/CN112631911A/en
Publication of CN112631911A publication Critical patent/CN112631911A/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/3688Test management for test execution, e.g. scheduling of test suites
    • 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

Abstract

The embodiment of the application belongs to the technical field of cloud, and relates to an automatic test method, which comprises the steps of obtaining all test cases corresponding to a test instruction and the test type of each test case based on a preset test case table when the test instruction is received; determining a target service of each test case according to the test type, acquiring a test queue corresponding to the test case, and sending the test case to the target service based on the test queue so that the target service executes the test case; and acquiring a first execution result of the test case, and generating a test report of the test case according to the first execution result. The application also provides an automatic testing device, computer equipment and a storage medium. In addition, the application also relates to a block chain technology, and the test report can be stored in the block chain. The application improves the testing efficiency.

Description

Automatic testing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of cloud technologies, and in particular, to an automated testing method and apparatus, a computer device, and a storage medium.
Background
Currently, there are more and more application scenarios that require application to automated testing, such as interface automated testing, APP automated testing for clients, UI automated testing for web pages, and automated testing of some performance. Through different function tests under different scenes, the stability of functions or applications can be ensured.
However, the existing automated testing can only be performed for a certain scenario, for example, only an interface or only a UI, but cannot be performed for the same scenario, which results in a technical problem of low testing efficiency.
Disclosure of Invention
An embodiment of the present application provides an automated testing method, an automated testing device, a computer device, and a storage medium, so as to solve the technical problem of low testing efficiency.
In order to solve the above technical problem, an embodiment of the present application provides an automated testing method, which adopts the following technical solutions:
when a test instruction is received, acquiring all test cases corresponding to the test instruction and the test type of each test case based on a preset test case table;
determining a target service of each test case according to the test type, acquiring a test queue corresponding to the test case, and sending the test case to the target service based on the test queue so that the target service executes the test case;
and acquiring a first execution result of the test case, and generating a test report of the test case according to the first execution result.
Further, the step of sending the test case to the target service based on the test queue specifically includes:
combining the test cases into a test plan, and determining whether the test types of the test cases in each test plan are the same when the test cases are combined into a plurality of different test plans;
and when the test types of the test cases in each test plan are different, respectively issuing the test plans to different test queues, and asynchronously sending the test plans to corresponding target services based on the different test queues.
Further, the step of asynchronously sending the test plan to the corresponding target service based on the different test queues includes:
acquiring a state identifier of a current test queue, and detecting whether the current test queue is full or not according to the state identifier;
when the current test queue is full, newly adding an asynchronous queue into a thread pool, and sending the test plan to a corresponding target service based on the asynchronous queue;
and when the current test queue is not full, sending the test plan to a corresponding target service based on the current test queue.
Further, the step of combining the test cases into a test plan specifically includes:
acquiring test functions of all the test cases, and determining whether the test cases are in the same test plan according to the test functions;
and when the test functions of the test cases are the same, determining that the test cases with the same test function are the same test plan.
Further, the step of obtaining the first execution result of the test case specifically includes:
when the test case is executed, performing assertion detection on the test case;
if the expected value of the test case, which is detected through the assertion, is consistent with the actual value, the test case is determined to be tested successfully, and the test case is marked as a test success case;
and if the expected value and the actual value obtained by the test case through the assertion detection are inconsistent, determining that the test case fails to test, and marking the test case as a test failure case.
Further, the step of generating the test report of the test case according to the first execution result specifically includes:
acquiring a second execution result of the test case, and calculating a comprehensive score of the test case according to the first execution result and the second execution result;
and generating a test report of the test case according to the comprehensive score.
Further, when the test instruction is received, the step of obtaining all test cases corresponding to the test instruction based on a preset test case table and the test type of each test case further includes:
the method comprises the steps of obtaining a preset pretest case based on a rear-end interface, displaying the pretest case on a front-end page through a preset function, and receiving a test instruction of the pretest case based on the front-end page.
In order to solve the above technical problem, an embodiment of the present application further provides an automatic testing apparatus, which adopts the following technical scheme:
the acquisition module is used for acquiring all test cases corresponding to the test instruction and the test type of each test case based on a preset test case table when the test instruction is received;
the sending module is used for determining the target service of each test case according to the test type, acquiring a test queue corresponding to the test case, and sending the test case to the target service based on the test queue so that the target service executes the test case;
and the generating module is used for acquiring a first execution result of the test case and generating a test report of the test case according to the first execution result.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which includes a memory and a processor, and computer readable instructions stored in the memory and executable on the processor, where the processor implements the steps of the above automated testing method when executing the computer readable instructions.
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, where computer-readable instructions are stored, and when executed by a processor, the computer-readable instructions implement the steps of the above automated testing method.
According to the automatic test method, when the test instruction is received, all test cases corresponding to the test instruction and the test type of each test case are obtained based on the preset test case table, so that the test cases can be uniformly managed and tested through the preset test case table; then, determining the target service of each test case according to the test type, acquiring a test queue corresponding to the test case, and sending the test case to the target service based on the test queue so that the target service executes the test case, and the test case can be sent through the test queue, thereby avoiding test blockage; and then, a first execution result of the test case is obtained, and a test report of the test case is generated according to the first execution result, so that the unified automatic test of the test case is realized, the blockage during the test case execution is avoided, the test time is saved, the test efficiency is improved, and the maintenance cost is reduced.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of an automated testing method according to the present application;
FIG. 3 is a schematic block diagram of one embodiment of an automated test equipment according to the present application;
FIG. 4 is a schematic block diagram of one embodiment of a computer device according to the present application.
Reference numerals: the automatic testing device comprises an automatic testing device 300, an acquisition module 301, a sending module 302 and a generating module 303.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that the automated testing method provided in the embodiments of the present application is generally executed by a server/terminal device, and accordingly, the automated testing apparatus is generally disposed in the server/terminal device.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow diagram of one embodiment of a method of automated testing is shown, in accordance with the present application. The automatic testing method comprises the following steps:
step S201, when a test instruction is received, all test cases corresponding to the test instruction and the test type of each test case are obtained based on a preset test case table;
in this embodiment, when a test instruction is received, a preset test case table is obtained, where the test case table includes a plurality of preset test cases and test types related to the preset test cases, and the test cases are packaged into a test script to be displayed in the test case table. The test type is the root directory name of the test script corresponding to each test case in the test case table, and represents the test scenario type, such as the interface test type and the application test type. When a test instruction is received, a preset test case table is obtained, all test cases corresponding to the test instruction are obtained based on the test case table, and the test script corresponding to the test cases is analyzed, so that the test type of each test case can be determined.
Step S202, determining a target service of each test case according to the test type, acquiring a test queue corresponding to the test case, and sending the test case to the target service based on the test queue so that the target service executes the test case;
in this embodiment, when determining the test case and the test type corresponding to the test instruction, the corresponding target service is determined according to the test type of each test case, and the test queue corresponding to the test case is obtained. And when the test queue is obtained, the test plan is issued to the test queue, and the test case is sent to a target service based on the test queue. When the test case is sent to the target service based on the test queue, the test plans can be sent from small to large according to the sending time of the test plans, and the test case in the test plan is sent to the corresponding target service, so that the target service executes the test case. And when different target services receive the corresponding test cases, executing the test cases according to different execution strategies.
For example, 10 test cases in the current test case table may be determined according to the test instruction, where the test type of 3 test cases is an api type, the test type of 3 test cases is an app type, and the test type of 4 test cases is a ui type.
The api type test case corresponds to the target service of the api test, a test suite (test suite) corresponding to the test case is constructed based on the target service and is sent to a pytest framework for execution, and when the execution of the pytest framework is completed, an execution result is written into a database;
the test case of the app type corresponds to a target service of the app test, when the test case of the app type is obtained, the test case is sent to an appium server, the appium server is always in a monitoring state, and when the appium server receives the test case, specific operation is executed according to a test script of the test case;
the ui type test case corresponds to a target service of the ui test, and when the ui type test case is obtained, a related web driver (such as chrome or firefox) is started, the web driver starts a browser and executes a corresponding click operation, and the execution result is written into the database.
Step S203, obtaining a first execution result of the test case, and generating a test report of the test case according to the first execution result.
In this embodiment, when it is detected that the target service completes executing the test cases, a first execution result of each test case is obtained, where the first execution result is a current execution result of each test case, for example, the first execution result of the test case that fails to be tested is a failure, and the first execution result of the test case that succeeds to be tested is a success. And generating a corresponding test report according to the first execution results of all the test cases currently participating in the test. The test report reflects the execution condition of each test case.
It should be emphasized that, in order to further ensure the privacy and security of the test report, the test report may also be stored in a node of a block chain.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The embodiment realizes the unified automatic test of the test case, avoids the blockage when the test case is executed, saves the test time, improves the test efficiency and reduces the maintenance cost.
In some embodiments of the present application, the sending the test case to the target service based on the test queue includes:
combining the test cases into a test plan, and determining whether the test types of the test cases in each test plan are the same when the test cases are combined into a plurality of different test plans;
and when the test types of the test cases in each test plan are different, respectively issuing the test plans to different test queues, and asynchronously sending the test plans to corresponding target services based on the different test queues.
In this embodiment, when obtaining the test cases, the test cases may be grouped into a plurality of different test plans, and the different test plans may include test cases of the same or different test types. When the test cases respectively form a plurality of different test plans, the test plans can be issued to the same test queue, and different test plans can be issued to different test queues, so that the multiple test plans can be executed simultaneously. Specifically, when the test cases respectively form a plurality of different test plans, determining whether the test types of the test cases in each test plan are the same, and if the test types of the test cases in each test plan are the same, distributing the plurality of test plans into the same test queue or different test queues; and when the test case in the test plan is sent to the target service, sending the test case according to the time sequence of adding the test plan to the test queue. If the test types of the test cases in each test plan are different, the different test plans are issued to different test queues, and the test cases in each test plan are asynchronously sent (namely, sent simultaneously) to the corresponding target service according to the different test queues, so that the simultaneous execution of a plurality of test plans is realized.
The embodiment combines the test cases into the test plan and sends the test plan through the test queue, thereby realizing the asynchronous test of the test cases, improving the test efficiency of the test cases and avoiding test blockage.
In some embodiments of the present application, the asynchronously sending the test plan to the corresponding target service based on the different test queues includes:
acquiring a state identifier of a current test queue, and detecting whether the current test queue is full or not according to the state identifier;
when the current test queue is full, newly adding an asynchronous queue into a thread pool, and sending the test plan to a corresponding target service based on the asynchronous queue;
and when the current test queue is not full, sending the test plan to a corresponding target service based on the current test queue.
In this embodiment, when obtaining the test queue corresponding to the test plan, it is further required to obtain a status identifier of the current test queue, and determine whether the current test queue is full according to the status identifier. For example, when the status flags are busy and offline, it is determined that the current test queue is full. And when the current test queue is full, adding a free asynchronous queue, adding the asynchronous queue into the thread pool, and sending the current test plan based on the asynchronous queue. And if the current test queue is determined to be not full according to the state identifier, issuing the current test plan to the current test queue, and sending the test plan to the target service according to the current test queue.
According to the embodiment, the test cases are sent to different test queues, so that test blockage is avoided, and the test efficiency is further improved.
In some embodiments of the present application, combining the test case into a test plan includes:
acquiring test functions of all the test cases, and determining whether the test cases are in the same test plan according to the test functions;
and when the test functions of the test cases are the same, determining that the test cases with the same test function are the same test plan.
In this embodiment, when different test cases are obtained according to the test instruction, the test cases may belong to different test plans, and different test functions correspond to different test plans. Specifically, when the test cases are obtained, the test number of each test case is obtained, and whether the test cases have the same test function is determined according to the test number. And when the test numbers are consistent, determining that the test cases have the same test function, and combining the test cases belonging to the same test function into the same test plan.
In the embodiment, the test cases with different test functions are combined into different test plans, so that the different functions can be tested in a unified manner through the test plans, and the test efficiency is improved.
In some embodiments of the present application, the obtaining a first execution result of the test case includes:
when the test case is executed, performing assertion detection on the test case;
if the expected value of the test case, which is detected through the assertion, is consistent with the actual value, the test case is determined to be tested successfully, and the test case is marked as a test success case;
and if the expected value and the actual value obtained by the test case through the assertion detection are inconsistent, determining that the test case fails to test, and marking the test case as a test failure case.
In this embodiment, when an execution completion instruction of a test case is received, performing assertion detection on the test case, if an expected value obtained by the test case through assertion detection is consistent with an actual value, determining that the test case is successfully tested, returning an execution result of the test case, and marking the test case as a test success case, where the execution result is a first execution result indicating that the test is successful; and if the expected value and the actual value obtained by the test case through assertion detection are inconsistent, determining that the test case fails to test, returning an execution result of the test case failure, wherein the execution result is a first execution result representing the test failure, and marking the test case as a test failure case.
According to the embodiment, whether the current test case fails to execute can be determined by performing assertion detection on the test case, so that the test case which fails to test can be modified in time, and the accuracy and the efficiency of the test are further improved.
In some embodiments of the application, the generating a test report of the test case according to the first execution result includes:
acquiring a second execution result of the test case, and calculating a comprehensive score of the test case according to the first execution result and the second execution result;
and generating a test report of the test case according to the comprehensive score.
In this embodiment, the second execution result is a historical execution result of the test case, and the first execution result is a current execution result of the test case. And when the first execution result of the test case is obtained, the second execution result of the test case can be obtained, and a test report of the test case is generated according to the first execution result and the second execution result. Specifically, when the first execution result is obtained, the second execution result of the current test case and the preset occupation ratios corresponding to the first execution result and the second execution result respectively are obtained, and the comprehensive score of the test case is calculated according to the preset occupation ratios. And when the comprehensive score is obtained through calculation, obtaining a score data table associated with the comprehensive score, obtaining specific score information of the current test case according to the score data table, and generating a test report according to the score information.
In this embodiment, the second execution result is obtained and the first execution result is combined, so that the test report is accurately generated, the current test condition can be accurately determined through the test report, and the feedback can be made in time.
In some embodiments of the application, when the test instruction is received, obtaining all test cases corresponding to the test instruction based on a preset test case table, and before the test type of each test case, the method further includes:
the method comprises the steps of obtaining a preset pretest case based on a rear-end interface, displaying the pretest case on a front-end page through a preset function, and receiving a test instruction of the pretest case based on the front-end page.
In this embodiment, before receiving a test instruction corresponding to a test case, a preset pretest case needs to be obtained through a backend interface, where the pretest case is a preset test case. Specifically, the pretest case is pre-stored in a database, and the pretest case can be obtained from the database through the backend interface; and when the pre-test case is obtained, displaying the test case in a test case table of a front-end page through preset function association. For example, the pretest case is pre-stored in the git database, and the pretest case can be displayed in the test case table of the front-end page through the git hook function. When the front-end page receives the test instruction, the test case corresponding to the test instruction can be obtained based on the test case table of the front-end page.
According to the embodiment, the pre-test cases are obtained in advance through the rear-end interface and are stored on the front-end page, so that each test case can be obtained directly through the front-end page during testing without rewriting, unified planning and management of the test cases are achieved, and the testing efficiency is further improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware associated with computer readable instructions, which can be stored in a computer readable storage medium, and when executed, the processes of the embodiments of the methods described above can be included. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 3, as an implementation of the method shown in fig. 2, the present application provides an embodiment of an automatic testing apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which can be applied to various electronic devices.
As shown in fig. 3, the automated testing apparatus 300 according to the present embodiment includes: an acquisition module 301, a sending module 302 and a generating module 303. Wherein:
the obtaining module 301 is configured to, when a test instruction is received, obtain all test cases corresponding to the test instruction and a test type of each test case based on a preset test case table;
a sending module 302, configured to determine a target service of each test case according to the test type, obtain a test queue corresponding to the test case, and send the test case to the target service based on the test queue, so that the target service executes the test case;
in this embodiment, when a test instruction is received, a preset test case table is obtained, where the test case table includes a plurality of preset test cases and test types related to the preset test cases, and the test cases are packaged into a test script to be displayed in the test case table. The test type is the root directory name of the test script corresponding to each test case in the test case table, and represents the test scenario type, such as the interface test type and the application test type. When a test instruction is received, a preset test case table is obtained, all test cases corresponding to the test instruction are obtained based on the test case table, and the test script corresponding to the test cases is analyzed, so that the test type of each test case can be determined.
Wherein the sending module 302 includes:
the combination unit is used for combining the test cases into a test plan, and when the test cases are combined into a plurality of different test plans, determining whether the test types of the test cases in each test plan are the same;
and the sending unit is used for respectively issuing the test plans to different test queues when the test types of the test cases in each test plan are different, and asynchronously sending the test plans to corresponding target services based on the different test queues.
Wherein the transmitting unit includes:
the detection subunit is used for acquiring a state identifier of the current test queue and detecting whether the current test queue is full according to the state identifier;
a first sending subunit, configured to, when the current test queue is full, add an asynchronous queue to a thread pool, and send the test plan to a corresponding target service based on the asynchronous queue;
and the second sending subunit is used for sending the test plan to the corresponding target service based on the current test queue when the current test queue is not full.
Wherein, the combination unit includes:
the first confirmation unit is used for acquiring the test functions of all the test cases and determining whether the test cases are in the same test plan according to the test functions;
and the second confirmation unit is used for determining that the test cases with the same test function are the same test plan when the test functions of the test cases are the same.
In this embodiment, when determining the test case and the test type corresponding to the test instruction, the corresponding target service is determined according to the test type of each test case, and the test queue corresponding to the test case is obtained. And when the test queue is obtained, the test plan is issued to the test queue, and the test case is sent to a target service based on the test queue. When the test case is sent to the target service based on the test queue, the test plans can be sent from small to large according to the sending time of the test plans, and the test case in the test plan is sent to the corresponding target service, so that the target service executes the test case. And when different target services receive the corresponding test cases, executing the test cases according to different execution strategies.
For example, 10 test cases in the current test case table may be determined according to the test instruction, where the test type of 3 test cases is an api type, the test type of 3 test cases is an app type, and the test type of 4 test cases is a ui type.
The api type test case corresponds to the target service of the api test, a test suite (test suite) corresponding to the test case is constructed based on the target service and is sent to a pytest framework for execution, and when the execution of the pytest framework is completed, an execution result is written into a database;
the test case of the app type corresponds to a target service of the app test, when the test case of the app type is obtained, the test case is sent to an appium server, the appium server is always in a monitoring state, and when the appium server receives the test case, specific operation is executed according to a test script of the test case;
the ui type test case corresponds to a target service of the ui test, and when the ui type test case is obtained, a related web driver (such as chrome or firefox) is started, the web driver starts a browser and executes a corresponding click operation, and the execution result is written into the database.
The generating module 303 is configured to obtain a first execution result of the test case, and generate a test report of the test case according to the first execution result.
Wherein, the generating module 303 includes:
the detection unit is used for performing assertion detection on the test case when the test case is executed;
a third confirming unit, configured to determine that the test case is successfully tested and mark the test case as a successful test case if an expected value obtained by the test case through the assertion detection is consistent with an actual value;
and the fourth confirming unit is used for determining that the test case fails to test and marking the test case as a test failure case if the expected value obtained by the test case through the assertion detection is inconsistent with the actual value.
The acquisition unit is used for acquiring a second execution result of the test case and calculating a comprehensive score of the test case according to the first execution result and the second execution result;
and the generating unit is used for generating a test report of the test case according to the comprehensive score.
In this embodiment, when it is detected that the target service completes executing the test cases, a first execution result of each test case is obtained, where the first execution result is a current execution result of each test case, for example, the first execution result of the test case that fails to be tested is a failure, and the first execution result of the test case that succeeds to be tested is a success. And generating a corresponding test report according to the first execution results of all the test cases currently participating in the test. The test report reflects the execution condition of each test case.
It should be emphasized that, in order to further ensure the privacy and security of the test report, the test report may also be stored in a node of a block chain.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The automated testing device provided in this embodiment further includes:
the receiving module is used for acquiring a preset pretest case based on a rear-end interface, displaying the pretest case on a front-end page through a preset function, and receiving a test instruction of the pretest case based on the front-end page.
In this embodiment, before receiving a test instruction corresponding to a test case, a preset pretest case needs to be obtained through a backend interface, where the pretest case is a preset test case. Specifically, the pretest case is pre-stored in a database, and the pretest case can be obtained from the database through the backend interface; and when the pre-test case is obtained, displaying the test case in a test case table of a front-end page through preset function association. For example, the pretest case is pre-stored in the git database, and the pretest case can be displayed in the test case table of the front-end page through the git hook function. When the front-end page receives the test instruction, the test case corresponding to the test instruction can be obtained based on the test case table of the front-end page.
The automatic testing device provided by the embodiment realizes unified automatic testing of the test cases, avoids blockage when the test cases are executed, saves testing time, improves testing efficiency and reduces maintenance cost.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 4, fig. 4 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 6 comprises a memory 61, a processor 62, a network interface 63 communicatively connected to each other via a system bus. It is noted that only a computer device 6 having components 61-63 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 61 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as a hard disk or a memory of the computer device 6. In other embodiments, the memory 61 may also be an external storage device of the computer device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 6. Of course, the memory 61 may also comprise both an internal storage unit of the computer device 6 and an external storage device thereof. In this embodiment, the memory 61 is generally used for storing an operating system installed on the computer device 6 and various application software, such as computer readable instructions of an automated testing method. Further, the memory 61 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 62 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 62 is typically used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is configured to execute computer readable instructions stored in the memory 61 or process data, such as computer readable instructions for executing the automated testing method.
The network interface 63 may comprise a wireless network interface or a wired network interface, and the network interface 63 is typically used for establishing a communication connection between the computer device 6 and other electronic devices.
The computer equipment provided by the embodiment realizes unified automatic test of the test cases, avoids blockage when the test cases are executed, saves test time, improves test efficiency and reduces maintenance cost.
The present application further provides another embodiment, which is a computer-readable storage medium storing computer-readable instructions executable by at least one processor to cause the at least one processor to perform the steps of the automated testing method as described above.
The computer-readable storage medium provided by the embodiment realizes unified automatic test of the test case, avoids blockage when the test case is executed, saves test time, improves test efficiency and reduces maintenance cost.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. An automated testing method, comprising the steps of:
when a test instruction is received, acquiring all test cases corresponding to the test instruction and the test type of each test case based on a preset test case table;
determining a target service of each test case according to the test type, acquiring a test queue corresponding to the test case, and sending the test case to the target service based on the test queue so that the target service executes the test case;
and acquiring a first execution result of the test case, and generating a test report of the test case according to the first execution result.
2. The automated testing method according to claim 1, wherein the step of sending the test case to the target service based on the test queue specifically comprises:
combining the test cases into a test plan, and determining whether the test types of the test cases in each test plan are the same when the test cases are combined into a plurality of different test plans;
and when the test types of the test cases in each test plan are different, respectively issuing the test plans to different test queues, and asynchronously sending the test plans to corresponding target services based on the different test queues.
3. The automated testing method of claim 2, wherein the step of asynchronously sending the test plan to the corresponding target service based on the different test queues comprises:
acquiring a state identifier of a current test queue, and detecting whether the current test queue is full or not according to the state identifier;
when the current test queue is full, newly adding an asynchronous queue into a thread pool, and sending the test plan to a corresponding target service based on the asynchronous queue;
and when the current test queue is not full, sending the test plan to a corresponding target service based on the current test queue.
4. The automated testing method of claim 2, wherein the step of combining the test cases into a test plan specifically comprises:
acquiring test functions of all the test cases, and determining whether the test cases are in the same test plan according to the test functions;
and when the test functions of the test cases are the same, determining that the test cases with the same test function are the same test plan.
5. The automated testing method according to claim 1, wherein the step of obtaining the first execution result of the test case specifically comprises:
when the test case is executed, performing assertion detection on the test case;
if the expected value of the test case, which is detected through the assertion, is consistent with the actual value, the test case is determined to be tested successfully, and the test case is marked as a test success case;
and if the expected value and the actual value obtained by the test case through the assertion detection are inconsistent, determining that the test case fails to test, and marking the test case as a test failure case.
6. The automated testing method according to claim 1, wherein the step of generating the test report of the test case according to the first execution result specifically comprises:
acquiring a second execution result of the test case, and calculating a comprehensive score of the test case according to the first execution result and the second execution result;
and generating a test report of the test case according to the comprehensive score.
7. The automated testing method according to claim 1, wherein the step of obtaining all test cases corresponding to the test instruction based on a preset test case table when the test instruction is received, and the test type of each test case further comprises:
the method comprises the steps of obtaining a preset pretest case based on a rear-end interface, displaying the pretest case on a front-end page through a preset function, and receiving a test instruction of the pretest case based on the front-end page.
8. An automated testing apparatus, comprising:
the acquisition module is used for acquiring all test cases corresponding to the test instruction and the test type of each test case based on a preset test case table when the test instruction is received;
the sending module is used for determining the target service of each test case according to the test type, acquiring a test queue corresponding to the test case, and sending the test case to the target service based on the test queue so that the target service executes the test case;
and the generating module is used for acquiring a first execution result of the test case and generating a test report of the test case according to the first execution result.
9. A computer device comprising a memory having computer readable instructions stored therein and a processor that when executed implements the steps of the automated testing method of any of claims 1-7.
10. A computer-readable storage medium having computer-readable instructions stored thereon which, when executed by a processor, implement the steps of the automated testing method of any of claims 1-7.
CN202011532148.1A 2020-12-22 2020-12-22 Automatic testing method and device, computer equipment and storage medium Pending CN112631911A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011532148.1A CN112631911A (en) 2020-12-22 2020-12-22 Automatic testing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011532148.1A CN112631911A (en) 2020-12-22 2020-12-22 Automatic testing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112631911A true CN112631911A (en) 2021-04-09

Family

ID=75322014

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011532148.1A Pending CN112631911A (en) 2020-12-22 2020-12-22 Automatic testing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112631911A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113722129A (en) * 2021-07-30 2021-11-30 苏州浪潮智能科技有限公司 Storage reliability testing method and related device
CN114116362A (en) * 2022-01-28 2022-03-01 苏州浪潮智能科技有限公司 Verification equipment use management method, system, storage medium and equipment
GB2619324A (en) * 2022-05-31 2023-12-06 The Court Of Edinburgh Napier Univ Software management system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113722129A (en) * 2021-07-30 2021-11-30 苏州浪潮智能科技有限公司 Storage reliability testing method and related device
CN113722129B (en) * 2021-07-30 2023-06-20 苏州浪潮智能科技有限公司 Storage reliability test method and related device
CN114116362A (en) * 2022-01-28 2022-03-01 苏州浪潮智能科技有限公司 Verification equipment use management method, system, storage medium and equipment
CN114116362B (en) * 2022-01-28 2022-05-24 苏州浪潮智能科技有限公司 Verification equipment use management method, system, storage medium and equipment
GB2619324A (en) * 2022-05-31 2023-12-06 The Court Of Edinburgh Napier Univ Software management system

Similar Documents

Publication Publication Date Title
CN112631911A (en) Automatic testing method and device, computer equipment and storage medium
CN111427803B (en) Automated random test method, apparatus, computer device and medium
CN112052111B (en) Processing method, device and equipment for server abnormity early warning and storage medium
CN112631910A (en) Front-end testing method and device, computer equipment and storage medium
CN110764798A (en) Microcode upgrading method, device, computer equipment and storage medium
CN112181835A (en) Automatic testing method and device, computer equipment and storage medium
CN113326991A (en) Automatic authorization method, device, computer equipment and storage medium
CN111813418A (en) Distributed link tracking method, device, computer equipment and storage medium
CN114564294A (en) Intelligent service arranging method and device, computer equipment and storage medium
CN112631751A (en) Task scheduling method and device, computer equipment and storage medium
CN111242462A (en) Data processing method and device, computer storage medium and electronic equipment
CN112860662A (en) Data blood relationship establishing method and device, computer equipment and storage medium
CN107229565B (en) Test method and device
CN111813518A (en) Robot early warning method and device, computer equipment and storage medium
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
CN113434254B (en) Client deployment method, client deployment apparatus, computer device, and storage medium
CN115328764A (en) Test code optimization method based on automatic test and related equipment thereof
CN114143308A (en) File uploading information processing method and device, computer equipment and storage medium
CN112364187B (en) Automobile accessory database building method, device and equipment based on big data
CN114615325A (en) Message pushing method and device, computer equipment and storage medium
CN114186976A (en) Workflow transfer method and device, computer equipment and storage medium
CN114626352A (en) Report automatic generation method and device, computer equipment and storage medium
CN112632192A (en) Node maintenance method and device, computer equipment and medium
CN111475388A (en) Data push test method and device, computer equipment and storage medium
CN114218191A (en) System function migration method and device, computer equipment and storage 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