Software layering test method and system, computer equipment and storage medium

By dividing the PC-side software code into a UI layer and a business layer, and using Python API interfaces and code coverage compilation conditions, the problem of GUI interface changes affecting testing efficiency is solved. This enables automated testing that is unaffected by UI changes, improves testing efficiency and code coverage, and supports left-shift testing and regression testing for product delivery.

CN120803961AInactive Publication Date: 2025-10-17JULIN TECH (SHANGHAI) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511308087.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-15
Publication Date
2025-10-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In existing PC software testing methods, changes in the GUI interface cause test scripts to fail to adapt in a timely manner, reducing the timeliness and efficiency of automated testing. There is an urgent need for a testing method that does not depend on interface changes.

Method used

By dividing the software code into a UI layer and a business layer, connecting them using a Python API interface, and constructing API interface information, automated testing of the business layer is achieved. Code coverage compilation conditions are added to compile the software, generating coverage information versions, test reports, and coverage reports until the target coverage is achieved.

Benefits of technology

It enables functional testing of the business layer to be unaffected by interface changes, improves testing efficiency, supports testing when the interface is not yet determined, optimizes code coverage of test cases, and supports left shift testing and regression testing for product delivery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803961A_ABST
    Figure CN120803961A_ABST
Patent Text Reader

Abstract

The invention provides a software layering testing method and system, computer equipment and a storage medium. The software layering testing method comprises the steps that a software code of to-be-tested software is subjected to business layer and interface layer separation; constructing an API interface for calling connection of the interface layer code and the business layer code; adding a code coverage rate compiling condition into the software code to form a software version with code coverage rate information; using an API interface to output a test script of a service function; running the test script in the software version with the code coverage rate information, and generating a test report and a code coverage rate report; when it is judged that the code coverage rate of the business layer code during testing does not reach the target value, a new test script is generated, and repeated testing is conducted till the code coverage rate reaches the target value. According to the scheme, the software business layer and the interface layer can be separated, so that the function test of the business layer does not depend on the interface, the test deployment is not influenced by the interface change, and the test efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of software testing, in particular to a software layered testing method, system, computer device and storage medium. BACKGROUND

[0002] With the development of science and technology and the Internet, software testing technology has also changed, especially the development of Internet business, which has given birth to many software testing methods and technologies in the field (such as Web, terminal). With the development of Web and terminal devices, software testing actively seeks more efficient and lower-cost testing methods in traditional manual testing, which promotes the launch of various automated testing tools, among which the more common ones belong to Web testing tools, such as GUI testing tools, interface testing frameworks, etc.

[0003] PC software will have different testing tools and methods corresponding to different development frameworks and development languages, which has affected the improvement and innovation of PC software testing methods and technologies to varying degrees. For PC software, in addition to traditional manual testing, the current main method is still to perform automated testing verification from the GUI interface. Due to the uncertain factors of GUI interface changes during development, the generated test scripts often cannot be adapted to the latest interface in time, resulting in the phenomenon that the test scripts cannot be used, which reduces the timeliness and testing efficiency of automated testing. Therefore, there is an urgent need for a software testing method that can make the testing of software business layer functions independent of the interface and the testing deployment not affected by the interface changes. SUMMARY

[0004] The purpose of the present application is to provide a software layered testing method, system, computer device and storage medium, which realizes the separation of software business layer and interface layer, uses API interface to realize the automated testing of business layer, makes the function testing of business layer independent of the interface, and the testing deployment not affected by the interface changes, which is beneficial to improve the testing efficiency, and at the same time realizes the verification of business functions under the condition that the interface is not completely determined or exists changes, realizes the left shift of product delivery testing.

