CN116841885A - Test case library-based test method and device and electronic equipment - Google Patents

Test case library-based test method and device and electronic equipment Download PDF

Info

Publication number
CN116841885A
CN116841885A CN202310803625.0A CN202310803625A CN116841885A CN 116841885 A CN116841885 A CN 116841885A CN 202310803625 A CN202310803625 A CN 202310803625A CN 116841885 A CN116841885 A CN 116841885A
Authority
CN
China
Prior art keywords
test
test case
target
case
test data
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
CN202310803625.0A
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.)
China Automotive Innovation Corp
Original Assignee
China Automotive Innovation Corp
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 China Automotive Innovation Corp filed Critical China Automotive Innovation Corp
Priority to CN202310803625.0A priority Critical patent/CN116841885A/en
Publication of CN116841885A publication Critical patent/CN116841885A/en
Pending legal-status Critical Current

Links

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/3684Test management for test design, e.g. generating new test cases
    • 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

Landscapes

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

Abstract

The application discloses a test method and a device based on a test case library and electronic equipment, wherein the test method based on the test case library can be applied to the field of software testing, and the method comprises the following steps: acquiring a test task description file and test case registration information; the test task description file describes the attribute of the test case; the test case registration information comprises test data identifiers corresponding to each test case; determining a plurality of target test cases based on the test task description file and the test case library; the test case library stores the attribute of the test case; for each target test case, traversing the shared test data set based on the test case registration information, calling the test data corresponding to the test data identifier when the test data identifier corresponding to the test case exists, and executing the test case; the shared test data set stores test data identification and test data. The application reduces the cost wasted by invalid test and saves the time and space cost caused by repeated data construction.

Description

