An automated testing method, device, and computer-readable medium

By building a test case set in EXCEL format and using the test script batch generation tool to generate general test case scripts, the problems of inconvenient modification and high maintenance costs of the automated test framework in the existing technology are solved, and an efficient and reusable automated testing method is realized.

CN114138665BActive Publication Date: 2025-05-27INSPUR QILU SOFTWARE IND
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111499907.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-05-27
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

The existing database automation testing framework and methods have problems such as inconvenient use case modification, high post-maintenance cost, unselectable execution mode, poor generality, inability to support multiple databases, and inability to execute multi-threaded.

Method used

Provides an automated testing method, by building a test case set in EXCEL format, using the test script batch generation tool to generate general test case scripts, and customize them on it, supporting multiple databases and multi-threaded execution.

Benefits of technology

Shorten the test cycle, improve test reusability, increase software trust, simplify the use case writing process, and reduce post-maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138665B_ABST
    Figure CN114138665B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of automated testing technology, and specifically provides an automated testing method, which is characterized in that a test case set is constructed, the test cases in EXCEL format include two sheet pages, and then a test case execution script is carried out, including the part of the test cases filled in EXCEL and the script part that reads the SQL in the EXCEL cases and executes it. Compared with the prior art, the present invention shortens the test cycle, improves the test reusability, increases the software trust, and the simple way of writing test cases frees the testing technicians and enables them to invest more energy in designing better test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of automated testing, and specifically provides an automated testing method, device, and computer-readable medium. Background Art

[0002] Automated testing can improve work efficiency, testing accuracy, and increase software trust. With the development and progress of the software testing industry, automated testing has become inevitable. However, current automated testing frameworks and methods for databases generally have the following disadvantages:

[0003] First, writing automated test use cases in a pure script manner has high requirements for testers' skills, is inconvenient to modify use cases, has high later maintenance costs, and the test results are not intuitive. There are also problems such as the execution mode being non-selectable, poor generality, inability to support multiple databases, and inability to execute multi-threadedly. Summary of the Invention

[0004] The present invention aims at the above-mentioned deficiencies of the prior art and provides a highly practical automated testing method.

[0005] A further technical task of the present invention is to provide a reasonably designed, safe and applicable automated testing device.

[0006] A further technical task of the present invention is to provide a computer-readable medium.

[0007] The technical solution adopted by the present invention to solve its technical problems is:

[0008] An automated testing method constructs a test case set, an EXCEL format test case including two sheet pages, and then performs a test case execution script, including the test case part filled in EXCEL and the script part for reading and executing SQL in the EXCEL use case.

[0009] Furthermore, the test case script part is divided into two categories: general and non-general.

[0010] The general test case script is batch-generated by a test script batch generation tool. In the generated general test case script, one function corresponds to one use case in EXCEL. The usage of the test script batch generation tool is as follows:

[0011] . / gen_case.sh -a N -f testfile, where N is the number of added use cases, corresponding to the number of use cases in Excel, and testfile is the name of the test script.

[0012] Further, the non - general test case script is modified based on the general script generated by the script generation tool to achieve custom modification of any one or more steps and expected values in the use cases in EXCEL, and add some operations such as switching users and obtaining data.

[0013] Further, in the case where the SQL commands in the test contain unfixed values, modify the function corresponding to the test case generated by the test case script generation tool. First, obtain the variable of the unfixed value, and then pass the dictionary - type variable with the test steps and SQL commands into the test case execution interface. During the execution of the test case, the test steps in EXCEL will be automatically replaced according to the passed - in dictionary - type variable.

[0014] Further, for the case where the test expected result is not a fixed value, in addition to representing the expected result in the EXCEL use case with a regular expression, modify the function corresponding to the test case generated by the test case script generation tool;

[0015] First, obtain the variable of the unfixed value, and then pass the dictionary - type variable with the test steps and the calculated expected result into the test case execution interface. During the execution of the test case, the expected value in EXCEL will be automatically replaced according to the passed - in dictionary - type variable.

[0016] Further, in the case where the test steps contain the situation of interrupting the current SQL and then continuing to execute, fill in the keywords of switching users or obtaining data in the steps that need to be interrupted in EXCEl, and modify the general test script function corresponding to the test case;

[0017] First, execute the call to the test case execution interface. When encountering the keywords of switching users or obtaining data, it will automatically interrupt the execution of the SQL in EXCEL, then add the processing such as switching users or obtaining data, continue to call the test case execution interface and pass in the step number of the interrupted step, and the test will continue to execute from the interrupted place.

[0018] Further, call the encapsulated excel reading interface to read the test cases, execute the test cases, compare the execution results with the expected results in the excel according to the matching method, and finally generate a test report.