[0005] The technical solution provided by the present application is as follows: In a first aspect, the present application provides a software layered testing method, comprising the steps of: record the code functions related to interface operation in the software code of the software to be tested as interface layer code, and encapsulate and record the code functions called by the interface layer code in the software code as business layer code; build an API interface for the calling connection of the interface layer code and the business layer code, and configure the interface information of the API interface; adding a code coverage compilation condition in the software code, compiling the software, and forming a software version with code coverage information; According to the interface information of the API interface, using the API interface, a test script of a business function corresponding to the business layer code is outputted. Running the test script in the software version with code coverage information, generating a test report and a code coverage report; When it is determined according to the code coverage report that the code coverage of the business layer code in the test does not reach a target value, a new test script is written according to the corresponding uncovered code in the code coverage report and repeated testing is performed until the code coverage reaches the target value.

[0006] In some embodiments, when the test script is run in the software version with code coverage information, the code involved in each operation step in the current test process is marked by a plug-in parameter added in advance during software compilation; Determining the covered code and the uncovered code of the business layer code in the current test process, and generating the code coverage report.

[0007] In some embodiments, the software layered testing method provided in the present application further comprises: Analyzing the coverage condition of the uncovered code, and generating a new test script according to the business function, path and business scenario corresponding to the uncovered code to perform corresponding testing of the uncovered code.

[0008] In some embodiments, the software layered testing method provided in the present application further comprises: Determining the code coverage according to the proportion of the covered code in the business layer code.

[0009] In some embodiments, adding a code coverage compilation condition in the software code comprises: Obtaining an engineering file in the software code that needs to be covered for coverage statistics, and adding the plug-in parameter for recording code execution coverage in the engineering file.

[0010] In some embodiments, the code function called by the interface layer code in the software code is encapsulated by Python, and a Python API interface is constructed.

[0011] In some embodiments, the interface information includes an interface name, an interface input parameter and an interface return value.

[0012] In a second aspect, the present application provides a software layered testing system, which uses the software layered testing method of the first aspect to test the software to be tested.

[0013] In a third aspect, the present application provides a computer device comprising a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the software layered testing method according to the first aspect.

[0014] In a fourth aspect, the present application provides a computer storage medium having a computer program or instructions stored thereon, wherein the computer program or instructions, when executed by a processor, implement the steps of the software layered testing method according to the first aspect.

[0015] The software layered testing method, system, computer device and storage medium provided by the present application have at least the following technical effects: (1) The present application encapsulates the code functions called by the interface layer code in the software code by Python, which can separate the business layer and the interface layer of the software, and can realize the automatic testing of the business layer using the API interface, so that the function testing of the business layer is not dependent on the interface, and the testing deployment is not affected by the interface changes, which is beneficial to improve the testing efficiency; (2) The present application can verify the business function in the case that the interface is not completely determined or is changed, which is beneficial to realize the left shift of product delivery testing; (3) The present application adds the code coverage rate compilation condition in the software code, compiles the software, forms the software version with the code coverage rate information, and can realize the code coverage rate collection during the script testing, which is beneficial to evaluate the effectiveness of the testing and the code coverage rate of the test cases, and points out the direction for the optimization of the test cases; (4) The test script constructed by the present application can directly perform the subsequent software testing, which is beneficial to the regression testing of the software version. BRIEF DESCRIPTION OF DRAWINGS

[0016] The above-mentioned features, technical characteristics, advantages and implementation modes of the present application will be further described in the following preferred embodiments in a clear and understandable manner combined with the accompanying drawings.

[0017] Figure 1 is the overall flowchart of an embodiment of the present application; Figure 2 is the flowchart of an embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, specific implementations of the present application will be described below with reference to the drawings. Obviously, the drawings in the following description only represent some embodiments of the present application, and for those skilled in the art, other drawings can be obtained from these drawings without creative effort, and other embodiments can also be obtained.

[0019] For the sake of simplicity of the drawings, only parts related to the present application are shown in each drawing, which do not represent the actual structure of the product. In addition, in order to make the drawings simple and easy to understand, in some drawings, only one of the components with the same structure or function is shown schematically, or only one of them is marked. In this document, "one" not only means "only one", but also means "more than one" situation.

[0020] In software testing, such as software function testing of EDA simulation software, with the development of science and technology and the Internet, software testing technology has also changed, especially the development of Internet business, which has given birth to many software testing methods and technologies in the field of software testing (such as Web, terminal). With the development of Web and terminal devices, software testing in traditional manual testing is actively seeking more efficient and lower-cost testing methods, which has prompted the introduction of various types of automated testing tools, among which the commonly used Web testing tools include GUI testing tools, interface testing frameworks, etc.