Test case library-based test method and device and electronic equipment
Technical Field
The present application relates to the field of software testing, and in particular, to a test method and apparatus based on a test case library, and an electronic device.
Background
The automatic test process of the software mainly utilizes an automatic test tool to design an automatic test case through analysis of test requirements, thereby constructing an automatic test framework, designing and writing an automatic script, and testing the correctness of the script, and further completing the set of test scripts. The process of test operation is a process of calling test data to execute test cases, one test case may need to call multiple test data, and multiple test cases often depend on the same test data when executed.
With the development of computer technology, the software testing technology presents a situation of high-speed development, a testing tool layer is endless, an automatic testing technology is developed to a great extent, but a main flow operation mode of automatic testing is still to execute all testing cases in a base line case library, test data are respectively constructed in each case, a great amount of test data are repeatedly constructed and analyzed, and waste of testing resources and low testing efficiency are caused.
Disclosure of Invention
In order to solve the problems in the prior art, the embodiment of the application provides a test method and device based on a test case library and electronic equipment. The technical scheme is as follows:
In one aspect, a test method based on a test case library is provided, the method comprising:
acquiring a test task description file and test case registration information; the test task description file is used for describing the attribute of the test case corresponding to the target test task; the test case registration information comprises test data information corresponding to each test case, and the test data information comprises a test data identifier;
determining a plurality of target test cases based on the test task description file and the test case library; the test case library comprises a plurality of test case objects; the test case object stores the function entry address of the test case and the attribute information corresponding to the test case; attribute information corresponding to each target test case is matched with the test task description file;
for each target test case, traversing a shared test data set based on the test case registration information, and calling test data corresponding to the test data identifier corresponding to the target test case in the shared test data set when the test data identifier corresponding to the target test case exists in the shared test data set, so as to execute the target test case and obtain a test result; the shared test data set includes a plurality of shared key-value pairs that hold test data identification and test data.
In another aspect, a test device based on a test case library is provided, the device including:
the information acquisition module is used for acquiring the test task description file and the test case registration information; the test task description file is used for describing the attribute of the test case corresponding to the target test task; the test case registration information comprises test data information corresponding to each test case, and the test data information comprises a test data identifier;
the case determining module is used for determining a plurality of target test cases based on the test task description file and the test case library; the test case library comprises a plurality of test case objects; the test case object stores the function entry address of the test case and the attribute information corresponding to the test case; attribute information corresponding to each target test case is matched with the test task description file;
the calling execution module is used for traversing the shared test data set for each target test case based on the test case registration information, and calling the test data corresponding to the test data identifier corresponding to the target test case in the shared test data set when the test data identifier corresponding to the target test case exists in the shared test data set, so as to execute the target test case and obtain a test result; the shared test data set includes a plurality of shared key-value pairs that hold test data identification and test data.
In an exemplary embodiment, the test data information further includes a test data parameter; the apparatus further includes a build execution module to build test data for invocation in executing the target test case, the build execution module comprising:
the parameter determining module is used for determining the test data parameters corresponding to the target test case based on the test case registration information when the test data identifier corresponding to the target test case does not exist in the shared test data set;
the data construction module is used for constructing target test data based on the test data parameters corresponding to the target test cases;
and the case execution module is used for calling the target test data and executing the target test case to obtain a test result.
In an exemplary embodiment, the use case determination module includes:
the object determining module is used for determining a plurality of target test case objects in the test case library based on the test task description file; attribute information in each target test case object is matched with the test task description file;
and the application case module is used for determining a corresponding target test case for each target test case object based on the function entry address in the target test case object.
In an exemplary embodiment, the object determination module includes:
the attribute extraction module is used for extracting the content of the test task description file to obtain multi-item label attribute information;
the dimension acquisition module is used for acquiring at least one input test dimension; each test dimension represents the dimension of the attribute of the test case corresponding to the target test task;
the correlation determination module is used for determining the correlation between the target attribute information and the at least one test dimension for each item of target attribute information to obtain the correlation corresponding to each item of target attribute information;
the screening condition module is used for determining the target attribute information as test case screening information when the correlation degree corresponding to the target attribute information meets the preset correlation degree condition for each item of target attribute information, so as to obtain a test case screening condition set;
the case object module is used for determining the plurality of target test case objects in the test case library based on the test case screening condition set; and the attribute information in each target test case object is matched with the test case screening condition set.
In one exemplary embodiment, the properties of the test cases have priority; the use case object module comprises:
the priority determining module is used for determining the priority of the test case screening information in the test case screening condition set;
and the case screening module is used for screening the test case objects in the test case library according to the order of the priority from high to low based on the test case screening information in the test case screening condition set to obtain the plurality of target test case objects.
In an exemplary embodiment, the test data information further includes an applicability level of the test data; the apparatus further includes a data insertion module that inserts multiplexed test data into the shared test data set, the data insertion module comprising:
the key value pair construction module is used for constructing a target shared key value pair based on the test data identifier corresponding to the target test case and the target test data if the test data identifier corresponding to the target test case has multiplexing in the test case registration information;
a key value pair inserting module, configured to insert the target shared key value pair into the shared test data set;
The level determining module is used for determining the applicable level of the target test data in the test case registration information based on the target test case;
the life cycle setting module is used for setting the life cycle for the target shared key value pair based on the applicable level of the target test data; the lifetime of the target shared key value pair is the execution period of the test case which belongs to the same applicable level with the target test data.
In an exemplary embodiment, the call execution module or the use case execution module includes:
the function determining module is used for determining a main function of each target test case to obtain a plurality of target functions;
the first function operation module is used for creating threads according to the preset quantity, randomly determining an objective function corresponding to each thread in the plurality of objective functions, operating the corresponding objective function based on the threads, and determining the threads as idle threads when the thread operation is finished;
the second function operation module is used for randomly determining an objective function corresponding to the idle thread in the residual objective functions for each idle thread when the number of operation objective functions is smaller than the number of the plurality of objective functions, determining the idle thread as an occupied thread, operating the corresponding objective function based on the occupied thread, and determining the occupied thread as the idle thread when the operation of the occupied thread is finished until the number of operation objective functions is equal to the number of the plurality of objective functions, and finishing the random determination; the running objective function is a function which is run in the plurality of objective functions; the residual objective function is a function which is not operated in the plurality of objective functions;
And the report generation module is used for generating a test report based on the operation result of the objective function corresponding to each objective test case.
In an exemplary embodiment, the apparatus further includes a case library construction module for constructing a test case library based on the attributes of the test case, the case library construction module including:
the case acquisition module is used for acquiring a plurality of test cases;
the information determining module is used for marking attribute information for each test case and determining the function entry address of the test case;
the object packaging module is used for packaging the function entry address of the test case and the attribute information corresponding to the test case into objects to obtain a plurality of test case objects;
and the case library generating module is used for generating the test case library based on the plurality of test case objects.
In another aspect, an electronic device is provided, including a processor and a memory, where at least one instruction or at least one program is stored in the memory, where the at least one instruction or the at least one program is loaded and executed by the processor to implement the test case library-based test method of any of the above aspects.
In another aspect, a computer readable storage medium having at least one instruction or at least one program stored therein is provided, the at least one instruction or the at least one program loaded and executed by a processor to implement a test case library-based test method as in any of the above aspects.
In another aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions so that the electronic device performs the test case library-based test method of any of the above aspects.
According to the embodiment of the application, the test case library containing the case attributes is constructed in advance, and the test cases with the attribute information matched with the test cases are screened based on the task description file configured by the user, so that the test cases with the required granularity are accurately screened, and the test cases in a specific range are accurately and efficiently tested when the test cases are automatically executed, so that the cost wasted by invalid test is greatly reduced, and the production efficiency is improved; when each use case is executed, searching and taking are performed in the shared test data set according to the identification of the required test data, so that time and space expenses caused by repeated data construction are saved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a test method based on a test case library according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of a screening test case according to an embodiment of the present application;
FIG. 3 is a schematic flow chart of screening test cases according to different test dimensions according to an embodiment of the present application;
FIG. 4 is a flow chart of storing multiplexed test data in a shared test data set according to an embodiment of the present application;
FIG. 5 is a schematic flow chart of a multithreaded test case according to an embodiment of the present application;
FIG. 6 is a schematic flow chart of a test case library construction provided by an embodiment of the present application;
FIG. 7 is a block diagram of a test device based on a test case library according to an embodiment of the present application;
Fig. 8 is a block diagram of a hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It will be appreciated that in the specific embodiments of the present application, related data such as user information is involved, and when the above embodiments of the present application are applied to specific products or technologies, user permissions or consents need to be obtained, and the collection, use and processing of related data need to comply with related laws and regulations and standards of related countries and regions.
Referring to fig. 1, a flow chart of a test method based on a test case library according to an embodiment of the application is shown. It is noted that the present specification provides method operational steps as illustrated in the examples or flowcharts, but may include more or fewer operational steps based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one way of performing the order of steps and does not represent a unique order of execution. In actual system or product execution, the methods illustrated in the embodiments or figures may be performed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment). As shown in fig. 1, the method may include:
s101, acquiring a test task description file and test case registration information.
The test task description file is used for describing the attribute of the test case corresponding to the target test task.
Specifically, the test task description file describes attributes that the to-be-executed use case of the target test task should have, for example: case number "tc_001|tc_002", case name "tc_n001|tc_n002", case module "tc_module_a", case module "tc_sub_module_a", case level "2", case characteristics "performance|stability", and the like.
The target test task is a test task corresponding to the test task description file, and is composed of configuration information in multiple aspects such as task configuration, log configuration, test report configuration, and the like, for example: task name "XXXX Module XXXX Property test", product name "C01", product version number "B001", module name "AD", sub-module name "LIFE_CYCLE", thread number "10", log level "DEBUG", log output path "/output/logs/", log output device "DEV_FILE", test report path "/output/reports/", etc.
The test case registration information comprises test data information corresponding to each test case, and the test data information comprises a test data identifier and test data parameters.
Wherein the test data identifier is a unique identifier capable of indicating specific test data.
Wherein the test data parameters are parameters necessary for constructing the test data. In particular, test data is constructed by constructing a function, and test data parameters are input values to the function.
S103, determining a plurality of target test cases based on the test task description file and the test case library.
The test case library comprises a plurality of test case objects.
The test case object stores the function entry address of the test case and the attribute information corresponding to the test case.
And the attribute information corresponding to each target test case is matched with the test task description file.
The function entry address of the test case is the address of the first instruction executed when the test case is executed.
The attribute information corresponding to the test cases is the attribute information marked for each test case when the test case library is constructed. For example, the following attribute information is labeled for the test case tc_001: case number "tc_001", case name "tc_n001", case module "tc_module_a", case module "tc_sub_module_a", case level "2", case property "performance|stability".
In specific implementation, traversing test case objects in a test case library, matching attribute information of test cases stored in the test case objects with attribute information in a test task description file, and inserting test cases indicated by function entry addresses stored in the test case objects which are successfully matched, namely target test cases, into a task linked list to obtain a to-be-executed case linked list of a target test task. Specifically, if the test task description file includes the following contents: case level "2", case characteristics "performance|stability", the attribute information corresponding to the target test case at least includes the above two attributes, for example, the above test case tc_001.
In an exemplary embodiment, as shown in fig. 2, the step S103 may include:
s201, determining a plurality of target test case objects in a test case library based on the test task description file.
The attribute information in each target test case object is matched with the test task description file.
In specific implementation, traversing test case objects in a test case library, matching attribute information of test cases stored in the test case objects with attribute information in a test task description file, and inserting test cases indicated by function entry addresses stored in the test case objects which are successfully matched, namely target test cases, into a task linked list to obtain a to-be-executed case linked list of a target test task. Specifically, if the test task description file includes the following contents: case level "2", case characteristics "performance|stability", then the attribute information corresponding to the target test case at least includes the above two attributes, for example, the test case object object_001 in the test case library has the following attribute information: case number "tc_001", case name "tc_n001", case module "tc_module_a", case module "tc_sub_module_a", case level "2", case property "performance|stability". And the test case object object_001 is successfully matched with the task description file, and the test case TC_001 indicated by the function entry address stored in the test case object object_001 is taken as a target test case and inserted into a task linked list.
In an exemplary embodiment, as shown in fig. 3, the step S201 may include:
s301, extracting the content of the test task description file to obtain multi-item label attribute information.
The target attribute information is an attribute which the to-be-executed case of the target test task should have. In specific implementation, descriptions about test case attributes in the test task description file are extracted one by one.
S303, acquiring at least one input test dimension.
Each test dimension represents the dimension of the attribute of the test case corresponding to the target test task. For example, the test dimension to which the attribute case number "tc_001|tc_002" belongs is the case number, the test dimension to which the attribute case property "performance|stability" belongs is the case property, and so on.
In specific implementation, the test dimension is defined by a tester, and the tester can screen test case objects in the test case library according to different test dimensions, for example, screen the case related to the new characteristic released at this time before releasing each version, set only the case with screening performance and reliability, screen the case with specific name, and so on.
S305, for each item of target attribute information, determining the correlation degree of the target attribute information and at least one test dimension, and obtaining the correlation degree corresponding to each item of target attribute information.
The correlation degree between each item of target attribute information and at least one test dimension is the coincidence degree between the dimension to which the target attribute information belongs and at least one test dimension. For example, the test dimensions defined by the tester are case level and case characteristics, and the multi-item target attribute information includes (1) case number "tc_001|tc_002", (2) case name "tc_n001|tc_n002", (3) case module "tc_module_a", (4) case module "tc_sub_module_a", (5) case level "2", and (6) case characteristic "performance|stability", and then the correlation corresponding to the target attribute information (5) and the correlation corresponding to the target attribute information (6) are both 50%, and the correlation corresponding to the other target attribute information is 0%.
S307, for each item of target attribute information, when the correlation degree corresponding to the target attribute information meets the preset correlation degree condition, determining the target attribute information as test case screening information, and obtaining a test case screening condition set.
The preset correlation condition is the correlation requirement of test case screening information and test dimensions defined by testers. Specifically, the preset relevance condition may be set as a ranking requirement of the relevance corresponding to the target attribute information, or may be set as a relevance value requirement corresponding to the target attribute information.
The test case screening information is information meeting preset relativity conditions in the multi-item label attribute information. In specific implementation, if the preset correlation condition is that the correlation between the target attribute information and the test dimension is greater than 30%, the correlation corresponding to the target attribute information (5) and the correlation corresponding to the target attribute information (6) are both 50% and greater than 30%, the test case screening information is the target attribute information (5) case level "2" and the target attribute information (6) case characteristic "performance|stability".
The test case screening condition set is a set formed by test case screening information. For example, the test case screening information is case level "2" and case characteristics "performance |stability", and the test case screening condition set is { case level "2", case characteristics "performance|stability" }. In specific implementation, if the number of test case screening information is 0, the test case screening condition set is an empty set.
S309, determining a plurality of target test case objects in a test case library based on the test case screening condition set.
Wherein the attribute information in each target test case object is matched with the test case screening condition set.
In specific implementation, traversing test case objects in a test case library, matching attribute information of test cases stored in the test case objects with test case screening information in test case screening condition sets, and inserting test cases indicated by function entry addresses stored in the test case objects which are successfully matched, namely target test cases, into a task linked list to obtain a to-be-executed case linked list of a target test task. Specifically, taking the test case screening condition set { case level "2", and the case characteristic "performance|stability" } as an example, the attribute information stored in the target test case object at least includes two attributes of the case level "2" and the case characteristic "performance|stability", for example, the test case object object_001 in the test case library has the following attribute information: case number "tc_001", case name "tc_n001", case module "tc_module_a", case module "tc_sub_module_a", case level "2", case property "performance|stability". And the test case object object_001 is successfully matched with the test case screening condition set, and the test case TC_001 indicated by the function entry address stored in the test case object object_001 is taken as a target test case and inserted into a task linked list.
According to the technical scheme, the use cases in the test case library are screened according to different test dimensions, and the screening range is freely and flexibly defined, so that the test can be performed more accurately and efficiently for the use cases in the specific range.
In an exemplary embodiment, the attribute of the test case has priority, and the step S309 may include the steps of:
determining the priority of test case screening information in the test case screening condition set;
and screening the test case objects in the test case library according to the order of the priority from high to low based on the test case screening information in the test case screening condition set to obtain a plurality of target test case objects.
In specific implementation, the highest priority is the case level, that is, one or more test cases are specifically designated, and other filtering information is not considered. Otherwise, screening is carried out according to personal version products, enterprise version products, modules, sub-modules and use case levels in sequence.
As can be seen from the above technical solutions of the embodiments of the present application, the embodiments of the present application screen test cases according to the order of the priority of the test case screening information from high to low, thereby screening test cases that best fit the test task.
S203, for each target test case object, determining a corresponding target test case based on the function entry address in the target test case object.
The function entry address in the target test case object is the address of a first instruction executed when the corresponding target test case is executed, and the target test case can be called based on the function entry address in the target test case object.
According to the technical scheme, the matched attribute information is screened through the task description file configured by the user, so that the matched test case object is determined, the test case is called based on the function entry address stored in the matched test case object, the test case with the required granularity is accurately screened out, the object storage is easy to expand, and the elastic expansion of the stored attribute information can be realized.
S105, traversing the shared test data set for each target test case based on the test case registration information.
The shared test data set comprises a plurality of shared key value pairs, and the shared key value pairs store test data identifiers and test data.
In specific implementation, for each target test case, according to the test data identifier corresponding to each test case in the test case registration information, determining the test data identifier of the target test case, traversing the shared test data set to determine whether the shared test data set has the test data identifier, and then determining whether test data required by the target test case is stored in the shared test data set.
S107, judging whether the test data identifier corresponding to the target test case exists in the shared test data set.
Specifically, if the result of the determination is yes, step S109 may be executed; otherwise, if the result of the determination is negative, step S1011 may be performed.
In the specific implementation, if the test data identifier corresponding to the target test case exists in the shared test data set, directly calling; if the test data identifier corresponding to the target test case does not exist in the shared test data set, constructing test data and calling.
S109, calling test data corresponding to the test data identifier corresponding to the target test case in the shared test data set, and executing the target test case to obtain a test result.
In specific implementation, a shared key value pair which stores the test data identifier corresponding to the target test case is determined, and the test data stored in the key value pair is called.
S1011, determining test data parameters corresponding to the target test case based on the test case registration information.
Specifically, according to the test data parameters corresponding to each test case in the test case registration information, determining the test data parameters corresponding to the target test case, and constructing test data through the parameters so as to be called by the test case in the execution process.
S1013, constructing target test data based on the test data parameters corresponding to the target test cases.
The target test data are test data required by the target test case. Specifically, the test data parameters corresponding to the target test cases are used as the input of the construction function to construct the target test data. For example, when a test is performed, a data D is required to be constructed, the parameters required for generating D are known as a private key i, and when the private key i is used as an input of a test data constructing function D, d=d (int i), and the obtained encrypted public key D is the target test data.
In an exemplary embodiment, the test data information further includes an applicable level of the test data, as shown in fig. 4, after the step S1013, may further include:
s401, if the test data identifier corresponding to the target test case is multiplexed in the test case registration information, a target shared key value pair is constructed based on the test data identifier corresponding to the target test case and the target test data.
Specifically, the test case registration information stores the test data identifier corresponding to each test case, whether the test data corresponding to the test data identifier is multiplexed is judged according to whether the test data identifier is repeated, if yes, the test data identifier and the corresponding test data are inserted into the shared test data set for direct calling of other test cases in the execution process, and if no multiplexing exists, the shared test data set is not required to be inserted.
S403, inserting the target sharing key value pair into the sharing test data set.
The key value of the target shared key value pair is a test data identifier corresponding to the target test case, the key value item is target test data, and the test data is called in the shared test data set only according to the test data identifier.
S405, determining the application level of the target test data in the test case registration information based on the target test case.
The application level of the target test data is determined according to the application level corresponding to each test case in the test case registration information.
In particular implementations, the applicable levels of test cases may include a case level, a sub-module level, a module level.
S407, setting a lifetime for the target shared key value pair based on the applicable level of the target test data.
The lifetime of the target shared key value pair is the execution period of the test case which belongs to the same applicable level as the target test data.
Specifically, the test cases belonging to the application level automatically release the target shared key value pair after the execution of the test cases is completed.
According to the technical scheme, the multiplexing test data is inserted into the shared test data set, and the lifetime is set for the shared test data set, so that time and space expenses caused by repeated construction of the test data are avoided, and timely and automatic release of the memory of the shared test data set is realized.
S1015, calling target test data, and executing a target test case to obtain a test result.
In specific implementation, a plurality of target test cases are executed in a multithreading manner, execution results of all the test cases are recorded, a test report is generated after analysis, log information in the whole test process is recorded, and the test task is completed.
According to the technical scheme, the test case library containing the case attributes is constructed in advance, the matched attribute information is screened based on the task description file configured by the user, the test cases with the required granularity are accurately screened, and the test cases in a specific range are accurately and efficiently tested when the test cases are automatically executed, so that the cost wasted by invalid test is greatly reduced, and the production efficiency is improved; when each use case is executed, searching and taking are performed in the shared test data set according to the identification of the required test data, so that time and space expenses caused by repeated data construction are saved.
In an exemplary embodiment, as shown in fig. 5, the process of executing the target test case in the above steps S109 and S1015 may include:
s501, determining a main function of each target test case to obtain a plurality of target functions.
The target test case is a case with attribute information matched with the test task description file.
The objective function is the main function of the objective test case.
S503, creating threads according to the preset quantity, randomly determining an objective function corresponding to each thread in a plurality of objective functions, running the corresponding objective function based on the threads, and determining the threads as idle threads when the running of the threads is finished.
The preset number is the number of threads created and can be set when the test task is configured.
The idle threads are threads which are not occupied in the created preset number of threads, namely threads which are not running the objective function.
S505, judging whether the number of running objective functions is smaller than the number of the plurality of objective functions.
Specifically, if the result of the determination is yes, step S407 may be executed; otherwise, if the result of the determination is negative, step S409 may be performed.
The running objective function is a function which is run in a plurality of objective functions.
In the implementation, when the objective function is not completely operated, the objective function which is not operated is continuously operated based on the idle thread until the objective function is completely operated.
S507, for each idle thread, randomly determining an objective function corresponding to the idle thread in the residual objective functions, determining the idle thread as an occupied thread, running the corresponding objective function based on the occupied thread, and determining the occupied thread as the idle thread when the occupied thread is ended.
The residual objective function is a function which is not operated in the plurality of objective functions.
The occupied threads are occupied threads in the created preset number of threads, namely threads running the objective function.
In specific implementation, the test cases may also be executed according to the priorities of the test cases.
S509, generating a test report based on the operation result of the objective function corresponding to each objective test case.
In the specific implementation, the running results of all objective functions are recorded, a test report is generated after analysis, log information in the whole test process is recorded, and the test task is completed.
As can be seen from the above technical solutions of the embodiments of the present application, the embodiments of the present application create a certain number of threads to execute test cases in a multithreading manner, so that the execution efficiency of the test cases is higher.
The process of building a test case library based on the properties of the test cases is described below, and as shown in fig. 6, may specifically include:
S601, a plurality of test cases are obtained.
In practice, test cases are typically from a baseline case library.
S603, labeling attribute information for each test case, and determining a function entry address of the test case.
The attribute information may include, among other things, a use case number, a use case name, a use case level, a use case characteristic, and the like. For example, the following attribute information is labeled for the test case tc_001: case number "tc_001", case name "tc_n001", case module "tc_module_a", case module "tc_sub_module_a", case level "2", case property "performance|stability".
The function entry address of the test case is the address of the first instruction executed when the test case is executed.
S605, the function entry address of the test case and the attribute information corresponding to the test case are packaged into objects, and a plurality of test case objects are obtained.
The test case library comprises a plurality of test case objects, and the test case objects store function entry addresses of the test cases and attribute information corresponding to the test cases.
In specific implementation, each baseline case in the baseline case library is packaged into an object of a TestCase class, and function entries and attribute information of the cases are stored in the object.
S607, based on the plurality of test case objects, a test case library is generated.
In specific implementation, each test case object is inserted into a task linked list and used as a test case library, so that the test case library can be traversed randomly, and the addition, deletion and examination operation is performed on the test case object.
According to the technical scheme, the embodiment of the application marks the attribute information of the test cases, the function entry address of the test cases and the attribute information of the test cases are stored in the object, and the test case library is constructed, so that the test cases can be conveniently screened according to the attribute of the test cases, the test cases with the required granularity can be accurately and efficiently screened, the test can be accurately and efficiently performed on the test cases in a specific range when the test cases are automatically executed, and the elastic expansion and contraction of the attribute information of the stored test cases can be realized.
The embodiment of the application also provides a test case library-based test device corresponding to the test case library-based test method provided by the above embodiments, and the implementation of the test case library-based test method is also applicable to the test case library-based test device provided by the embodiment, and will not be described in detail in the embodiment.
Referring to fig. 7, a schematic structural diagram of a test device based on a test case library according to an embodiment of the present application is shown, where the device has a function of implementing the test method based on the test case library in the above method embodiment, and the function may be implemented by hardware or implemented by executing corresponding software by hardware. As shown in fig. 7, the apparatus may include:
the information acquisition module 710 is configured to acquire a test task description file and test case registration information; the test task description file is used for describing the attribute of the test case corresponding to the target test task; the test case registration information comprises test data information corresponding to each test case, and the test data information comprises a test data identifier;
the case determination module 720 is configured to determine a plurality of target test cases based on the test task description file and the test case library; the test case library comprises a plurality of test case objects; the test case object stores the function entry address of the test case and the attribute information corresponding to the test case; attribute information corresponding to each target test case is matched with the test task description file;
the calling execution module 730 is configured to, for each target test case, traverse the shared test data set based on the test case registration information, call test data corresponding to a test data identifier corresponding to a target test case in the shared test data set when the test data identifier corresponding to the target test case exists in the shared test data set, and execute the target test case to obtain a test result; the shared test data set includes a plurality of shared key value pairs that store test data identification and test data.
In an exemplary embodiment, the test data information further includes a test data parameter; the device also comprises a construction execution module for constructing test data for being called when executing the target test case, wherein the construction execution module comprises:
the parameter determining module is used for determining test data parameters corresponding to the target test cases based on the test case registration information when the test data identifiers corresponding to the target test cases do not exist in the shared test data set;
the data construction module is used for constructing target test data based on the test data parameters corresponding to the target test cases;
and the case execution module is used for calling the target test data and executing the target test case to obtain a test result.
In one exemplary embodiment, the use case determination module includes:
the object determining module is used for determining a plurality of target test case objects in the test case library based on the test task description file; attribute information in each target test case object is matched with the test task description file;
and the application case module is used for determining the corresponding target test case for each target test case object based on the function entry address in the target test case object.
In one exemplary embodiment, the object determination module includes:
the attribute extraction module is used for extracting the content of the test task description file to obtain multi-item label attribute information;
the dimension acquisition module is used for acquiring at least one input test dimension; each test dimension represents the dimension of the attribute of the test case corresponding to the target test task;
the correlation determination module is used for determining the correlation between the target attribute information and at least one test dimension for each item of target attribute information to obtain the correlation corresponding to each item of target attribute information;
the screening condition module is used for determining the target attribute information as test case screening information when the correlation degree corresponding to the target attribute information meets the preset correlation degree condition for each item of target attribute information, so as to obtain a test case screening condition set;
the case object module is used for determining a plurality of target test case objects in the test case library based on the test case screening condition set; the attribute information in each target test case object matches the test case screening condition set.
In one exemplary embodiment, the properties of the test cases have priority; the use case object module comprises:
The priority determining module is used for determining the priority of the test case screening information in the test case screening condition set;
and the case screening module is used for screening the test case objects in the test case library based on the test case screening information in the test case screening condition set according to the order of the priority from high to low to obtain a plurality of target test case objects.
In an exemplary embodiment, the test data information further includes a suitability level of the test data; the apparatus further includes a data insertion module that inserts multiplexed test data into the shared test data set, the data insertion module comprising:
the key value pair construction module is used for constructing a target shared key value pair based on the test data identifier corresponding to the target test case and the target test data if the test data identifier corresponding to the target test case has multiplexing in the test case registration information;
the key value pair inserting module is used for inserting the target sharing key value pair into the sharing test data set;
the level determining module is used for determining the applicable level of the target test data in the test case registration information based on the target test case;
the life cycle setting module is used for setting the life cycle for the target shared key value pair based on the applicable level of the target test data; the lifetime of the target shared key pair is the execution period of the test case belonging to the same applicable level as the target test data.
In an exemplary embodiment, the call execution module or use case execution module includes:
the function determining module is used for determining a main function of each target test case to obtain a plurality of target functions;
the first function operation module is used for creating threads according to the preset quantity, randomly determining an objective function corresponding to each thread in a plurality of objective functions, operating the corresponding objective function based on the threads, and determining the threads as idle threads when the thread operation is finished;
the second function operation module is used for randomly determining an objective function corresponding to the idle thread in the residual objective functions for each idle thread when the number of the operation objective functions is smaller than the number of the plurality of objective functions, determining the idle thread as an occupied thread, operating the corresponding objective function based on the occupied thread, and determining the occupied thread as the idle thread when the operation of the occupied thread is finished until the number of the operation objective functions is equal to the number of the plurality of objective functions, and finishing the random determination; the running objective function is a function which is run in a plurality of objective functions; the residual objective function is a function which is not operated in the plurality of objective functions;
And the report generation module is used for generating a test report based on the operation result of the objective function corresponding to each objective test case.
In an exemplary embodiment, the apparatus further includes a case library construction module for constructing a test case library based on the attributes of the test case, the case library construction module including:
the case acquisition module is used for acquiring a plurality of test cases;
the information determining module is used for marking attribute information for each test case and determining the function entry address of the test case;
the object packaging module is used for packaging the function entry address of the test case and the attribute information corresponding to the test case into objects to obtain a plurality of test case objects;
and the case library generating module is used for generating a test case library based on the plurality of test case objects.
It should be noted that, in the apparatus provided in the foregoing embodiment, when implementing the functions thereof, only the division of the foregoing functional modules is used as an example, in practical application, the foregoing functional allocation may be implemented by different functional modules, that is, the internal structure of the device is divided into different functional modules, so as to implement all or part of the functions described above. In addition, the apparatus and the method embodiments provided in the foregoing embodiments belong to the same concept, and specific implementation processes of the apparatus and the method embodiments are detailed in the method embodiments and are not repeated herein.
The embodiment of the application provides electronic equipment, which comprises a processor and a memory, wherein at least one instruction or at least one section of program is stored in the memory, and the at least one instruction or the at least one section of program is loaded and executed by the processor to realize any test method based on a test case library.
The memory may be used to store software programs and modules that the processor executes to perform various functional applications and data processing by executing the software programs and modules stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, application programs required for functions, and the like; the storage data area may store data created according to the use of the device, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide access to the memory by the processor.
The method embodiments provided by the embodiments of the present application may be performed in a computer terminal, a server, or a similar computing device, i.e., the electronic device may include a computer terminal, a server, or a similar computing device. FIG. 8 is a block diagram of a hardware structure of a computer device for running a test method based on a test case library according to an embodiment of the present application, and as shown in FIG. 8, the internal structure of the computer device may include, but is not limited to: processor, network interface and memory. The processors, network interfaces, and memories in the computer device may be connected by a bus or other means, and in fig. 8 shown in the embodiment of the present disclosure, the connection by a bus is an example.
Among them, a processor (or CPU (Central Processing Unit, central processing unit)) is a computing core and a control core of a computer device. The network interface may optionally include a standard wired interface, a wireless interface (e.g., WI-FI, mobile communication interface, etc.). Memory (Memory) is a Memory device in a computer device for storing programs and data. It will be appreciated that the memory herein may be a high speed RAM memory device or a non-volatile memory device, such as at least one magnetic disk memory device; optionally, at least one memory device located remotely from the processor. The memory provides a storage space that stores an operating system of the electronic device, which may include, but is not limited to: windows (an operating system), linux (an operating system), android (an Android, a mobile operating system) system, IOS (a mobile operating system) system, etc., the invention is not limited in this regard; also stored in the memory space are one or more instructions, which may be one or more computer programs (including program code), adapted to be loaded and executed by the processor. In the embodiment of the specification, the processor loads and executes one or more instructions stored in the memory to realize the test method based on the test case library provided by the embodiment of the method.
Embodiments of the present application also provide a computer readable storage medium that may be provided in an electronic device to store at least one instruction or at least one program for implementing a test case library-based test method correlation, where the at least one instruction or the at least one program is loaded and executed by the processor to implement any of the test case library-based test methods provided in the above method embodiments.
Alternatively, in the present embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It should be noted that: the sequence of the embodiments of the present application is only for description, and does not represent the advantages and disadvantages of the embodiments. And the foregoing description has been directed to specific embodiments of this specification. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments in part.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The foregoing description of the preferred embodiments of the application is not intended to limit the application to the precise form disclosed, and any such modifications, equivalents, and alternatives falling within the spirit and scope of the application are intended to be included within the scope of the application.

