Automatic testing method and device for recruitment platform background program, equipment and medium
By generating configuration files and filtering test modules and use cases with pytest framework, the problem of duplication and complex operations in the background program test of the recruitment platform is solved, and an efficient and automated testing process is achieved.
Patent Information
- Application Number
- CN202411510463.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-10
AI Technical Summary
In the background program testing of existing recruitment platforms, setup and teardown functions need to be written for each test function, resulting in high code repetition rate and difficult maintenance. It also eliminates unexecuted test functions and their pre-data difficult, and the operation is complicated.
By generating test modules, test classes and test function configuration files, combining pytest testing framework, filter out target test modules, test classes and test functions, batch insert and delete pre-data, generate executable test cases, reduce code changes and improve Test efficiency.
It realizes flexible testing modules and use case management, reduces code duplication, improves testing efficiency and maintenance, and simplifies automated testing processes.
Smart Images

Figure CN119292941A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet platform technology, and in particular to an automated testing method, device, equipment and medium for a background program of a recruitment platform. Background Art
[0002] The background program of the recruitment platform is the system and software component that supports the normal operation of the recruitment platform. In order to ensure the normal operation of the recruitment platform and the background program, it is necessary to test the background program of the recruitment platform. The recruitment platform usually includes multiple background programs, each of which can correspond to at least one test function, at least one test function can belong to a test class, and at least one test class can belong to a test module (session).
[0003] When testing, if you write setup and teardown functions for each session / class, you cannot exclude unexecuted test functions and their corresponding pre-data. If you write a setup and teardown function for each test function, the code duplication rate is high, and if you need to modify some of the same logic, you need to modify multiple test functions, which is a large amount of modification and difficult to maintain.
[0004] In some solutions of related technologies, in order to exclude unexecuted test functions, it is usually necessary to manually modify the code before executing the test to mark the test functions that do not need to be executed with the @skip annotation, or to classify all test functions and mark them with custom annotations. This is not only time-consuming and labor-intensive, but also unfriendly to non-testers and internal collaboration within the test. In addition, this method also requires specifying the tags that need to be executed in the execution command, which is more complicated. Summary of the invention
[0005] In view of this, the embodiments of the present application provide an automated testing method, device, equipment and medium for a recruitment platform backend program, which are used to solve at least one of the above technical problems.
[0006] In a first aspect, an embodiment of the present application provides an automated testing method for a background program of a recruitment platform, including: generating a test module configuration file, a test class configuration file, and a test function configuration file, wherein the recruitment platform includes multiple background programs, each test module includes at least one test class, each test class includes at least one test function, each test function corresponds to at least one background program and includes at least one test case; the test module configuration file includes a first identifier of a target test module to be executed, the test class configuration file includes a second identifier of a target test class to be executed, the test function configuration file includes a third identifier of a target test function to be executed, the location of pre-data of each test case in the target test function, and the location of parameterized data, the parameterized data includes at least a use case description and an execution status of the test case, if the execution status of the test case is yes, the test case is the first target test case to be tested; setting a batch insert command row parameters; read the test module configuration file, the test class configuration file and the test function configuration file, and filter out the target test function in the target test module from the multiple test modules collected by the pytest test framework according to the first identifier, the second identifier and the third identifier; if the batch insert command line parameter is yes, then for the multiple first target test cases whose execution status is yes in the target test function, read the pre-data of the multiple first target test cases, and batch insert the pre-data of the multiple first target test cases into the database; based on the parameterized data of the multiple first target test cases, generate multiple second target test cases that can be executed by the pytest test framework, and the multiple second target test cases correspond one to one to the multiple first target test cases; execute the multiple second target test cases, and after the multiple second target test cases are executed, batch delete the pre-data inserted in the database and the process data generated when executing the multiple second target test cases.
[0007] According to some embodiments of the present application, optionally, the recruitment platform includes a job recommendation system and a resume recommendation system, and the multiple background programs include at least one first background data synchronization program of the job recommendation system, at least one second background data synchronization program of the resume recommendation system, and at least one third background data synchronization program; each first background data synchronization program corresponds to a first test function, each second background data synchronization program corresponds to a second test function, and each third background data synchronization program corresponds to a third test function; the target test function includes at least one of the first test function, the second test function, and the third test function; the prerequisite data of the test case includes the test case ID, the source database, the source data table, and the data content, and the parameterized data of the test case includes the test case ID, the case description, the target database, the target data table, the execution status, and the expected data.
[0008] According to some embodiments of the present application, optionally, the automated testing method of the recruitment platform background program also includes: if the batch insertion command line parameter is no, then after generating multiple second target test cases, the prerequisite data of the i-th first target test case corresponding to the i-th second target test case is inserted into the database, and the i-th second target test case is executed, and after executing the i-th second target test case, the prerequisite data of the i-th first target test case inserted in the database is deleted, and the process data generated when executing the i-th second target test case is deleted, where i is a positive integer.
[0009] According to some embodiments of the present application, optionally, based on the first identifier, the second identifier and the third identifier, a target test function in a target test module is filtered out from multiple test modules collected by the pytest test framework, including: based on the first identifier, filtering out the target test module corresponding to the first identifier from multiple test modules collected by the pytest test framework, and discarding other test modules except the target test module; based on the second identifier, filtering out the target test class corresponding to the second identifier from the target test module, and discarding other test classes except the target test class; based on the third identifier, filtering out the target test function corresponding to the third identifier from the target test class.
[0010] According to some embodiments of the present application, optionally, the automated testing method of the recruitment platform background program also includes: updating the test module configuration file, the test class configuration file and the test function configuration file when the background program to be tested and / or the first target test case are updated.
[0011] According to some embodiments of the present application, optionally, based on the parameterized data of multiple first target test cases, multiple second target test cases that can be executed by the pytest test framework are generated, including: based on the locations of the parameterized data of multiple first target test cases in the test function configuration file, reading the parameterized data of the multiple first target test cases, and transferring the parameterized data of the multiple first target test cases to the parameterized decorator of the pytest test framework to generate multiple second target test cases.
[0012] According to some embodiments of the present application, optionally, executing multiple second target test cases includes: executing the multiple second target test cases simultaneously, and after the multiple second target test cases are executed, simultaneously outputting test reports of the multiple second target test cases.
[0013] In a second aspect, an embodiment of the present application provides an automated testing device for a background program of a recruitment platform, including: a generation module, used to generate a test module configuration file, a test class configuration file, and a test function configuration file, wherein the recruitment platform includes multiple background programs, each test module includes at least one test class, each test class includes at least one test function, each test function corresponds to at least one background program and includes at least one test case; the test module configuration file includes a first identifier of a target test module to be executed, the test class configuration file includes a second identifier of a target test class to be executed, the test function configuration file includes a third identifier of a target test function to be executed, the location of the pre-data of each test case in the target test function, and the location of parameterized data, the parameterized data includes at least a use case description and an execution status of the test case, if the execution status of the test case is yes, the test case is the first target test case to be tested; a setting module, used to set batch insert commands row parameters; a screening module, used to read the test module configuration file, the test class configuration file and the test function configuration file, and according to the first identifier, the second identifier and the third identifier, filter out the target test function in the target test module from the multiple test modules collected by the pytest test framework; an execution module, used to read the pre-data of multiple first target test cases for the multiple first target test cases whose execution status is yes in the target test function if the batch insert command line parameter is yes, and batch insert the pre-data of the multiple first target test cases into the database; based on the parameterized data of the multiple first target test cases, generate multiple second target test cases that can be executed by the pytest test framework, and the multiple second target test cases correspond one to one to the multiple first target test cases; execute the multiple second target test cases, and after the multiple second target test cases are executed, batch delete the pre-data inserted in the database and the process data generated when executing the multiple second target test cases.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the steps of the automated testing method for the background program of the recruitment platform as described above are implemented.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, the steps of the automated testing method for the background program of the recruitment platform as described above are implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes computer program instructions. When the computer program instructions are executed by a processor, the steps of the automated testing method for the background program of the recruitment platform as described above are implemented.
[0017] The automated testing method, device, equipment and medium of the recruitment platform background program provided by the embodiment of the present application are adopted. On the one hand, by setting the test module configuration file, the test class configuration file and the test function configuration file, the target test module, the target test class and the target test function to be executed are specified, and the multiple first target test cases to be tested can be screened out in combination with the execution state of the test case, and the multiple second target test cases corresponding to the multiple first target test cases to be executed by the pytest test framework are subsequently generated, so as to realize the test for the multiple second target test cases. In this way, the test modules, test classes, test functions and test cases to be tested are uniformly managed through the configuration file. When changing the test modules, test classes, test functions or test cases to be tested, it is only necessary to change the corresponding configuration file, which reduces the changes to the pytest test framework code itself or the code of jenkins, and is flexible and convenient to maintain. On the other hand, based on the combination of multiple configuration files with the pytest test framework, the present application can be based on the pytest test framework to realize only testing a part of the test cases of one or more background programs, which meets the test requirements of different situations, improves the test efficiency and shortens the test time. On the other hand, by batch inserting command line parameters and setting the execution status of test cases, multiple first target test cases that need to be tested can be identified, and batch insertion and batch deletion of the preceding data of multiple first target test cases can be achieved, thereby speeding up the execution progress of automated testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following briefly introduces the drawings in the embodiments of the present application.
[0019] Figure 1 A flowchart of an automated testing method for a recruitment platform backend program provided in an embodiment of the present application.
[0020] Figure 2 A structural schematic diagram of an automated testing device for a recruitment platform backend program provided in an embodiment of the present application.
[0021] Figure 3 A schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that the purpose of providing these embodiments is to make the principles and spirit of the present application clearer and more thorough, so that those skilled in the art can better understand and implement the principles and spirit of the present application. The exemplary embodiments provided herein are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments herein, all other embodiments obtained by ordinary technicians of the art without creative work are within the scope of protection of this application.
[0023] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0024] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0025] It is obvious to those skilled in the art that various modifications and changes can be made in the present application without departing from the spirit or scope of the present application. Therefore, the present application is intended to cover modifications and changes of the present application that fall within the scope of the corresponding claims (technical solutions for protection) and their equivalents. It should be noted that the implementation methods provided in the embodiments of the present application can be combined with each other without contradiction.
[0026] Before describing the technical solutions provided by the embodiments of the present application, in order to facilitate the understanding of the embodiments of the present application, the present application first specifically describes the problems existing in the related art:
[0027] The background program of the recruitment platform is the system and software component that supports the normal operation of the recruitment platform. In order to ensure the normal operation of the recruitment platform and the background program, it is necessary to test the background program of the recruitment platform. The recruitment platform usually includes multiple background programs, each of which can correspond to at least one test function, at least one test function can belong to a test class, and at least one test class can belong to a test module (session).
[0028] When testing, if you write setup and teardown functions for each session / class, you cannot exclude unexecuted test functions and their corresponding pre-data. If you write a setup and teardown function for each test function, the code duplication rate is high, and if you need to modify some of the same logic, you need to modify multiple test functions, which is a large amount of modification and difficult to maintain.
[0029] In software development and testing, setup functions and teardown functions are often associated with test frameworks. They are used to set up and clean up the test environment to ensure that each test runs in a clean and consistent state. For example, the setup function can be used to execute before each test runs to initialize the environment and state required for the test. The teardown function can be used to execute after each test is completed to clean up the test environment and release resources.
[0030] In some solutions of related technologies, in order to exclude unexecuted test functions, it is usually necessary to manually modify the code before executing the test to mark the test functions that do not need to be executed with the @skip annotation, or to classify all test functions and mark them with custom annotations. This is not only time-consuming and labor-intensive, but also unfriendly to non-testers and internal collaboration within the test. In addition, this method also requires specifying the tags that need to be executed in the execution command, which is more complicated.
[0031] In view of the above research findings of the inventors, the embodiments of the present application provide an automated testing method, apparatus, device and computer-readable storage medium for a recruitment platform backend program, which can solve at least one of the above technical problems existing in the related art.
[0032] The following first introduces the automated testing method for the recruitment platform backend program provided in the embodiment of the present application.
[0033] Figure 1 A flow chart of an automated testing method for a recruitment platform backend program provided in an embodiment of the present application. Figure 1 As shown, the automated testing method for the recruitment platform background program provided in the embodiment of the present application may include the following steps S101 to S106.
[0034] S101: Generate a test module configuration file, a test class configuration file, and a test function configuration file.
[0035] Among them, the recruitment platform may include multiple background programs. According to the division of test modules, test classes and test functions, each test module may include at least one test class. A test module may also be called a test file, such as a PY file. A PY file is a source code file of the Python programming language, and the file extension may be ".py". A PY file may include at least one test class, such as test class A, test class B and test class C. Test class A, test class B and test class C represent different test classes.
[0036] A test class can be a class that contains multiple test functions, usually organizing and grouping related test cases in some way. Each test class can include at least one test function, each test function corresponds to at least one background program, and each test function (or each background program) can include at least one test case.
[0037] The test module configuration file may include a first identifier of a target test module to be executed. The test module to be executed is called a target test module. Exemplarily, the first identifier may be a name and / or ID of the target test module.
[0038] The test class configuration file may include a second identifier of a target test class to be executed. The test class to be executed is called a target test class. Exemplarily, the second identifier may be a name and / or ID of the target test class.
[0039] The test function configuration file may include a third identifier of the target test function to be executed, the location of the pre-data of each test case in the target test function, and the location of the parameterized data. The test function to be executed is called the target test function, and illustratively, the third identifier may be the name and / or ID of the target test function. The location of the pre-data may be the storage address or access address where the file of the pre-data is located, and the location of the parameterized data may be the storage address or access address where the file of the parameterized data is located.
[0040] The parameterized data of the test case may at least include the test case description and the execution status of the test case. For example, if the execution status of the test case is yes, the test case is the first target test case that needs to be tested. If the execution status of the test case is no, the test case is a test case that does not need to be tested.
[0041] S102: Setting batch insert command line parameters.
[0042] When using the pytest test framework, parameters can be passed in through the command line, such as passing in the batch insert command line parameter batch_insert_pre_data through the command line. The batch insert command line parameter can be a global parameter, which is used to control whether to insert the pre-data in batches. For example, if the batch insert command line parameter is yes, the operation of batch inserting the pre-data and the operation of batch deleting the pre-data are executed. If the batch insert command line parameter is no, the operation of batch inserting the pre-data and the operation of batch deleting the pre-data are not executed. In S102, the batch insert command line parameter batch_insert_pre_data passed in by the command line can be parsed and integrated into the config configuration object of the pytest test framework.
[0043] S103: Read the test module configuration file, the test class configuration file and the test function configuration file, and filter out the target test function in the target test module from the multiple test modules collected by the pytest test framework according to the first identifier, the second identifier and the third identifier.
[0044] Specifically, the test module configuration file, the test class configuration file, and the test function configuration file can be read to obtain the first identification of the target test module to be executed, the second identification of the target test class to be executed, and the third identification of the target test function to be executed. According to the first identification, the second identification, and the third identification, the target test module, the target test class in the target test module, and the target test function in the target test class can be sequentially screened out from multiple test modules collected by the pytest test framework.
[0045] S104: If the batch insert command line parameter is yes, for multiple first target test cases whose execution status in the target test function is yes, read the pre-data of the multiple first target test cases, and batch insert the pre-data of the multiple first target test cases into the database.
[0046] Specifically, if the batch insert command line parameter is yes, such as batch_insert_pre_data is true, then for multiple first target test cases whose execution status in the target test function is yes, the operation of batch inserting pre-data is performed. For example, based on the position of the pre-data of multiple first target test cases in the test function configuration file, the pre-data of multiple first target test cases can be accessed and read, and the pre-data of multiple first target test cases can be batch inserted into the database. In this way, by setting the batch insert command line parameter and the execution status of the test case, the batch insertion of the pre-data of multiple first target test cases can be achieved, which speeds up the execution progress of the automated test. In addition, test cases that do not need to be executed can be excluded, and the pre-data of test cases that do not need to be executed can be excluded.
[0047] S105: Based on the parameterized data of the multiple first target test cases, generate multiple second target test cases that can be executed by the pytest test framework, and the multiple second target test cases correspond one-to-one to the multiple first target test cases.
[0048] For example, the parameterized data of multiple first target test cases can be accessed and read based on the location of the parameterized data of multiple first target test cases in the test function configuration file. In view that multiple first target test cases may not be directly executed by the pytest test framework, multiple second target test cases that can be executed by the pytest test framework can be generated based on the parameterized data of multiple first target test cases. Multiple second target test cases correspond one-to-one to multiple first target test cases, that is, one second target test case corresponds to one first target test case.
[0049] S106: Execute a plurality of second target test cases, and after the plurality of second target test cases are executed, batch delete the pre-data inserted into the database and the process data generated when the plurality of second target test cases are executed.
[0050] After the pre-data of multiple first target test cases are inserted into the database in batches, multiple second target test cases can be executed based on the pytest test framework to test the multiple second target test cases. For any second target test case, actual data can be generated during the execution of the second target test case. And the parameterized data may include the expected data of the second target test case. After the actual data is generated, the generated actual data can be compared with the expected data of the second target test case. If the two are consistent, the second target test case is tested and passed. If the two are inconsistent, the second target test case fails.
[0051] If the operation of inserting batches of pre-data is performed in the preceding step, after the execution of the plurality of second target test cases, the pre-data inserted in the database and the process data generated when executing the plurality of second target test cases can be deleted in batches, wherein the process data includes but is not limited to the actual data mentioned above.
[0052] During automated testing, there may be a need to test only a portion of the test cases for one or more background programs. In view of the problem that the current pytest test framework is difficult to meet the problem of testing only a portion of the test cases for one or more background programs, this application is based on the combination of multiple configuration files and the pytest test framework, and realizes testing only a portion of the test cases for one or more background programs, excluding test cases that do not need to be executed, excluding the pre-data of test cases that do not need to be executed, meeting the testing requirements of different situations, improving testing efficiency, and shortening testing time.
[0053] In addition, the inventors of this application have further discovered that the current pytest testing framework still has the following problems when combined with Jenkins: when changing the test modules, test classes, test functions or test cases that need to be tested, it is necessary to change or rewrite the pytest testing framework's own code or the Jenkins code, and re-specify the test modules, test classes, test functions or test cases that need to be tested, which is complicated to operate and has poor flexibility.
[0054] In view of this, this application specifies the target test module, target test class, and target test function to be executed by setting the test module configuration file, the test class configuration file, and the test function configuration file. Combined with the execution status of the test case, multiple first target test cases that need to be tested can be screened out, and then multiple second target test cases that can be executed by the pytest test framework corresponding to the multiple first target test cases are generated one by one, so as to implement the test of multiple second target test cases. In this way, the test modules, test classes, test functions, and test cases that need to be tested are uniformly managed through configuration files. When changing the test modules, test classes, test functions, or test cases that need to be tested, only the corresponding configuration files need to be changed, which reduces the changes to the pytest test framework's own code or the jenkins code, and is flexible and easy to maintain.
[0055] In addition, the present application can identify multiple first target test cases that need to be tested by batch inserting command line parameters and setting the execution status of test cases, and implement batch insertion and batch deletion of the preceding data of multiple first target test cases, thereby speeding up the execution progress of automated testing.
[0056] According to some embodiments of the present application, the recruitment platform may optionally include a job recommendation system and a resume recommendation system. For example, the job recommendation system may recommend suitable jobs for job seekers based on their needs, thereby helping job seekers find suitable jobs more quickly and accurately. For example, the resume recommendation system may recommend suitable resumes of job seekers for the company based on the needs of the recruiting company, thereby helping the company find suitable talents more quickly and accurately.
[0057] In some examples, the multiple background programs of the recruitment platform may include at least one first background data synchronization program of the job recommendation system, at least one second background data synchronization program of the resume recommendation system, and at least one third background data synchronization program.
[0058] For example, a job recommendation system may include three first background data synchronization programs, namely: program a, program b, and program c. For example, a resume recommendation system may include three second background data synchronization programs, namely: program d, program e, and program f. In addition to the job recommendation system and the resume recommendation system, the recruitment platform may also include third background data synchronization programs with other functions, such as program g, program h, and program i.
[0059] Each first background data synchronization program corresponds to a first test function, each second background data synchronization program corresponds to a second test function, and each third background data synchronization program corresponds to a third test function. The first test function, the second test function and the third test function are different test functions.
[0060] For example, program a, program b and program c may correspond to three first test functions, and the three first test functions may all belong to test class A. Program d, program e and program f may correspond to three second test functions, and the three second test functions may all belong to test class B. Program g, program h and program i may correspond to three third test functions, and the three third test functions may all belong to test class C. It should be noted that the three first test functions may be different test functions, the three second test functions may be different test functions, and the three third test functions may be different test functions. Test class A and test class B may belong to test module 1, and test class C may belong to test module 2. Test module 1 and test module 2 are different test modules.
[0061] The target test function to be executed may include at least one of the first test function, the second test function, and the third test function. The target test function may include one test function or multiple test functions, which may be flexibly adjusted according to actual conditions, and the present application does not limit this. For example, in some examples, the target test function may be the first test function corresponding to program a. For example, in other examples, the target test function may include the first test function corresponding to program a, the second test function corresponding to program e, and the third test function corresponding to program g, and the present application does not limit this.
[0062] When the target test function includes only a test function corresponding to a background program, only at least part of the test cases of the background program can be automatically tested. When the target test function includes test functions corresponding to multiple background programs, at least part of the test cases of the multiple background programs can be automatically tested sequentially or simultaneously.
[0063] In some embodiments, the pre-data of the test case may include the test case ID, source database, source data table and data content. The parameterized data of the test case may include the test case ID, case description, target database, target data table, execution status and expected data.
[0064] Taking the test case of the first background data synchronization program in the job recommendation system as an example, the source database may include a MySQL database, and the data content may include the target job ID and the job content of the target job, and the job content may include the job title, job description and / or work location. The target database may be a redis database, and the expected data may include the target job ID and the job content of the target job, and the job content may include the job title, job description and / or work location.
[0065] You can first insert the target position's job content in the MySQL database into the Redis database. When executing the test case, you can compare the target position's job content inserted into the Redis database with the target position's job content in the parameterized data. If the two are consistent, the test case passes. If they are inconsistent, the test case fails.
[0066] According to some embodiments of the present application, optionally, the automated testing method of the recruitment platform backend program may further include the following steps:
[0067] If the batch insert command line parameter is no, then after generating multiple second target test cases, the prerequisite data of the i-th first target test case corresponding to the i-th second target test case is inserted into the database, and the i-th second target test case is executed, and after executing the i-th second target test case, the prerequisite data of the i-th first target test case inserted in the database is deleted, and the process data generated when executing the i-th second target test case is deleted, where i is a positive integer.
[0068] Specifically, if the batch insert command line parameter is false, such as batch_insert_pre_data is false, the batch insert pre-data operation may not be performed. Instead, the pre-data of the i-th first target test case corresponding to the i-th second target test case is inserted into the database before executing the i-th second target test case. For example, the pre-data of the i-th first target test case corresponding to the i-th second target test case may be inserted into the target data table of the target database through the setup function.
[0069] Then, execute the i-th second target test case, and compare the generated actual data with the expected data of the i-th second target test case. If the two are consistent, the i-th second target test case passes the test; if the two are inconsistent, the i-th second target test case fails the test.
[0070] After executing the i-th second target test case, the pre-data of the i-th first target test case inserted into the target data table of the target database is deleted through the teardown function, and the actual data generated when executing the i-th second target test case is deleted. For example, the pre-data corresponding to the i-th second target test case can be obtained according to the test case ID and the test function configuration file of the i-th second target test case, and then the pre-data of the i-th first target test case is deleted in the target database, and the actual data generated when executing the i-th second target test case is deleted.
[0071] According to some embodiments of the present application, optionally, S103: filtering out a target test function in a target test module from multiple test modules collected by the pytest test framework according to the first identifier, the second identifier, and the third identifier may include the following steps one to three.
[0072] Step 1: According to the first identifier, filter out a target test module corresponding to the first identifier from multiple test modules collected by the pytest test framework, and discard other test modules except the target test module.
[0073] For example, taking the target test function as the first test function corresponding to program a, that is, only the automated test of program a needs to be executed, according to the first identifier, the target test module corresponding to the first identifier can be screened out from the multiple test modules collected by the pytest test framework, that is, test module 1. Other test modules except test module 1 can be discarded, thereby further improving the test efficiency.
[0074] Step 2: According to the second identifier, a target test class corresponding to the second identifier is screened out from the target test module, and other test classes except the target test class are discarded.
[0075] Still taking the case where the target test function is the first test function corresponding to program a and the target test module is test module 1 as an example, after test module 1 is screened out, the target test class corresponding to the second identifier can be screened out from test module 1 according to the second identifier, that is, test class A. Other test classes except test class A can be discarded, thereby further improving the test efficiency.
[0076] Step three: According to the third identifier, select the target test function corresponding to the third identifier from the target test class.
[0077] After the target test class is screened out, the target test function corresponding to the third identifier can be screened out from the target test class according to the third identifier. Other test functions except the target test function can be discarded, thereby further improving the test efficiency.
[0078] Thus, according to the first identifier, the second identifier and the third identifier, the target test module, the target test class in the target test module, and the target test function in the target test class can be accurately found from the multiple test modules collected by the pytest test framework. In the screening process, the test efficiency can be improved by discarding other test modules, other test classes and / or other test functions that do not need to be executed.
[0079] According to some embodiments of the present application, optionally, S105: generating a plurality of second target test cases executable by the pytest test framework based on the parameterized data of the plurality of first target test cases may include the following steps:
[0080] Based on the locations of the parameterized data of the multiple first target test cases in the test function configuration file, the parameterized data of the multiple first target test cases are read, and the parameterized data of the multiple first target test cases are transferred to the parameterized decorator of the pytest test framework to generate multiple second target test cases.
[0081] Specifically, the test function configuration file can be read. For multiple first target test cases whose execution status is yes, the parameterized data of multiple first target test cases can be accessed and read based on the position of the parameterized data of multiple first target test cases in the test function configuration file. Then, the parameterized data of multiple first target test cases are transferred to the parameterized decorator (parametrize function) in the test function (metafunc function) of the pytest test framework to generate multiple second target test cases.
[0082] The parametrize function can be used to parameterize test cases so that the same test function can be called by multiple different input data, thereby improving test coverage and code reusability.
[0083] According to some embodiments of the present application, optionally, the automated testing method of the recruitment platform backend program may further include the following steps:
[0084] When the background program to be tested and / or the first target test case is updated, the test module configuration file, the test class configuration file and the test function configuration file are updated.
[0085] Specifically, when the background program to be tested and / or the first target test case to be tested needs to be changed, you only need to update the test module configuration file, the test class configuration file and the test function configuration file, and perform automated testing on the changed first target test case according to the same test process or script, thereby reducing changes to the pytest test framework's own code or the jenkins code, making it flexible and easy to maintain, and helping to improve testing efficiency.
[0086] According to some embodiments of the present application, optionally, S106: executing multiple second target test cases may include the following steps:
[0087] A plurality of second target test cases are executed simultaneously, and after the plurality of second target test cases are executed, test reports of the plurality of second target test cases are output simultaneously.
[0088] Specifically, multiple second target test cases can be executed simultaneously, that is, multiple second target test cases can be automatically tested at the same time. After the multiple second target test cases are executed, test reports of the multiple second target test cases can be output simultaneously. In this way, the test efficiency can be improved, and there is no need to start multiple automation programs.
[0089] Based on the same technical concept as the automated testing method for the background program of the recruitment platform provided in the above embodiment, the present application also provides an automated testing device for the background program of the recruitment platform.
[0090] Figure 2 A schematic diagram of a structure of an automated testing device for a recruitment platform backend program provided in an embodiment of the present application. Figure 2 As shown, the automated testing device 20 for the recruitment platform backend program provided in the embodiment of the present application may include the following modules:
[0091] A generation module 201 is used to generate a test module configuration file, a test class configuration file and a test function configuration file, wherein the recruitment platform includes multiple background programs, each test module includes at least one test class, each test class includes at least one test function, each test function corresponds to at least one background program and includes at least one test case;
[0092] The test module configuration file includes a first identifier of a target test module to be executed, the test class configuration file includes a second identifier of a target test class to be executed, and the test function configuration file includes a third identifier of a target test function to be executed, the location of the pre-data of each test case in the target test function, and the location of the parameterized data, the parameterized data includes at least a test case description and an execution status of the test case, and if the execution status of the test case is yes, the test case is the first target test case to be tested;
[0093] Setting module 202, used to set batch insert command line parameters;
[0094] A screening module 203 is used to read a test module configuration file, a test class configuration file, and a test function configuration file, and screen out a target test function in a target test module from multiple test modules collected by the pytest test framework according to the first identifier, the second identifier, and the third identifier;
[0095] An execution module 204 is used to read the pre-data of multiple first target test cases for multiple first target test cases whose execution status is yes in the target test function if the batch insert command line parameter is yes, and batch insert the pre-data of multiple first target test cases into the database; based on the parameterized data of the multiple first target test cases, generate multiple second target test cases that can be executed by the pytest test framework, and the multiple second target test cases correspond one-to-one to the multiple first target test cases; execute the multiple second target test cases, and after the multiple second target test cases are executed, batch delete the pre-data inserted in the database and the process data generated when executing the multiple second target test cases.
[0096] The automated testing device of the background program of the recruitment platform provided by the embodiment of the present application, on the one hand, by setting the test module configuration file, the test class configuration file and the test function configuration file, specifying the target test module, the target test class and the target test function to be executed, combining the execution state of the test case to screen out the multiple first target test cases to be tested, and subsequently generating multiple second target test cases corresponding to the multiple first target test cases that can be executed by the pytest test framework, to achieve the test for the multiple second target test cases. In this way, the test modules, test classes, test functions and test cases to be tested are uniformly managed by the configuration file. When changing the test modules, test classes, test functions or test cases to be tested, it is only necessary to change the corresponding configuration file, which reduces the changes to the pytest test framework's own code or the code of jenkins, and is flexible and convenient to maintain. On the other hand, based on the combination of multiple configuration files with the pytest test framework, the present application can be based on the pytest test framework to achieve only a part of the test cases of one or more background programs to be tested, which meets the test requirements of different situations, improves the test efficiency and shortens the test time. On the other hand, by batch inserting command line parameters and setting the execution status of test cases, multiple first target test cases that need to be tested can be identified, and batch insertion and batch deletion of the preceding data of multiple first target test cases can be achieved, thereby speeding up the execution progress of automated testing.
[0097] According to some embodiments of the present application, optionally, the recruitment platform includes a job recommendation system and a resume recommendation system, and the multiple background programs include at least one first background data synchronization program of the job recommendation system, at least one second background data synchronization program of the resume recommendation system, and at least one third background data synchronization program. Each first background data synchronization program corresponds to a first test function, each second background data synchronization program corresponds to a second test function, and each third background data synchronization program corresponds to a third test function; the target test function includes at least one of the first test function, the second test function, and the third test function. The pre-data of the test case includes the test case ID, the target database, the target data table, and the data content, and the parameterized data of the test case includes the test case ID, the case description, the source database, the source data table, the execution status, and the expected data.
[0098] According to some embodiments of the present application, optionally, the execution module 204 can also be used to, if the batch insert command line parameter is no, then after generating multiple second target test cases, insert the pre-data of the i-th first target test case corresponding to the i-th second target test case into the database, and execute the i-th second target test case, and after executing the i-th second target test case, delete the pre-data of the i-th first target test case inserted in the database, and delete the process data generated when executing the i-th second target test case, where i is a positive integer.
[0099] According to some embodiments of the present application, optionally, the filtering module 203 can be specifically used to filter out a target test module corresponding to a first identifier from multiple test modules collected by the pytest testing framework according to a first identifier, and discard other test modules except the target test module; filter out a target test class corresponding to the second identifier from the target test module according to a second identifier, and discard other test classes except the target test class; and filter out a target test function corresponding to the third identifier from the target test class according to a third identifier.
[0100] According to some embodiments of the present application, optionally, the automated testing device 20 for the recruitment platform background program provided by the embodiments of the present application may also include an update module for updating the test module configuration file, the test class configuration file and the test function configuration file when the background program to be tested and / or the first target test case are updated.
[0101] According to some embodiments of the present application, optionally, the execution module 204 can be specifically used to read the parameterized data of multiple first target test cases based on the location of the parameterized data of multiple first target test cases in the test function configuration file, and transfer the parameterized data of the multiple first target test cases to the parameterized decorator of the pytest test framework to generate multiple second target test cases.
[0102] According to some embodiments of the present application, optionally, the execution module 204 can be specifically used to execute multiple second target test cases simultaneously, and after the multiple second target test cases are executed, simultaneously output test reports of the multiple second target test cases.
[0103] Figure 2 Each module / unit in the device shown has the function of implementing each step in the automated testing method of the recruitment platform background program provided in the above method embodiment, and can achieve its corresponding technical effect. For the sake of concise description, it will not be repeated here.
[0104] The electronic device in the embodiment of the present application may be a user terminal device, a server, other computing devices, or a cloud server. Figure 3 This is a hardware structure diagram of an electronic device of an embodiment of the present application. The electronic device may include a processor 301 and a memory 302 storing computer program instructions. When the processor 301 executes the computer program instructions, it implements the process or function of any of the above-mentioned embodiment methods.
[0105] Specifically, the processor 301 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application. The memory 302 may include a large-capacity memory for data or instructions. For example, the memory 302 may be at least one of the following: a hard disk drive (HDD), a read-only memory (ROM), a random access memory (RAM), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, a universal serial bus (USB) drive, or other physical / tangible memory storage devices. For another example, the memory 302 may include a removable or non-removable (or fixed) medium. For another example, the memory 302 may be inside or outside the integrated gateway disaster recovery device. The memory 302 may be a non-volatile solid-state memory. In other words, the memory 302 generally includes a tangible (non-transitory) computer-readable storage medium (such as a memory device) encoded with computer-executable instructions, and when the software is executed (such as executed by one or more processors), the operations described in the method of the embodiments of the present application may be performed. The processor 301 implements the process or function of any method in the above embodiments by reading and executing the computer program instructions stored in the memory 302 .
[0106] In one example, Figure 3The electronic device shown may also include a communication interface 303 and a bus 310. Among them, the processor 301, the memory 302, and the communication interface 303 are connected through the bus 310 and complete the communication between each other. The communication interface 303 is mainly used to realize the communication between each module, device, unit and / or device in the embodiment of the present application. The bus 310 includes hardware, software or both, and can couple the components of the online data traffic billing device to each other. For example, the bus may include at least one of the following: an accelerated graphics port (AGP) or other graphics bus, an enhanced industrial standard architecture (EISA) bus, a front-end bus (FSB), a hypertransport (HT) interconnect, an industrial standard architecture (ISA) bus, an infinite bandwidth interconnect, a low pin count (LPC) bus, a memory bus, a micro channel architecture (MCA) bus, a peripheral component interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a serial advanced technology attachment (SATA) bus, a video electronics standard association local (VLB) bus or other suitable buses. The bus 310 may include one or more buses. Although the embodiments of the present application describe or illustrate a specific bus, the embodiments of the present application may consider any suitable bus or interconnection method.
[0107] In combination with the method in the above embodiments, an embodiment of the present application also provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the process or function of any method in the above embodiments is implemented.
[0108] In addition, an embodiment of the present application further provides a computer program product, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the process or function of any one of the methods in the above embodiments is implemented.
[0109] The above exemplarily describes the flowcharts and / or block diagrams of the methods, devices, systems and computer program products of the embodiments of the present application, and describes the relevant various aspects. It should be understood that each box or combination thereof in the flowchart and / or block diagram can be implemented by computer program instructions, or by dedicated hardware that performs a specified function or action, or by a combination of dedicated hardware and computer instructions. For example, these computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to form a machine that enables these instructions executed by such a processor to enable the implementation of the functions / actions specified in each box or combination thereof in the flowchart and / or block diagram. Such a processor can be a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit.
[0110] The functional blocks shown in the structured block diagram of the embodiment of the present application can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc.; when implemented in software, it is a program or code segment used to perform the required task. The program or code segment can be stored in a memory, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0111] It should be noted that the present application is not limited to the specific configurations and processes described above or shown in the figures. The above is only a specific implementation mode of the present application. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the described system, device, module or unit can refer to the corresponding process in the method embodiment without further description. It should be understood that the scope of protection of the present application is not limited to this. Any technician familiar with the technical field can think of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and these modifications or substitutions should be included in the scope of protection of the present application.
Claims
1. An automated testing method for a recruitment platform background program, characterized in that: include: Generate a test module configuration file, a test class configuration file, and a test function configuration file, wherein the recruitment platform includes multiple background programs, each test module includes at least one test class, each test class includes at least one test function, and each test function corresponds to at least one background program and includes at least one test case; The test module configuration file includes a first identifier of a target test module to be executed, the test class configuration file includes a second identifier of a target test class to be executed, and the test function configuration file includes a third identifier of a target test function to be executed, the location of the pre-data of each test case in the target test function, and the location of the parameterized data, the parameterized data includes at least a test case description and an execution status of the test case, and if the execution status of the test case is yes, the test case is the first target test case to be tested; Set batch insert command line parameters; Read the test module configuration file, the test class configuration file, and the test function configuration file, and filter out the target test function in the target test module from multiple test modules collected by the pytest test framework according to the first identifier, the second identifier, and the third identifier; If the batch insert command line parameter is yes, then for multiple first target test cases whose execution status is yes in the target test function, read the pre-data of the multiple first target test cases, and insert the pre-data of the multiple first target test cases into the database in batches; based on the parameterized data of the multiple first target test cases, generate multiple second target test cases that can be executed by the pytest test framework, and the multiple second target test cases correspond one-to-one to the multiple first target test cases; execute the multiple second target test cases, and after the multiple second target test cases are executed, batch delete the pre-data inserted in the database and the process data generated when executing the multiple second target test cases.
2. The method according to claim 1, characterized in that The recruitment platform includes a job recommendation system and a resume recommendation system, and the multiple background programs include at least one first background data synchronization program of the job recommendation system, at least one second background data synchronization program of the resume recommendation system, and at least one third background data synchronization program; Each first background data synchronization program corresponds to a first test function, each second background data synchronization program corresponds to a second test function, and each third background data synchronization program corresponds to a third test function; the target test function includes at least one of the first test function, the second test function and the third test function; The prerequisite data of a test case includes the test case ID, source database, source data table and data content, and the parameterized data of a test case includes the test case ID, case description, target database, target data table, execution status and expected data.
3. The method according to claim 1, characterized in that The method further comprises: If the batch insert command line parameter is no, then after generating multiple second target test cases, the prerequisite data of the i-th first target test case corresponding to the i-th second target test case is inserted into the database, and the i-th second target test case is executed, and after executing the i-th second target test case, the prerequisite data of the i-th first target test case inserted in the database is deleted, and the process data generated when executing the i-th second target test case is deleted, where i is a positive integer.
4. The method according to claim 1, characterized in that: According to the first identifier, the second identifier, and the third identifier, the target test function in the target test module is filtered out from multiple test modules collected by the pytest test framework, including: According to the first identifier, a target test module corresponding to the first identifier is filtered out from multiple test modules collected by the pytest test framework, and other test modules except the target test module are discarded; According to the second identifier, a target test class corresponding to the second identifier is filtered out from the target test module, and other test classes except the target test class are discarded; According to the third identifier, a target test function corresponding to the third identifier is filtered out from the target test class.
5. The method according to claim 1, characterized in that The method further comprises: When the background program to be tested and / or the first target test case is updated, the test module configuration file, the test class configuration file and the test function configuration file are updated.
6. The method according to claim 1, characterized in that Based on the parameterized data of the multiple first target test cases, multiple second target test cases that can be executed by the pytest test framework are generated, including: Based on the locations of the parameterized data of the multiple first target test cases in the test function configuration file, the parameterized data of the multiple first target test cases are read, and the parameterized data of the multiple first target test cases are transferred to the parameterized decorator of the pytest test framework to generate multiple second target test cases.
7. The method according to claim 1, characterized in that Execute multiple secondary target test cases, including: A plurality of second target test cases are executed simultaneously, and after the plurality of second target test cases are executed, test reports of the plurality of second target test cases are output simultaneously.
8. An automated testing device for a recruitment platform background program, characterized in that: include: A generation module, used to generate a test module configuration file, a test class configuration file and a test function configuration file, wherein the recruitment platform includes multiple background programs, each test module includes at least one test class, each test class includes at least one test function, each test function corresponds to at least one background program and includes at least one test case; The test module configuration file includes a first identifier of a target test module to be executed, the test class configuration file includes a second identifier of a target test class to be executed, and the test function configuration file includes a third identifier of a target test function to be executed, the location of the pre-data of each test case in the target test function, and the location of the parameterized data, the parameterized data includes at least a test case description and an execution status of the test case, and if the execution status of the test case is yes, the test case is the first target test case to be tested; The settings module is used to set the batch insert command line parameters; A screening module, used to read a test module configuration file, a test class configuration file, and a test function configuration file, and screen out a target test function in a target test module from multiple test modules collected by the pytest test framework according to the first identifier, the second identifier, and the third identifier; An execution module is used to read the pre-data of multiple first target test cases for multiple first target test cases whose execution status is yes in the target test function if the batch insert command line parameter is yes, and batch insert the pre-data of multiple first target test cases into the database; based on the parameterized data of the multiple first target test cases, generate multiple second target test cases that can be executed by the pytest test framework, and the multiple second target test cases correspond one-to-one to the multiple first target test cases; execute the multiple second target test cases, and after the multiple second target test cases are executed, batch delete the pre-data inserted in the database and the process data generated when executing the multiple second target test cases.
9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory storing computer program instructions; when the electronic device executes the computer program instructions, the automated testing method for the background program of the recruitment platform as described in any one of claims 1-7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by a processor, implement an automated testing method for a recruitment platform backend program as described in any one of claims 1 to 7.