[0019] An automated test device includes: at least one memory and at least one processor;

[0020] The at least one memory is used to store machine - readable programs;

[0021] The at least one processor is used to call the machine - readable program to execute an automated test method.

[0022] A computer-readable medium stores computer instructions thereon. When the computer instructions are executed by a processor, the processor is caused to execute an automated testing method.

[0023] Compared with the prior art, an automated testing method, apparatus, and computer-readable medium of the present invention have the following prominent beneficial effects:

[0024] The present invention shortens the testing cycle, improves the test reusability, increases the software trust level, and the simple test case writing method liberates test technicians, enabling them to invest more energy in designing better test cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0026] Attached Figure 1 is a flowchart of an automated testing method;

[0027] Attached Figure 2 is a schematic diagram of the interface of the first sheet page in an automated testing method;

[0028] Attached Figure 3 is a schematic diagram of the interface of the second sheet page in an automated testing method. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0029] In order to enable those skilled in the art to better understand the solution of the present invention, the following further detailed description of the present invention is provided in conjunction with specific embodiments. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.

[0030] The following gives a preferred embodiment:

[0031] As Figures 1 - 3 shown, in an automated testing method of this embodiment, a test case set is constructed. The test cases in EXCEL format include two sheet pages. The first sheet page includes test case number, test case description, steps, expected result, expected value, matching method (supporting containment matching, regular expression matching, equality matching), remarks, first-level module, second-level module,

[0032] Third-level module, fourth-level module, priority, use case type, precondition, maintainer, requirement identifier, corresponding version.

[0033] The second sheet includes name, description, steps, expected result, expected value, and matching method (supporting containment matching, regular expression matching, and equality matching).

[0034] The content in setUpClass is for pre-test preparation work and is executed only once before the entire test process;

[0035] The content in tearDownClass is for post-test cleanup work and is executed only once after the entire test process ends;

[0036] The content in setUp is for pre-test preparation and is executed once before each use case;

[0037] The content in tearDown is for post-test cleanup work and is executed once after each test case;

[0038] During the writing of test cases, the content in the second sheet can be selectively filled in according to the actual situation.

[0039] The expected result in EXCEL can be generated from the expected value and copied to EXCEL; the database expected value generation tool connects to the database by calling the database connection interface, reads the sql input by the use case, and returns the execution result to the terminal.

[0040] Then, execute the test case execution script, including the part of the test case filled in EXCEL and the part of the script that reads and executes the SQL in the EXCEL use case. The test case script part is divided into two categories: general (cases that strictly read and execute the use case SQL in EXCEL without other special operations) and non-general. The general test case script can be batch-generated by the test script batch generation tool, and one function in the generated general test case script corresponds to one use case in EXCEL;

[0041] The usage of the test script batch generation tool is as follows:

[0042] . / gen_case.sh -a N -f testfile

[0043] N is the number of added use cases, corresponding to the number of use cases in Excel, and testfile is the name of the test script.

[0044] The non-general test case script can be modified based on the general script generated by the script generation tool to achieve custom modification of any one or more steps and expected values of the use case in EXCEL, and add some complex operations such as switching users and obtaining data:

[0045] (1) For the case where the SQL commands in the test steps contain unfixed values (such as the temporary table name being random), the function corresponding to the test case generated by the test case script generation tool can be modified. First, obtain the variable of the unfixed value, and then pass the dictionary-type variable with the test steps and SQL commands into the test case execution interface. During the execution of the test case, the test steps in the EXCEL will be automatically replaced according to the passed dictionary-type variable.

[0046] (2) For the case where the test expected result is not a fixed value (such as the return value of the function to query the system time), in addition to representing the expected result with a regular expression in the EXCEL test case, the function corresponding to the test case generated by the test case script generation tool can be modified. First, obtain the variable of the unfixed value, and then pass the dictionary-type variable with the test steps and the calculated expected result into the test case execution interface. During the execution of the test case, the expected value in the EXCEL will be automatically replaced according to the passed dictionary-type variable.

[0047] (3) For the case where the test steps contain operations that need to interrupt the current SQL (such as switching users, obtaining test data, etc.) and then continue to execute, in the steps that need to be interrupted in the EXCEl, fill in the keywords: 'Switch user' or 'Get data'. Modify the general test script function corresponding to the test case. First, execute and call the test case execution interface. When encountering keywords such as 'Switch user' or 'Get data', the script will automatically interrupt the execution of the SQL in the EXCEL, then add processing such as switching users or obtaining data, and then continue to call the test case execution interface and pass in the step number of the interrupted step. The test will continue to execute from the interruption point.