Claims (10)

1. A test method based on a test case library, the method comprising:
acquiring a test task description file and test case registration information; the test task description file is used for describing the attribute of the test case corresponding to the target test task; the test case registration information comprises test data information corresponding to each test case, and the test data information comprises a test data identifier;
Determining a plurality of target test cases based on the test task description file and the test case library; the test case library comprises a plurality of test case objects; the test case object stores the function entry address of the test case and the attribute information corresponding to the test case; attribute information corresponding to each target test case is matched with the test task description file;
for each target test case, traversing a shared test data set based on the test case registration information, and calling test data corresponding to the test data identifier corresponding to the target test case in the shared test data set when the test data identifier corresponding to the target test case exists in the shared test data set, so as to execute the target test case and obtain a test result; the shared test data set includes a plurality of shared key-value pairs that hold test data identification and test data.
2. The test case library based test method of claim 1, wherein the test data information further comprises test data parameters; the method further comprises the steps of:
when the test data identifier corresponding to the target test case does not exist in the shared test data set, determining test data parameters corresponding to the target test case based on the test case registration information;
Constructing target test data based on the test data parameters corresponding to the target test cases;
and calling the target test data, and executing the target test case to obtain a test result.
3. The test case library-based test method of claim 1, wherein the determining a plurality of target test cases based on the test task description file and the test case library comprises:
determining a plurality of target test case objects in the test case library based on the test task description file; attribute information in each target test case object is matched with the test task description file;
for each target test case object, determining a corresponding target test case based on a function entry address in the target test case object.
4. The test case library-based test method of claim 3, wherein said determining a plurality of target test case objects in said test case library based on said test task description file comprises:
extracting the content of the test task description file to obtain multi-item label attribute information;
acquiring at least one input test dimension; each test dimension represents the dimension of the attribute of the test case corresponding to the target test task;
For each item of target attribute information, determining the correlation degree of the target attribute information and the at least one test dimension to obtain the correlation degree corresponding to each item of target attribute information;
for each item of target attribute information, when the correlation degree corresponding to the target attribute information meets a preset correlation degree condition, determining the target attribute information as test case screening information, and obtaining a test case screening condition set;
determining the plurality of target test case objects in the test case library based on the test case screening condition set; and the attribute information in each target test case object is matched with the test case screening condition set.
5. The test case library based test method of claim 4, wherein the attributes of the test cases have priority; the determining the plurality of target test case objects in the test case library based on the test case screening condition set includes:
determining the priority of the test case screening information in the test case screening condition set;
and screening the test case objects in the test case library according to the order of the priority from high to low based on the test case screening information in the test case screening condition set to obtain the plurality of target test case objects.
6. The test case library based test method of claim 2, wherein the test data information further comprises a level of applicability of the test data; the method further comprises the steps of:
if the test data identifier corresponding to the target test case is multiplexed in the test case registration information, a target shared key value pair is constructed based on the test data identifier corresponding to the target test case and the target test data;
inserting the target shared key value pair into the shared test data set;
determining the application level of the target test data in the test case registration information based on the target test case;
setting a lifetime for the target shared key value pair based on the applicable level of the target test data; the lifetime of the target shared key value pair is the execution period of the test case which belongs to the same applicable level with the target test data.
7. The test case library-based test method according to claim 1 or 2, wherein the executing the target test case comprises:
for each target test case, determining a main function of the target test case to obtain a plurality of target functions;
Creating threads according to a preset number, randomly determining an objective function corresponding to each thread in the multiple objective functions for each thread, running the corresponding objective function based on the thread, and determining the thread as an idle thread when the thread is ended to run;
when the number of running objective functions is smaller than the number of the plurality of objective functions, for each idle thread, randomly determining an objective function corresponding to the idle thread in the remaining objective functions, determining the idle thread as an occupied thread, running the corresponding objective function based on the occupied thread, and determining the occupied thread as an idle thread when the occupied thread is running, until the number of running objective functions is equal to the number of the plurality of objective functions, and ending the random determination; the running objective function is a function which is run in the plurality of objective functions; the residual objective function is a function which is not operated in the plurality of objective functions;
and generating a test report based on the operation result of the objective function corresponding to each objective test case.
8. The test case library-based testing method of any one of claims 1-7, further comprising:
Acquiring a plurality of test cases;
labeling attribute information for each test case, and determining a function entry address of the test case;
encapsulating the function entry address of the test case and the attribute information corresponding to the test case into objects to obtain a plurality of test case objects;
and generating the test case library based on the plurality of test case objects.
9. A test case library-based testing apparatus, the apparatus comprising:
the information acquisition module is used for acquiring the test task description file and the test case registration information; the test task description file is used for describing the attribute of the test case corresponding to the target test task; the test case registration information comprises test data information corresponding to each test case, and the test data information comprises a test data identifier;
the case determining module is used for determining a plurality of target test cases based on the test task description file and the test case library; the test case library comprises a plurality of test case objects; the test case object stores the function entry address of the test case and the attribute information corresponding to the test case; attribute information corresponding to each target test case is matched with the test task description file;
The calling execution module is used for traversing the shared test data set for each target test case based on the test case registration information, and calling the test data corresponding to the test data identifier corresponding to the target test case in the shared test data set when the test data identifier corresponding to the target test case exists in the shared test data set, so as to execute the target test case and obtain a test result; the shared test data set includes a plurality of shared key-value pairs that hold test data identification and test data.
10. An electronic device comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the test case library-based test method of any one of claims 1-8.
CN202310803625.0A 2023-06-30 2023-06-30 Test case library-based test method and device and electronic equipment Pending CN116841885A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310803625.0A CN116841885A (en) 2023-06-30 2023-06-30 Test case library-based test method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310803625.0A CN116841885A (en) 2023-06-30 2023-06-30 Test case library-based test method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN116841885A true CN116841885A (en) 2023-10-03