[0021] PC software will have different testing tools and methods corresponding to different development frameworks and development languages, which has affected the improvement and innovation of PC software testing methods and technologies to varying degrees. For PC software, in addition to traditional manual testing, the current main method is still to perform automatic testing and verification from the GUI interface. However, due to the uncertain factors of GUI interface changes during development, the generated test scripts often cannot be adapted to the latest interface in time, resulting in the phenomenon that the test scripts cannot be used, which reduces the timeliness and test efficiency of automatic testing. Therefore, there is an urgent need for a software testing method that can make the testing of software business layer functions independent of the interface and the deployment of the testing not affected by the interface changes.

[0022] Considering that the software code of the software to be tested contains interface-related code and function business-related code, and when the GUI interface is used for automated testing, the interface code is used to call the business code. In the software architecture design and development, the functions called by the interface in the business function code are encapsulated by Python, so that when the business function function needs to be called through the interface, the code logic of the business layer can be executed by calling the Python interface to realize the business operation. That is, the software code is divided into interface code and business code by the Python API interface as an intermediate connection, and the interface code and the business code are connected by the Python API interface, so that the operation and testing of the business function of the business layer are no longer dependent on the interface, and the testing deployment is no longer affected by the interface change, thereby improving the testing efficiency. The present scheme will be described in detail below with reference to the accompanying drawings: In one embodiment, with reference to the description and Figure 1 and the accompanying Figure 2 drawings, the present application provides a software layered testing method, comprising the steps of: S100, the code functions related to the interface operation in the software code of the software to be tested are recorded as interface layer code, and the code functions called by the interface layer code in the software code are encapsulated and recorded as business layer code.

[0023] The present scheme first determines the code functions related to the interface operation in the software code of the software to be tested, and then determines the code functions called by the interface layer code in the software code. The code functions called by the interface layer code are the business code that can actually execute the business function. In order to realize the distinction of the business code, the present scheme records the code functions related to the interface operation in the software code of the software to be tested as the interface layer code, and encapsulates the code functions called by the interface layer code in the software code by using Python and other programming languages, and records them as the business layer code, so as to realize the separation of the interface code and the business code in the software code. In addition, since the present application is used for testing the software code, the verification of the business function can still be performed when the interface is not completely determined or is changed, instead of being performed after the testing interface is determined, which is beneficial to realize the left shift of product delivery testing.

[0024] S200, an API interface is constructed for the calling connection of the interface layer code and the business layer code, and the interface information of the API interface is configured.

[0025] After the separation of interface code and business code in the software code, in order to remove the influence of the runtime interface of the business layer code, an API interface can be built for the calling connection of the interface layer code and the business layer code, so that when the business function function needs to be called through the interface, the code logic of the business layer can be executed by only calling the API interface, and the business operation is realized. The application does not limit the specific form of the API interface, for example, in a specific example, when the code function called by the interface layer code in the software code is encapsulated using the Python language, a corresponding Python API interface is built. At the same time, the interface information of the API interface is configured, the interface information can be stored and displayed in the form of a document, and the interface information includes the interface name, interface input parameter and interface return value and other parameters of the API interface. By configuring the interface information, the API interface corresponding to the business layer code can be built, so that the calling and execution of the business layer code through the API interface are realized.

[0026] S300, adding a code coverage compilation condition in the software code, performing software compilation, and forming a software version with code coverage information.

[0027] The scheme adopts a QT framework, and C++ is used as the programming language of the software. Code coverage is collected through tools such as gcov / lcov. Before software compilation, a code coverage compilation condition is added in the software code, including: obtaining an engineering file in the software code that needs to be subjected to coverage statistics, and adding a patching parameter for recording code execution coverage in the engineering file. The application does not limit the specific form of the patching parameter, for example, in a specific implementation mode, the patching parameter is: -fprofile -arcs -ftest -coverage. Thus, after compilation, a software program with coverage information can be generated. By running the software program with coverage information and performing various operations, the coverage execution of the code segment that is run can be recorded, so as to determine which code is run and which code is not run when the software code is run.

