CN108089982A - Test method, device, electronic equipment and computer readable storage medium - Google Patents
Test method, device, electronic equipment and computer readable storage medium Download PDFInfo
- Publication number
- CN108089982A CN108089982A CN201711296591.1A CN201711296591A CN108089982A CN 108089982 A CN108089982 A CN 108089982A CN 201711296591 A CN201711296591 A CN 201711296591A CN 108089982 A CN108089982 A CN 108089982A
- Authority
- CN
- China
- Prior art keywords
- test
- test data
- query
- data
- task
- 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.)
- Granted
Links
- 238000010998 test method Methods 0.000 title claims abstract description 14
- 238000012360 testing method Methods 0.000 claims abstract description 304
- 238000000034 method Methods 0.000 claims abstract description 25
- 238000010586 diagram Methods 0.000 description 11
- 230000006870 function Effects 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000004590 computer program Methods 0.000 description 6
- 238000004364 calculation method Methods 0.000 description 5
- 230000006399 behavior Effects 0.000 description 4
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 238000010200 validation analysis Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000003252 repetitive effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2453—Query optimisation
- G06F16/24532—Query optimisation of parallel queries
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Debugging And Monitoring (AREA)
Abstract
The embodiment of the present disclosure discloses a kind of test method, device, electronic equipment and computer readable storage medium.The described method includes:Obtain a plurality of test data and list object;The test data includes field name, the corresponding query statement of the field name;The test data is encapsulated in program code;For object is preset in the list object, multiple tasks are concurrently generated in a manner of journey to assist, each task tests wherein one in a plurality of test data;The task is performed, the task determines test result according to the test data.Full-automatic test of the embodiment of the present disclosure based on asynchronous association's journey pattern, concurrently performs Field Inquiry request, and obtains test result according to query result, improves SQL query efficiency.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a testing method, an apparatus, an electronic device, and a computer-readable storage medium.
Background
In the internet O2O business, the offline data system has wide application in user representation modeling. The user behavior data is obtained by carrying out statistical calculation on massive user interaction behaviors (such as browsing, clicking, ordering and the like), and the user can be depicted. It is characterized in that: the data volume is large, and the iteration speed is high. For example, in a centuries takeaway system platform, a user representation may increase from 200+ to 800+ in number of individual user fields in five months, where most of the fields may be queried by the database to yield results. While field accuracy is of great concern for accurately describing and characterizing users.
Disclosure of Invention
The embodiment of the disclosure provides a test method, a test device, electronic equipment and a computer-readable storage medium.
In a first aspect, a testing method is provided in an embodiment of the present disclosure.
Specifically, the test method comprises the following steps:
acquiring a plurality of test data and an object list; the test data comprises field names and query sentences corresponding to the field names; the test data is encapsulated in program code;
generating a plurality of tasks concurrently in a coroutine mode aiming at preset objects in the object list, wherein each task tests one of the test data;
and executing the task, and determining a test result by the task according to the test data.
With reference to the first aspect, wherein performing the task includes:
executing the query statement corresponding to the field name in the test data;
and determining a test result according to the query result.
With reference to the first aspect, in a first implementation manner of the first aspect, the test data further includes measured data corresponding to the field name and a test mode.
With reference to the first aspect, in a second implementation manner of the first aspect, the concurrently generating, in a coroutine manner, multiple tasks for a preset object in the object list includes:
replacing the object aimed at by the query statement in the test data with the preset object, and then putting the object into a queue;
and the task reads a record from the queue and executes corresponding operation.
With reference to the second implementation manner of the first aspect, in a third implementation manner of the first aspect, the present disclosure further includes, for a preset object in the object list, concurrently generating multiple tasks in a coroutine manner, where:
and putting the tested data corresponding to the field names in the test data into alignment according to a test mode.
With reference to the first implementation manner of the first aspect, in a fourth implementation manner of the first aspect, the determining a test result according to the query result includes:
and comparing the query result with the tested data according to the test mode to obtain the test result.
With reference to the first aspect, the first implementation manner of the first aspect, the second implementation manner of the first aspect, the third implementation manner of the first aspect, or the fourth implementation manner of the first aspect, in a fifth implementation manner of the first aspect, when the number of preset objects is multiple, the generating, in a coroutine manner, multiple tasks concurrently for preset objects in the object list includes:
and for one preset object, sequentially and concurrently generating a plurality of tasks in a coroutine mode.
In a second aspect, an embodiment of the present disclosure provides a testing apparatus, including:
an acquisition module configured to acquire a plurality of test data and an object list; the test data comprises field names and query sentences corresponding to the field names;
the first execution module is configured to concurrently generate a plurality of tasks in a coroutine mode aiming at preset objects in the object list, and each task tests one of the test data;
and the task execution module is configured to execute the task, and the task determines a test result according to the test data.
With reference to the second aspect, the task execution module includes:
a first execution sub-module configured to execute the query statement corresponding to the field name in the test data;
a first testing sub-module configured to determine a testing result from the query result.
With reference to the second aspect, in a first implementation manner of the second aspect, the test data further includes data to be tested corresponding to the field name and a test mode.
With reference to the second aspect, in a second implementation manner of the second aspect, the first execution module includes:
a first queue sub-module, configured to replace an object targeted by the query statement in the test data with the preset object and then place the object into a queue;
and the second execution submodule is configured to read a record from the queue by the task and execute corresponding operation.
With reference to the second implementation manner of the second aspect, in a third implementation manner of the second aspect, the first execution module further includes:
and the second queue submodule is configured to put the tested data corresponding to the field names in the test data into alignment according to the test mode.
With reference to the first implementation manner of the second aspect, in a fourth implementation manner of the second aspect, the first testing sub-module includes:
and the second testing sub-module is configured to compare the query result with the tested data according to the testing mode to obtain the testing result.
In connection with the second aspect, the test data is encapsulated in program code.
With reference to the second aspect, the first implementation manner of the second aspect, the second implementation manner of the second aspect, the third implementation manner of the second aspect, or the fourth implementation manner of the second aspect, in a fifth implementation manner of the second aspect of the present disclosure, if there are a plurality of preset objects, the first execution module includes:
and the third execution submodule is configured to sequentially and concurrently generate a plurality of tasks in a coroutine mode for one preset object.
The functions can be realized by hardware, and the functions can also be realized by executing corresponding software by hardware. The hardware or software includes one or more modules corresponding to the above-described functions.
In one possible design, the test apparatus includes a memory and a processor, the memory is used for storing one or more computer instructions for supporting the test apparatus to execute the test method in the first aspect, and the processor is configured to execute the computer instructions stored in the memory. The testing apparatus may further comprise a communication interface for the testing apparatus to communicate with other devices or a communication network.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including a memory and a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps of the first aspect.
In a fourth aspect, the disclosed embodiments provide a computer-readable storage medium for storing computer instructions for a testing apparatus, which contains computer instructions for performing the testing method in the first aspect.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
when testing the database field, the embodiment of the disclosure encapsulates the field to be tested and the corresponding field query statement into a program code, and when testing, concurrently generates a plurality of tasks in a collaborative way at a time, and each task executes a plurality of different query statements respectively for the same user, thereby realizing an asynchronous query mode. The automatic testing method and the automatic testing device based on the asynchronous coroutine mode have the advantages that the field query requests are executed in a concurrent mode, the test results are obtained according to the query results, the SQL query efficiency is improved, the test efficiency and the coverage of test cases are improved, the test time is saved, and the test framework has expansibility and wide universality.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments when taken in conjunction with the accompanying drawings. In the drawings:
FIG. 1 shows a flow diagram of a testing method according to an embodiment of the present disclosure;
FIG. 2 shows a flow chart of step S102 according to the embodiment shown in FIG. 1;
FIG. 3 shows a block diagram of a test apparatus according to an embodiment of the present disclosure;
FIG. 4 is a block diagram illustrating a first execution module 302 according to the embodiment shown in FIG. 3;
fig. 5 is a schematic structural diagram of an electronic device suitable for implementing a testing method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. Also, for the sake of clarity, parts not relevant to the description of the exemplary embodiments are omitted in the drawings.
In the present disclosure, it is to be understood that terms such as "including" or "having," etc., are intended to indicate the presence of the disclosed features, numbers, steps, behaviors, components, parts, or combinations thereof, and are not intended to preclude the possibility that one or more other features, numbers, steps, behaviors, components, parts, or combinations thereof may be present or added.
It should be further noted that the embodiments and features of the embodiments in the present disclosure may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
At present, most of field accuracy tests adopt a pure manual test or a serial semi-automatic test. And (4) purely manual testing, namely manually spelling the SQL query sentences of the user and the field logic one by one, then executing the SQL query sentences in the database to obtain a database query result, and manually comparing the database query result with the field of the user generated by the portrait model to judge whether the field is correct or incorrect. And the semi-automatic test is to package the SQL query sentences which are manually spelled one by one into a script file, read the SQL query sentences in the script file line by using an executive program, serially and automatically call a request interface of the SQL query sentences to obtain a database query result, manually compare the database query result with the field of the user output by the portrait model and judge whether the query result is correct or incorrect.
However, in the above purely manual testing manner, the SQL query statements need to be written one by one manually to perform http request query, which takes a long time, and the execution time of the SQL query statements with complex logic is even as long as more than 30 minutes. The test covers fewer users due to limited manual effort. The tester is always doing repetitive work, which is tedious and inefficient. Even in a semi-automatic test mode, the program always serially executes the SQL query request, and the time efficiency of the test and the coverage of the test user are far from the requirements.
FIG. 1 shows a flow diagram of a testing method according to an embodiment of the present disclosure. As shown in fig. 1, the test method includes the following steps S101 to S103:
in step S101, a plurality of test data and an object list are acquired; the test data comprises field names and query sentences corresponding to the field names; the test data is encapsulated in program code;
in step S102, concurrently generating a plurality of tasks in a coroutine manner for preset objects in the object list, each task testing one of the plurality of pieces of test data;
in step S103, the task is executed, and the task determines a test result according to the test data.
In this embodiment, the correctness of the data to be tested is tested. The measured data can be obtained according to field values stored in a database, for example, the measured data is obtained by software developed for field query of the database; it will of course be appreciated that the data under test may be any data that is relevant to a database field query and requires validation. In a traditional mode, when the correctness of the tested data output by software is tested, the correctness of a software calculation result, namely the calculation effect of the software is tested, is determined by comparing a query result obtained by manually writing an SQL query statement with a result obtained by automatically calculating the software.
In this embodiment, when the correctness of the data to be tested is tested, the field names designed by the test data, the query statements corresponding to the field names, the object lists corresponding to the field names, and the like are encapsulated into a program code form in a programming manner, and in the execution process of the program code, the test data and the object lists are obtained from the program code, and a plurality of tasks are concurrently generated for the same preset object in the object list in a coroutine manner, each task executes one piece of test data, and one piece of test data corresponds to one field name and one query statement corresponding to the field name, that is, each task executes one query statement, and the plurality of tasks are executed in parallel and do not need to wait for the return of query results, so that the query efficiency can be improved.
In this embodiment, the test data may be pre-packaged in the program code. Before testing, the field names to be tested and the logics of the corresponding query statements are written into the program codes, and meanwhile, the logics of the testing method corresponding to each field can also be written into the program codes, so that the full automation of the testing process is realized, and an asynchronous execution mode of a plurality of query statements is realized by adopting a multi-task concurrent mode of coroutines, so that the query time can be saved, and the testing cost is saved.
Coroutines are different from threads, and can be considered as user space threads, and an operating system has no knowledge about the coroutines, so that a developer needs to relate to good scheduling in the threads, and the coroutines are very suitable for executing cooperative multitasks. And after the operating system calls the threads carried by the coroutine, the thread internally completes secondary scheduling of the coroutine. Therefore, the embodiment of the present disclosure enables query statements corresponding to test data to be concurrently executed in a coroutine manner by writing program codes.
In this embodiment, the query statement corresponding to the field name may be a field value corresponding to a field, or may be a value obtained by a plurality of field values corresponding to a field in a period of time according to some computation logic. For example, a field is the user's daily spending amount, and the corresponding query statement may be the user's average spending amount over a year. In one embodiment, the object list may include a user id list and a time list, each query statement is for a field, but the field has different field values for different users and different times, so each query for the field needs to be performed according to the user id and the time. It is to be understood that the object list is not limited to the user id list and the time list, but may be any other object such as a company name list, an address list, and the like.
In this embodiment, when writing program codes, each field involved in testing and the query statement corresponding to the field are written in the codes, and the object parameters in the query statement may be obtained from the object list during execution, that is, for different objects, testing of the same field only needs to write one query statement. For example, when a user is used as an object, the user id is used as a variable in a field query statement, and different user ids are input into an execution program in the execution process, so that the query of the same field recorded by a plurality of users can be completed.
In an optional implementation manner of this embodiment, the step S103, that is, the step of executing the task, includes the following steps:
executing the query statement corresponding to the field name in the test data;
and determining a test result according to the query result.
In this embodiment, a plurality of concurrently executed tasks are directed to the same preset object. Each task executes different test data aiming at the same preset object. When the program is executed, a certain object in the object list is specified, when a plurality of tasks are triggered to execute the query statement, the object id in the corresponding query statement is replaced by the specified object id, and each task executes the corresponding query statement in parallel.
For example, the test data includes 10 pieces of field values, each for a different field and/or a different query statement, and the field value to be tested for the test data may be the field value corresponding to 100 object ids. The automation framework in the program code as a whole adopts a producer-consumer model of coroutines. The producer can store the field names and corresponding query statements in 10 test data packaged in the program code into a data structure which can be identified by a certain program, such as a dictionary structure, read the test data in the dictionary, replace parameters such as object id in the query statements, and put the query statements and the corresponding object id into a queue as a record of the queue. The consumer takes one record from the queue for consumption. During consumption, multiple tasks execute multiple query statements concurrently. The process is I/O asynchronous, the query result does not need to be waited for returning, and a large amount of waiting time is saved. And after the result is returned, calling the corresponding test mode of the field, and comparing the query result with the tested data to obtain a test result.
In an optional implementation manner of this embodiment, the test data further includes data to be tested corresponding to the field name and a test mode.
In this alternative implementation, the data to be tested may be written into the program code in advance, or the obtaining mode of the data to be tested may be written into the program code. The test mode may include a comparison mode between the query result and the data to be tested, a test result corresponding to the comparison result, and the like. For example, the comparison method is how to compare the query result and the measured data type when they are different, such as how to compare the query result with the measured data type when the query result is shaped, and how to compare the query result with the measured data type when the measured data type is shaped. The test result may be only correct or incorrect two results, and may also be set as required, for example, a list of objects participating in the test, a comparison result (true/false) for each field of each object, the number of fields with errors for each object comparison result, the field name and the number of errors for which there is an error record, the number of objects for which all the fields are paired, the number of fields with errors, execution time, and so on.
In an optional implementation manner of this embodiment, as shown in fig. 2, the step S102, for a preset object in the object list, concurrently generating a plurality of tasks in a coroutine manner, further includes:
in step S201, replacing the object in the test data for the query statement with the preset object, and then placing the object in a queue;
in step S202, the task reads a record from the queue and performs a corresponding operation.
In this alternative implementation, the query statement is used to query a field value of the corresponding field or some computed result of the field value. Different objects in the same field have different field values, so that one query statement corresponding to one field can be universal, only one piece of test data is used in a program code, and query for different objects can be realized by replacing the id of an object in the test data when the program code is executed, so that the object id of the query statement in the test data is replaced by a preset object before the program is executed, the preset object is put into a queue, and each task reads one record from the queue to execute the corresponding query statement. That is, when the program is executed, the input object id is obtained, then the plurality of pieces of test data are read one by one, and the object id corresponding to the query statement in each piece of test data is replaced with the input object id, that is, the preset object, and then the object id is placed in the queue. Different tasks may extract records from the queue one by one and execute them.
For example, there are 10 pieces of test data in total, and each piece of test data is tested using data of 100 subjects. Firstly, when a program is executed, the id of one preset object is obtained from 100 objects, the object ids of query statements in 10 test data are replaced by the id of the preset object one by one and then are placed in a queue, then 10 tasks are concurrently performed, the 10 test data corresponding to the preset object are taken out from the queue one by one to be tested, and the test of 100 object data can be realized after 100 times of execution.
In an optional implementation manner of this embodiment, the step S102, for a preset object in the object list, concurrently generating a plurality of tasks in a coroutine manner, further includes:
and putting the tested data corresponding to the field names in the test data into alignment according to a test mode.
In the optional implementation manner, while the query statement replacing the object id is put into the queue, the data to be tested and the test mode and the query statement are also put into the queue as a record, so that after each task executes the query statement and obtains a query result, the query result and the data to be tested can be compared based on the test mode, and the test result is obtained and then output.
In an optional implementation manner of this embodiment, the step S104 of determining the test result according to the query result further includes:
and comparing the query result with the tested data according to the test mode to obtain the test result.
In this alternative implementation, the query result is a correct result obtained from the database through the query statement, and the measured data may be obtained through other manners such as software automatic calculation, and in order to verify the correctness of the measured data, the test may be completed by comparing the query result with the measured data. The query data and the tested data may have different types, and the requirement of the test result may be different according to the actual situation. Therefore, the test mode and the acquisition mode of the data to be tested or the data to be tested can be written in the program code in advance, and after the query statement is executed to obtain the query result, the test result is obtained based on the test mode.
In an optional implementation manner of this embodiment, when there are a plurality of preset objects, the step S102, that is, the step of concurrently generating a plurality of tasks in a coroutine manner for the preset objects in the object list, further includes:
and for one preset object, sequentially and concurrently generating a plurality of tasks in a coroutine mode.
In this alternative implementation, for each piece of test data, testing may be performed based on field values corresponding to a plurality of different objects. The test data may be classified in advance, and the test data of different classifications may be tested using different numbers and/or different field values corresponding to the objects. For example, for a field type with a high requirement on accuracy, field values corresponding to a large number of objects may be used for testing, for a field type with a low requirement on accuracy, field values corresponding to a small number of objects may be used for testing, and different fields may also be purposefully selected according to their own attributes to perform testing, etc. In this way, test data of the same type can be used as a group corresponding to the same object list, and a plurality of tasks can be executed concurrently in a coroutine mode. In the testing process, aiming at a field corresponding to a preset object in the object list, a plurality of tasks are started to test a plurality of pieces of test data in the same class simultaneously and concurrently until all or part of fields corresponding to the preset object in the object list are tested. All or as many object ids as possible can be included in the object list, or only a part of the object ids can be included; for the test data of different classifications, it can be known that a certain part of objects in the object list are used as preset objects to be tested, that is, during testing, the query result corresponding to the query statement is obtained only by querying the field value corresponding to the preset object. By the method, different service scenes or fields with large resource consumption difference can be classified, and then concurrent automatic testing is performed in a classified mode.
The following are embodiments of the disclosed apparatus that may be used to perform embodiments of the disclosed methods.
Fig. 3 shows a block diagram of a testing apparatus according to an embodiment of the present disclosure, which may be implemented as part or all of an electronic device by software, hardware, or a combination of both. As shown in fig. 3, the testing apparatus includes an obtaining module 301, a first executing module 302, and a task executing module 303:
an obtaining module 301 configured to obtain a plurality of test data and an object list; the test data comprises field names and query sentences corresponding to the field names; the test data is encapsulated in program code;
a first execution module 302, configured to concurrently generate a plurality of tasks in a coroutine manner for preset objects in the object list, where each task tests one of the plurality of pieces of test data;
a task execution module 303 configured to execute the task, the task determining a test result according to the test data. .
In this embodiment, the correctness of the data to be tested is tested. The measured data can be obtained according to field values stored in a database, for example, the measured data is obtained by software developed for field query of the database; it will of course be appreciated that the data under test may be any data that is relevant to a database field query and requires validation. In a traditional mode, when the correctness of the tested data output by software is tested, the correctness of a software calculation result, namely the calculation effect of the software is tested, is determined by comparing a query result obtained by manually writing an SQL query statement with a result obtained by automatically calculating the software.
In this embodiment, when the correctness of the data to be tested is tested, the field names designed by the test data, the query statements corresponding to the field names, the object lists corresponding to the field names, and the like are encapsulated into a program code form in a programming manner, and in the execution process of the program code, the test data and the object lists are obtained from the program code, and a plurality of tasks are concurrently generated for the same preset object in the object list in a coroutine manner, each task executes one piece of test data, and one piece of test data corresponds to one field name and one query statement corresponding to the field name, that is, each task executes one query statement, and the plurality of tasks are executed in parallel and do not need to wait for the return of query results, so that the query efficiency can be improved.
In this embodiment, the test data may be pre-packaged in the program code. Before testing, the field names to be tested and the logics of the corresponding query statements are written into the program codes, and meanwhile, the logics of the testing method corresponding to each field can also be written into the program codes, so that the full automation of the testing process is realized, and an asynchronous execution mode of a plurality of query statements is realized by adopting a multi-task concurrent mode of coroutines, so that the query time can be saved, and the testing cost is saved.
Coroutines are different from threads, and can be considered as user space threads, and an operating system has no knowledge about the coroutines, so that a developer needs to relate to good scheduling in the threads, and the coroutines are very suitable for executing cooperative multitasks. And after the operating system calls the threads carried by the coroutine, the thread internally completes secondary scheduling of the coroutine. Therefore, the embodiment of the present disclosure enables query statements corresponding to test data to be concurrently executed in a coroutine manner by writing program codes.
In this embodiment, the query statement corresponding to the field name may be a field value corresponding to a field, or may be a value obtained by a plurality of field values corresponding to a field in a period of time according to some computation logic. For example, a field is the user's daily spending amount, and the corresponding query statement may be the user's average spending amount over a year. In one embodiment, the object list may include a user id list and a time list, each query statement is for a field, but the field has different field values for different users and different times, so each query for the field needs to be performed according to the user id and the time. It is to be understood that the object list is not limited to the user id list and the time list, but may be any other object such as a company name list, an address list, and the like.
In this embodiment, when writing program codes, each field involved in testing and the query statement corresponding to the field are written in the codes, and the object parameters in the query statement may be obtained from the object list during execution, that is, for different objects, testing of the same field only needs to write one query statement. For example, when a user is used as an object, the user id is used as a variable in a field query statement, and different user ids are input into an execution program in the execution process, so that the query of the same field recorded by a plurality of users can be completed.
In an optional implementation manner of this embodiment, the task execution module 301 includes:
a first execution sub-module configured to execute the query statement corresponding to the field name in the test data;
a first testing sub-module configured to determine a testing result from the query result.
In this embodiment, a plurality of concurrently executed tasks are directed to the same preset object. Each task executes different test data aiming at the same preset object. When the program is executed, a certain object in the object list is specified, when a plurality of tasks are triggered to execute the query statement, the object id in the corresponding query statement is replaced by the specified object id, and each task executes the corresponding query statement in parallel.
For example, the test data includes 10 pieces of field values, each for a different field and/or a different query statement, and the field value to be tested for the test data may be the field value corresponding to 100 object ids. The automation framework in the program code as a whole adopts a producer-consumer model of coroutines. The producer can store the field names and corresponding query statements in 10 test data packaged in the program code into a data structure which can be identified by a certain program, such as a dictionary structure, read the test data in the dictionary, replace parameters such as object id in the query statements, and put the query statements and the corresponding object id into a queue as a record of the queue. The consumer takes one record from the queue for consumption. During consumption, multiple tasks execute multiple query statements concurrently. The process is I/O asynchronous, the query result does not need to be waited for returning, and a large amount of waiting time is saved. And after the result is returned, calling the corresponding test mode of the field, and comparing the query result with the tested data to obtain a test result.
In an optional implementation manner of this embodiment, the test data further includes data to be tested corresponding to the field name and a test mode.
In this alternative implementation, the data to be tested may be written into the program code in advance, or the obtaining mode of the data to be tested may be written into the program code. The test mode may include a comparison mode between the query result and the data to be tested, a test result corresponding to the comparison result, and the like. For example, the comparison method is how to compare the query result and the measured data type when they are different, such as how to compare the query result with the measured data type when the query result is shaped, and how to compare the query result with the measured data type when the measured data type is shaped. The test result may be only correct or incorrect two results, and may also be set as required, for example, a list of objects participating in the test, a comparison result (true/false) for each field of each object, the number of fields with errors for each object comparison result, the field name and the number of errors for which there is an error record, the number of objects for which all the fields are paired, the number of fields with errors, execution time, and so on.
In an optional implementation manner of this embodiment, as shown in fig. 4, the first executing module 302 includes:
a first queue sub-module 401, configured to replace the object in the test data for the query statement with the preset object and then place the object in a queue;
and the second execution submodule 402 is configured to read a record from the queue by the task and execute corresponding operation.
In this alternative implementation, the query statement is used to query a field value of the corresponding field or some computed result of the field value. Different objects in the same field have different field values, so that one query statement corresponding to one field can be universal, only one piece of test data is used in a program code, and query for different objects can be realized by replacing the id of an object in the test data when the program code is executed, so that the object id of the query statement in the test data is replaced by a preset object before the program is executed, the preset object is put into a queue, and each task reads one record from the queue to execute the corresponding query statement. That is, when the program is executed, the input object id is obtained, then the plurality of pieces of test data are read one by one, and the object id corresponding to the query statement in each piece of test data is replaced with the input object id, that is, the preset object, and then the object id is placed in the queue. Different tasks may extract records from the queue one by one and execute them.
For example, there are 10 pieces of test data in total, and each piece of test data is tested using data of 100 subjects. Firstly, when a program is executed, the id of one preset object is obtained from 100 objects, the object ids of query statements in 10 test data are replaced by the id of the preset object one by one and then are placed in a queue, then 10 tasks are concurrently performed, the 10 test data corresponding to the preset object are taken out from the queue one by one to be tested, and the test of 100 object data can be realized after 100 times of execution.
In an optional implementation manner of this embodiment, the first executing module 302 further includes:
and the second queue submodule is configured to put the tested data corresponding to the field names in the test data into alignment according to the test mode.
In the optional implementation manner, while the query statement replacing the object id is put into the queue, the data to be tested and the test mode and the query statement are also put into the queue as a record, so that after each task executes the query statement and obtains a query result, the query result and the data to be tested can be compared based on the test mode, and the test result is obtained and then output.
In an optional implementation manner of this embodiment, the first testing sub-module includes:
and the second testing sub-module is configured to compare the query result with the tested data according to the testing mode to obtain the testing result.
In this alternative implementation, the query result is a correct result obtained from the database through the query statement, and the measured data may be obtained through other manners such as software automatic calculation, and in order to verify the correctness of the measured data, the test may be completed by comparing the query result with the measured data. The query data and the tested data may have different types, and the requirement of the test result may be different according to the actual situation. Therefore, the test mode and the acquisition mode of the data to be tested or the data to be tested can be written in the program code in advance, and after the query statement is executed to obtain the query result, the test result is obtained based on the test mode.
In an optional implementation manner of this embodiment, in a case that the preset object is multiple, the first executing module 302 includes:
and the third execution submodule is configured to sequentially and concurrently generate a plurality of tasks in a coroutine mode for one preset object.
In this alternative implementation, for each piece of test data, testing may be performed based on field values corresponding to a plurality of different objects. The test data may be classified in advance, and the test data of different classifications may be tested using different numbers and/or different field values corresponding to the objects. For example, for a field type with a high requirement on accuracy, field values corresponding to a large number of objects may be used for testing, for a field type with a low requirement on accuracy, field values corresponding to a small number of objects may be used for testing, and different fields may also be purposefully selected according to their own attributes to perform testing, etc. In this way, test data of the same type can be used as a group corresponding to the same object list, and a plurality of tasks can be executed concurrently in a coroutine mode. In the testing process, aiming at a field corresponding to a preset object in the object list, a plurality of tasks are started to test a plurality of pieces of test data in the same class simultaneously and concurrently until all or part of fields corresponding to the preset object in the object list are tested. All or as many object ids as possible can be included in the object list, or only a part of the object ids can be included; for the test data of different classifications, it can be known that a certain part of objects in the object list are used as preset objects to be tested, that is, during testing, the query result corresponding to the query statement is obtained only by querying the field value corresponding to the preset object. By the method, different service scenes or fields with large resource consumption difference can be classified, and then concurrent automatic testing is performed in a classified mode.
Fig. 5 is a schematic structural diagram of an electronic device suitable for implementing a testing method according to an embodiment of the present disclosure.
As shown in fig. 5, the electronic apparatus 500 includes a Central Processing Unit (CPU)501 that can execute various processes in the embodiment shown in fig. 1 described above according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM503, various programs and data necessary for the operation of the electronic apparatus 500 are also stored. The CPU501, ROM502, and RAM503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to embodiments of the present disclosure, the method described above with reference to fig. 1 may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a medium readable thereby, the computer program comprising program code for performing the testing method of FIG. 1. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowcharts or block diagrams may represent a module, a program segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present disclosure may be implemented by software or hardware. The units or modules described may also be provided in a processor, and the names of the units or modules do not in some cases constitute a limitation of the units or modules themselves.
As another aspect, the present disclosure also provides a computer-readable storage medium, which may be the computer-readable storage medium included in the apparatus in the above-described embodiment; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present disclosure.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
A1, a test method, comprising: acquiring a plurality of pieces of test data and an object list; the test data comprises field names and query sentences corresponding to the field names; the test data is encapsulated in program code; generating a plurality of tasks concurrently in a coroutine mode aiming at preset objects in the object list, wherein each task tests one of the test data; and executing the task, and determining a test result by the task according to the test data. A2, the test method according to A1, further comprising: performing the task, including: executing the query statement corresponding to the field name in the test data; and determining a test result according to the query result. A3, the testing method according to A1 or A2, the testing data further includes the data to be tested corresponding to the field name and the testing mode. A4, the testing method as described in a1 or a2, for the preset objects in the object list, concurrently generating a plurality of tasks in a collaborative manner, including: replacing the object aimed at by the query statement in the test data with the preset object, and then putting the object into a queue; and the task reads a record from the queue and executes corresponding operation. A5, the testing method as in a4, for preset objects in the object list, concurrently generating a plurality of tasks in a collaborative manner, further comprising: and putting the tested data corresponding to the field names in the test data into alignment according to a test mode. A6, the testing method according to A3, determining a test result according to the query result, comprising: and comparing the query result with the tested data according to the test mode to obtain the test result. A7, the testing method as in a1 or a2, when there are a plurality of preset objects, generating a plurality of tasks concurrently in a coroutine manner for the preset objects in the object list, including: and for one preset object, sequentially and concurrently generating a plurality of tasks in a coroutine mode.
B8, a test device comprising: the acquisition module is configured to acquire a plurality of pieces of test data and an object list; the test data comprises field names and query sentences corresponding to the field names; the first execution module is configured to concurrently generate a plurality of tasks in a coroutine mode aiming at preset objects in the object list, and each task tests one of the test data; and the task execution module is configured to execute the task, and the task determines a test result according to the test data. B9, the testing device according to B8, the task execution module includes: a first execution sub-module configured to execute the query statement corresponding to the field name in the test data; a first testing sub-module configured to determine a testing result from the query result. B10, the testing device as B8 or B9, the testing data further includes the data to be tested corresponding to the field name and the testing mode. B11, the testing device as B8 or B9, the first execution module comprising: a first queue sub-module, configured to replace an object targeted by the query statement in the test data with the preset object and then place the object into a queue; and the second execution submodule is configured to read a record from the queue by the task and execute corresponding operation. B12, the testing device as described in B11, the first execution module further comprising: and the second queue submodule is configured to put the tested data corresponding to the field names in the test data into alignment according to the test mode. B13, the test method of B10, the first test submodule comprising: and the second testing sub-module is configured to compare the query result with the tested data according to the testing mode to obtain the testing result. B14, the testing apparatus as described in B8 or B9, wherein the first executing module, when the preset object is plural, includes: and the third execution submodule is configured to sequentially and concurrently generate a plurality of tasks in a coroutine mode for one preset object.
C15, an electronic device comprising a memory and a processor; wherein the memory is to store one or more computer instructions, wherein the one or more computer instructions are to be executed by the processor to implement the method steps of any of A1-A7.
D16, a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, carry out the method steps of any one of a1-a 7.
Claims (10)
1. A method of testing, comprising:
acquiring a plurality of pieces of test data and an object list; the test data comprises field names and query sentences corresponding to the field names; the test data is encapsulated in program code;
generating a plurality of tasks concurrently in a coroutine mode aiming at preset objects in the object list, wherein each task tests one of the test data;
and executing the task, and determining a test result by the task according to the test data.
2. The test method of claim 1, further comprising: performing the task, including:
executing the query statement corresponding to the field name in the test data;
and determining a test result according to the query result.
3. The test method according to claim 1 or 2, wherein the test data further includes data to be tested corresponding to the field name and a test mode.
4. The test method according to claim 1 or 2, wherein the concurrent generation of a plurality of tasks in a collaborative manner for the preset objects in the object list comprises:
replacing the object aimed at by the query statement in the test data with the preset object, and then putting the object into a queue;
and the task reads a record from the queue and executes corresponding operation.
5. The testing method of claim 4, wherein a plurality of tasks are concurrently generated in a collaborative manner for preset objects in the object list, further comprising:
and putting the tested data corresponding to the field names in the test data into alignment according to a test mode.
6. The testing method of claim 3, wherein determining a test result based on the query result comprises:
and comparing the query result with the tested data according to the test mode to obtain the test result.
7. The testing method according to claim 1 or 2, wherein, in case that there are a plurality of preset objects, concurrently generating a plurality of tasks in a coroutine manner for the preset objects in the object list, comprises:
and for one preset object, sequentially and concurrently generating a plurality of tasks in a coroutine mode.
8. A test apparatus, comprising:
the acquisition module is configured to acquire a plurality of pieces of test data and an object list; the test data comprises field names and query sentences corresponding to the field names;
the first execution module is configured to concurrently generate a plurality of tasks in a coroutine mode aiming at preset objects in the object list, and each task tests one of the test data;
and the task execution module is configured to execute the task, and the task determines a test result according to the test data.
9. An electronic device comprising a memory and a processor; wherein,
the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method steps of any of claims 1-7.
10. A computer-readable storage medium having stored thereon computer instructions, characterized in that the computer instructions, when executed by a processor, carry out the method steps of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711296591.1A CN108089982B (en) | 2017-12-08 | 2017-12-08 | Test method, test device, electronic equipment and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711296591.1A CN108089982B (en) | 2017-12-08 | 2017-12-08 | Test method, test device, electronic equipment and computer readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108089982A true CN108089982A (en) | 2018-05-29 |
CN108089982B CN108089982B (en) | 2020-12-01 |
Family
ID=62174893
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711296591.1A Expired - Fee Related CN108089982B (en) | 2017-12-08 | 2017-12-08 | Test method, test device, electronic equipment and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108089982B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108957237A (en) * | 2018-08-01 | 2018-12-07 | 歌尔股份有限公司 | A kind of anomalous line detection method, device, equipment and storage medium |
CN108959079A (en) * | 2018-06-27 | 2018-12-07 | 郑州云海信息技术有限公司 | A kind of with automatic test is leading software agile development method and system |
CN110221982A (en) * | 2019-06-17 | 2019-09-10 | 深圳前海微众银行股份有限公司 | Performance test methods, device, equipment and the readable storage medium storing program for executing of operation system |
CN110908892A (en) * | 2019-09-18 | 2020-03-24 | 泰康保险集团股份有限公司 | Interface data testing method and device and readable storage medium |
CN111124892A (en) * | 2019-12-04 | 2020-05-08 | 四川安迪科技实业有限公司 | Automatic testing method and system based on command line |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102306200A (en) * | 2011-09-22 | 2012-01-04 | 用友软件股份有限公司 | Device and method for concurrently applying incremental data manipulation statements |
CN104375935A (en) * | 2014-11-13 | 2015-02-25 | 华为技术有限公司 | Method and device for testing SQL injection attack |
CN105843917A (en) * | 2016-03-24 | 2016-08-10 | 成都金盘电子科大多媒体技术有限公司 | Medical data dictionary standardization method and system based on cloud service |
CN105930274A (en) * | 2016-05-05 | 2016-09-07 | 中国银行股份有限公司 | Automated test method and system |
CN106326119A (en) * | 2016-08-19 | 2017-01-11 | 北京匡恩网络科技有限责任公司 | Method and device for generating test case |
US20170039128A1 (en) * | 2015-08-04 | 2017-02-09 | Salesforce.Com, Inc. | Testing software enhancements in database applications |
US20170185646A1 (en) * | 2015-12-29 | 2017-06-29 | Cognizant Technology Solutions India Pvt. Ltd. | System and method for providing a framework having a query building logic |
-
2017
- 2017-12-08 CN CN201711296591.1A patent/CN108089982B/en not_active Expired - Fee Related
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102306200A (en) * | 2011-09-22 | 2012-01-04 | 用友软件股份有限公司 | Device and method for concurrently applying incremental data manipulation statements |
CN104375935A (en) * | 2014-11-13 | 2015-02-25 | 华为技术有限公司 | Method and device for testing SQL injection attack |
US20170039128A1 (en) * | 2015-08-04 | 2017-02-09 | Salesforce.Com, Inc. | Testing software enhancements in database applications |
US20170185646A1 (en) * | 2015-12-29 | 2017-06-29 | Cognizant Technology Solutions India Pvt. Ltd. | System and method for providing a framework having a query building logic |
CN105843917A (en) * | 2016-03-24 | 2016-08-10 | 成都金盘电子科大多媒体技术有限公司 | Medical data dictionary standardization method and system based on cloud service |
CN105930274A (en) * | 2016-05-05 | 2016-09-07 | 中国银行股份有限公司 | Automated test method and system |
CN106326119A (en) * | 2016-08-19 | 2017-01-11 | 北京匡恩网络科技有限责任公司 | Method and device for generating test case |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108959079A (en) * | 2018-06-27 | 2018-12-07 | 郑州云海信息技术有限公司 | A kind of with automatic test is leading software agile development method and system |
CN108959079B (en) * | 2018-06-27 | 2021-08-20 | 郑州云海信息技术有限公司 | Software agile development method and system taking automatic test as leading factor |
CN108957237A (en) * | 2018-08-01 | 2018-12-07 | 歌尔股份有限公司 | A kind of anomalous line detection method, device, equipment and storage medium |
CN110221982A (en) * | 2019-06-17 | 2019-09-10 | 深圳前海微众银行股份有限公司 | Performance test methods, device, equipment and the readable storage medium storing program for executing of operation system |
CN110221982B (en) * | 2019-06-17 | 2023-06-09 | 深圳前海微众银行股份有限公司 | Performance test method, device and equipment of business system and readable storage medium |
CN110908892A (en) * | 2019-09-18 | 2020-03-24 | 泰康保险集团股份有限公司 | Interface data testing method and device and readable storage medium |
CN111124892A (en) * | 2019-12-04 | 2020-05-08 | 四川安迪科技实业有限公司 | Automatic testing method and system based on command line |
Also Published As
Publication number | Publication date |
---|---|
CN108089982B (en) | 2020-12-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108089982B (en) | Test method, test device, electronic equipment and computer readable storage medium | |
CN108614770B (en) | Automatic test assertion method, device, storage medium and equipment | |
CN110764993A (en) | Automatic testing method and terminal equipment | |
US20140325480A1 (en) | Software Regression Testing That Considers Historical Pass/Fail Events | |
US8402317B1 (en) | Viewing multi-dimensional metric data from multiple test cases | |
US20080092120A1 (en) | Size and effort estimation in testing applications | |
US8839198B2 (en) | Automated analysis of composite applications | |
CN107943694B (en) | Test data generation method and device | |
CN112581018B (en) | Method, system, device and storage medium for managing process tasks | |
US8661414B2 (en) | Method and system for testing an order management system | |
CN117195568B (en) | Simulation engine performance analysis method and device based on discrete event | |
CN109388564B (en) | Test method and device and electronic equipment | |
CN114168565B (en) | Backtracking test method, device and system of business rule model and decision engine | |
CN112395182A (en) | Automatic testing method, device, equipment and computer readable storage medium | |
CN112346994B (en) | Test information association method, device, computer equipment and storage medium | |
US20160180262A1 (en) | System and method for testing enterprise transactions | |
CN115292418A (en) | Cross-system business process automatic processing method and system | |
CN111367820B (en) | Sequencing method and device for test cases | |
CN113448867B (en) | Software pressure testing method and device | |
CN113806231A (en) | Code coverage rate analysis method, device, equipment and medium | |
CN112527584A (en) | Software efficiency improving method and system based on script compiling and data acquisition | |
CN113377648A (en) | Software system diagnosis method and device, electronic equipment and computer readable medium | |
CN110297625B (en) | Application processing method and device | |
CN109901983B (en) | Automatic testing method and device, storage medium and electronic equipment | |
CN109358855A (en) | A kind of front end analogue data agile development method and electronic equipment for programming |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20201201 |
|
CF01 | Termination of patent right due to non-payment of annual fee |