Family

ID=88159449

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310803625.0A Pending CN116841885A (en) 2023-06-30 2023-06-30 Test case library-based test method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN116841885A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117435514A (en) * 2023-12-21 2024-01-23 杭州罗莱迪思科技股份有限公司 Extraction method for smoke emission test case
CN118035020A (en) * 2024-04-11 2024-05-14 成都佰维存储科技有限公司 Automatic test method, device, electronic equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117435514A (en) * 2023-12-21 2024-01-23 杭州罗莱迪思科技股份有限公司 Extraction method for smoke emission test case
CN117435514B (en) * 2023-12-21 2024-03-01 杭州罗莱迪思科技股份有限公司 Extraction method for smoke emission test case
CN118035020A (en) * 2024-04-11 2024-05-14 成都佰维存储科技有限公司 Automatic test method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN116841885A (en) Test case library-based test method and device and electronic equipment
CN110231994B (en) Memory analysis method, memory analysis device and computer readable storage medium
CN109032631B (en) Application program patch package obtaining method and device, computer equipment and storage medium
CN110554962A (en) Regression testing process covering method, server and computer readable storage medium
CN110928777B (en) Test case processing method, device, equipment and storage medium
CN110162466B (en) Automatic test method, device, computer equipment and storage medium
CN113342685A (en) Precise test method and device, computer equipment and storage medium
CN115357515B (en) Debugging method and device of multi-core system, computer equipment and storage medium
CN103186463B (en) Determine the method and system of the test specification of software
CN111783094A (en) Data analysis method and device, server and readable storage medium
CN110750457A (en) Automatic unit testing method and device based on memory database
CN111221721B (en) Automatic recording and executing method and device for unit test cases
CN117370203B (en) Automatic test method, system, electronic equipment and storage medium
CN108897678B (en) Static code detection method, static code detection system and storage device
CN112463596B (en) Test case data processing method, device and equipment and processing equipment
CN111562952B (en) Dynamic loading method and dynamic loading device for double-core intelligent ammeter management unit
CN117493188A (en) Interface testing method and device, electronic equipment and storage medium
CN112559343A (en) Test path generation method and related equipment
CN111240974A (en) Log output method and device, electronic equipment and medium
CN111400171A (en) Interface testing method, system, device and readable storage medium
CN107656849B (en) Method and device for positioning performance problem of software system
CN115617668A (en) Compatibility testing method, device and equipment
CN113127367B (en) Defect detection method for Android dynamic permission application
CN113282504A (en) Incremental code coverage rate detection method and service development method and device
CN114490413A (en) Test data preparation method and device, storage medium and electronic equipment

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