[0028] S400, according to the interface information of the API interface, using the API interface, outputting a test script of a business function corresponding to the business layer code.

[0029] The present scheme designs corresponding test scripts through the description document of the API interface, combined with the use scene of the actual business function. For example, a simulation schematic diagram is imported in the EDA software, or the simulation schematic diagram is directly built through the API interface, and a test script is generated, and the simulation operation is executed through the test script. Meanwhile, corresponding detection points can be added to determine whether the test script running result meets the expectation. The present application does not limit the specific form of the test script, and does not limit the specific way of generating the test script. The actual demand and the on-site tool can be selected, as long as the calling of the business layer code can be realized.

[0030] S500, running the test script in the software version with the code coverage information, generating a test report and a code coverage report.

[0031] The present application runs the test script in the software version with the code coverage information, and generates two report files of the test report and the code coverage report. The test report after the running of the test script can be checked to check whether the function running is normal, the script of the test failure is analyzed, and the problem tracking is performed. The test report contains the result of all script running this time. The test script of the API interface covers the verification of the function scene, and the detection points in the script are used to determine whether the function and the business logic are normal. If the test result of the script is determined as failure, the script can be further analyzed, for example, the function is abnormal, and the problem needs to be reported and tracked. After the problem is repaired, the script can be run again for regression testing.

[0032] When the test script is run in the software version with the code coverage information, the code coverage of each operation step involved in the current test process is marked through the plug-in parameter added in advance when the software is compiled, so that the covered code and the uncovered code of the business layer code in the current test process can be determined, and then the code coverage report is generated. When multiple test scripts are used to perform testing and multiple covered codes are determined, the covered codes may overlap. Other tools, such as the Gcov / lcov tool conversion collection command, can be used to integrate the generated coverage data files, and output the final code coverage test report. The report can show the code coverage after the script is executed, such as the covered and uncovered proportion of the code text line and the function.

[0033] When the code coverage in the test is calculated, the code coverage can be determined according to the proportion of the covered code in the business layer code.

[0034] S600, when it is determined according to the code coverage report that the code coverage of the business layer code in the test does not reach a target value, a new test script is written according to the uncovered code in the code coverage report, and repeated testing is performed until the code coverage reaches the target value.

[0035] After running the test script, obtaining the test report and the code coverage report, the code coverage report can be viewed by manual means or the like to determine the code coverage and determine whether the code coverage of the business layer code during testing reaches the target value, which can also be referred to as an expected value, an intended value, which can be adjusted according to the use requirements, for example, set to 90% or 80% or the like, which is not limited by the present application. If the code coverage of the business layer code during testing does not reach the target value, new test scripts can be written according to the uncovered code recorded in the code coverage report and repeated testing is performed until the code coverage reaches the target value. Specifically, when generating new test scripts, the coverage conditions of the uncovered code can be analyzed, and new test scripts can be generated according to the business functions, paths and business scenarios corresponding to the uncovered code to perform corresponding testing of the uncovered code. In the process of dividing the software code into business layer code and interface layer code and performing automatic testing of the business layer, the present application introduces code coverage judgment, which not only accurately understands the code participation during testing, but also specifically writes new test scripts for uncovered code, thereby improving testing efficiency and optimizing the testing process.

[0036] The software layered testing method provided by the present application has at least the following technical effects: (1) The present application encapsulates the code functions called by the interface layer code in the software code by Python, which can separate the business layer and the interface layer of the software, and can realize automatic testing of the business layer using the API interface, so that the function testing of the business layer is not dependent on the interface, and the testing deployment is not affected by the interface changes, which is beneficial to improve the testing efficiency; (2) The present application can verify the business functions in the case where the interface is not completely determined or is changed, which is beneficial to realize the left shift of product delivery testing; (3) The present application adds code coverage compilation conditions in the software code and compiles the software to form a software version with code coverage information, which can realize code coverage collection during script testing, and is beneficial to evaluate the effectiveness of the testing and the code coverage of the test cases, and points out the direction for optimization of the test cases; (4) The test script constructed by the present application can directly perform subsequent software testing, which is beneficial to regression testing of the software version.