[0048] The process of executing the test script is as follows: call the encapsulated excel reading interface to read the test cases; execute the test cases; compare the execution results with the expected results in the excel according to the matching method and finally generate a test report.

[0049] It is implemented based on the django MVC model. Use django-admin startproject to create a project and python manage.py startapp to create an application. Place the templates (login page, test configuration page, and operation result page) in the template folder. Edit models.py to establish a database model. Use the built-in sqlite database in django to mainly store the test case set and the test case number and name. Edit views.py and import the model established in models.py. Edit admin.py to register the database model into the admin interface and process data in the admin interface. Edit views.py to design relevant modules for processing data. Edit urls.py to establish a connection with views.py to form a graphical interface.

[0050] For the interfaces related to test case processing, there are interfaces for reading EXCEL test cases, case execution, and result checking. For general interfaces, use the ssh connection interface to the database server, the data sending interface to the database server, or the command execution interface to the database server. Use the smtp email sending interface.

[0051] It is implemented by calling the BeautifulReport.report() interface of the python BeautifulReport module. The script outputs the test case number, test case description, and execution steps in the excel to the standard output to be displayed in the test report.

[0052] It is implemented through the python unittest module. unittest.TestLoader().loadTestsFromTestCase() is used to load each test case set. The all_suite list stores all test case sets. The unittest.TestSuite() interface is passed different all_suite values to execute all test case sets and specified test case sets. The unittest.TestSuite().addTests() interface is passed different parameters to execute a single test case in the specified test case set.

[0053] The test report email sending is implemented through the smtplib protocol and uses the smtplib and email modules in python.

[0054] The above specific embodiments are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above specific embodiments. Any appropriate changes or substitutions made by any person of ordinary skill in the art that comply with the claims of an automated testing method, device, and computer-readable medium of the present invention shall fall within the patent protection scope of the present invention.

[0055] Although the embodiments of the present invention have been shown and described, it will be understood by those of ordinary skill in the art that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. An automated testing method, characterized in that, a test case set is constructed, and the test cases in EXCEL format include two sheet pages, and then a test case execution script is carried out, including the part of the test cases filled in EXCEL and the script part for reading the SQL in the EXCEL cases and executing it; the test case script part is divided into two categories: general and non-general; the general test case scripts are batch-generated by a test script batch generation tool. In the generated general test case scripts, one function corresponds to one case in EXCEL. The usage of the test script batch generation tool is as follows: . / gen_case.sh -a N -f testfile, where N is the number of added cases, corresponding to the number of cases in Excel, and testfile is the name of the test script; the non-general test case scripts are modified on the basis of the general scripts generated by the script generation tool to achieve custom modification of any one or more steps and expected values of the cases in EXCEL, and add some operations such as switching users and obtaining data; in the case where the SQL commands in the test contain unfixed values, modify the function corresponding to the test case generated by the test case script generation tool. First, obtain the variable of the unfixed value, and then pass the dictionary-type variable with the test steps and sql commands into the test case execution interface. During the execution of the test case, the test steps in EXCEL will be automatically replaced according to the passed dictionary-type variable; for the case where the test expected result is not a fixed value, in addition to representing the expected result in the EXCEL case with a regular expression, modify the function corresponding to the test case generated by the test case script generation tool; first, obtain the variable of the unfixed value, and then pass the dictionary-type variable with the test steps and the calculated expected result into the test case execution interface. During the execution of the test case, the expected value in EXCEL will be automatically replaced according to the passed dictionary-type variable.

2. The automated testing method according to claim 1, characterized in that, when the test steps include the situation where the current SQL needs to be interrupted and then continue to execute, fill in the keywords of switching users or obtaining data in the steps that need to be interrupted in EXCEl, and modify the general test script function corresponding to the test case; first, execute the call to the test case execution interface. When encountering the keywords of switching users or obtaining data, the execution of the SQL in EXCEL will be automatically interrupted, and then add processing such as switching users or obtaining data, continue to call the test case execution interface and pass in the step number of the interrupted step, and the test will continue to execute from the interruption point.

3. The automated testing method according to claim 2, characterized in that, call the encapsulated excel reading interface to read the test cases, execute the test cases, compare the execution results with the expected results in excel according to the matching method, and finally generate a test report.

4. An automated testing device, characterized in that, comprises: at least one memory and at least one processor; the at least one memory is used for storing machine-readable programs; The at least one processor is configured to call the machine-readable program to execute the method according to any one of claims 1 to 3.

5. A computer-readable medium, wherein, computer instructions are stored on the computer-readable medium, and when the computer instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Automatic interface testing method based on python

    CN110297774A

  • Application test case generation method and device and software test system

    CN110659197A