[0037] In one embodiment, on the basis of the foregoing embodiment, the present application provides a software layered testing system which adopts the software layered testing method of the foregoing embodiment to test the software to be tested.

[0038] In one embodiment, based on the foregoing embodiment, the present application provides a computer device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the software layering test method of the foregoing embodiment.

[0039] In one embodiment, based on the foregoing embodiment, the present application provides a computer storage medium having stored thereon a computer program or instructions, which, when executed by a processor, implement the steps of the software layering test method of the foregoing embodiment.

[0040] In one embodiment, based on the foregoing embodiment, the present application provides a computer program product comprising a computer program or instructions, which, when executed by a processor, implement the steps of the software layering test method of the foregoing embodiment.

[0041] The software layering test method of the present application can be implemented by program codes executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or a plurality of modules or steps thereof can be made into a single integrated circuit module. Thus, the present application is not limited to any particular combination of hardware and software.

[0042] It should be noted that the above embodiments can be freely combined as needed. The above description is merely preferred embodiments of the present application, and it should be noted that those of ordinary skill in the art can make several improvements and refinements without departing from the principles of the present application, and these improvements and refinements should also be considered within the scope of the present application.

Claims

1. A software layered testing method, characterized in that: Including steps: Record the code functions related to the interface operation in the software code of the software to be tested as interface layer code, and encapsulate the code functions in the software code that are called by the interface layer code and record them as business layer code; Constructing an API interface for calling and connecting the interface layer code and the business layer code, and configuring the interface information of the API interface; Adding a code coverage compilation condition to the software code, compiling the software, and forming a software version with code coverage information; Outputting a test script for the business function corresponding to the business layer code using the API interface according to the interface information of the API interface; Running the test script in the software version having code coverage information to generate a test report and a code coverage report; When it is determined according to the code coverage report that the code coverage of the business layer code during testing does not reach the target value, a new test script is written according to the corresponding uncovered code in the code coverage report and repeated testing is performed until the code coverage reaches the target value.

2. The software layered testing method according to claim 1, characterized in that: When running the test script in the software version with code coverage information, marking the code involved in each operation step in the current test process by using the instrumentation parameters pre-added during software compilation; Determine the covered code and uncovered code of the business layer code during the current test process, and generate the code coverage report.

3. The software layered testing method according to claim 2, characterized in that: Also includes: The coverage conditions of the uncovered code are analyzed, and a new test script is generated according to the business functions, paths, and business scenarios corresponding to the uncovered code to perform corresponding tests on the uncovered code.

4. The software layered testing method according to claim 2, wherein: Also includes: The code coverage is determined according to the proportion of the covered code in the business layer code.

5. The software layered testing method according to claim 2, wherein: Add code coverage compilation conditions to the software code, including: A project file for which coverage statistics need to be performed in the software code is obtained, and the instrumentation parameters for recording code execution coverage are added to the project file.

6. The software layered testing method according to claim 1, wherein: The code functions in the software code that are called by the interface layer code are encapsulated through Python, and a Python API interface is constructed.

7. The software layered testing method according to claim 1, wherein: The interface information includes the interface name, interface input parameters and interface return value.

8. A software layered testing system, characterized in that: The software to be tested is tested using the software layered testing method described in any one of claims 1 to 7.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory, wherein: The processor executes the computer program to implement the steps of the software layered testing method according to any one of claims 1 to 7.

10. A computer storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the software layered testing method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Software development method and system

    CN107145350A

  • Automatic test method and device for user interface, electronic equipment and storage medium

    CN113778898A

  • Layered testing method, layered testing device, electronic equipment and storage medium

    CN116302932A

  • Method for analyzing front-end page coverage rate based on code instrumentation

    CN119441052A

  • Test method and operation system, continuous integration platform, equipment, medium, program product and vehicle

    CN119961165A