Geometric modeling engine test method and device, electronic equipment and storage medium
By registering command class instances in the test system and using test scripts to parse parameters, the problem of difficult and cost of geometric modeling engine testing is solved, and efficient cross-language testing is achieved.
Patent Information
- Application Number
- CN202510220009.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2045-02-26
AI Technical Summary
During the testing process of geometric modeling engine, there are problems such as high testing difficulty and high testing cost.
Testing the geometry modeling engine is realized by registering a command class instance in the test system, executing the test case using a test script based on the first programming language, and obtaining the test parameters of the second programming language through parameter sequence analysis.
实现了跨编程语言的灵活且高效的参数数据处理,减少了程序开发和维护工作量,提高了测试效率。
Smart Images

Figure CN120295904A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and particularly to a test method for a geometric modeling engine, a test device for a geometric modeling engine, an electronic device, and a computer-readable storage medium. Background Art
[0002] A geometric modeling engine is a software tool or library for creating, operating, and analyzing geometric models, which is widely used in fields such as computer-aided design, computer graphics, simulation, 3D printing, and game development. The core functions of a geometric modeling engine include the creation, editing, Boolean operations (such as union, difference, intersection), deformation, rendering, etc. Among them, during the process of testing a geometric modeling engine, due to the existence of a large number of parameter forms of C++ structures or classes in the geometric modeling engine, it is likely to bring greater difficulty and testing cost to users' testing. Summary of the Invention
[0003] Embodiments of the present invention provide a test method, device, electronic device, and computer-readable storage medium for a geometric modeling engine to solve or partially solve the problems of high testing difficulty and large testing cost during the process of testing a geometric modeling engine.
[0004] Embodiments of the present invention disclose a test method for a geometric modeling engine, which relates to a test system and a geometric modeling engine. The test system runs a test script, and the test script is a script program configured based on a first programming language. The method includes:
[0005] Registering a command class instance for testing the geometric modeling engine in the test system, where a number of function interfaces are provided in the command class instance;
[0006] Determining a test case for the geometric modeling engine, executing the test case through the test script, determining a test command corresponding to the test case and a parameter sequence corresponding to each test command, and the parameter type of the parameter sequence is the first programming language;
[0007] Extracting a target command class instance matching the test command from the registered command class instances according to the parameter sequence;
[0008] Parsing the parameter sequence according to the function interface of the target command class instance to obtain test parameters with a parameter type of a second programming language, and testing the geometric modeling engine according to the test parameters to obtain a test result corresponding to the test case.
[0009] In some feasible embodiments, it further includes:
[0010] In response to all test cases being tested, all command class instances in the test system are deactivated.
[0011] In some feasible embodiments, the parameter sequence at least includes a command identifier, and extracting a target command class instance matching the test command from the registered command class instances according to the parameter sequence includes:
[0012] Extracting a target command class instance matching the command identifier from the registered command class instances.
[0013] In some feasible embodiments, the test system at least includes a model library, and the model library at least includes all model object instances generated during the test run of the geometric modeling engine and the model identifiers corresponding to each of the model object instances. The method further includes:
[0014] If there is a model identifier in the parameter sequence for representing a model object instance, extracting a target model object instance matching the model identifier from the model library.
[0015] In some feasible embodiments, testing the geometric modeling engine according to the test parameters to obtain the test result corresponding to the test case includes:
[0016] Testing the geometric modeling engine according to the test parameters and the target model object instance to obtain the test result corresponding to the test case.
[0017] In some feasible embodiments, the command class instance includes a parameter parsing function interface, the first programming language is the Python language, the second programming language is the C++ language, and parsing the parameter sequence according to the function interface of the target command class instance to obtain test parameters of the second programming language type includes:
[0018] Passing the parameter sequence of the Python language type into the parameter parsing function interface for parameter type conversion to obtain test parameters of the C++ language type.
[0019] In some feasible embodiments, the command class instance further includes an execution function interface, the test parameters at least include first geometric modeling parameters, and testing the geometric modeling engine according to the test parameters to obtain the test result corresponding to the test case includes:
[0020] Through the execution function interface, the first geometric modeling parameter is passed to the geometric modeling engine. In response to the geometric modeling engine executing a first geometric modeling operation corresponding to the first geometric modeling parameter, a test result corresponding to the test case is obtained according to the first geometric modeling operation.
[0021] In some feasible embodiments, the test parameter at least includes a first geometric modeling parameter. Testing the geometric modeling engine according to the test parameter and the target model object instance to obtain a test result corresponding to the test case includes:
[0022] Obtain a second geometric modeling parameter corresponding to the target model object instance;
[0023] Pass the first geometric modeling parameter and the second geometric modeling parameter to the geometric modeling engine. In response to the geometric modeling engine executing a second geometric modeling operation corresponding to the first geometric modeling parameter and the second geometric modeling parameter, a test result corresponding to the test case is obtained according to the second geometric modeling operation.
[0024] In some feasible embodiments, the command class instance further includes a clearing function interface, and the method further includes:
[0025] In response to the completion of the test of the geometric modeling engine, clear the test parameter through the clearing function interface.
[0026] An embodiment of the present invention also discloses a test device for a geometric modeling engine, which relates to a test system and a geometric modeling engine. The test system runs a test script, and the test script is a script program configured based on a first programming language. The device includes:
[0027] A registration module for registering a command class instance for testing the geometric modeling engine in the test system. A plurality of function interfaces are provided in the command class instance;
[0028] A test case determination module for determining a test case for the geometric modeling engine, executing the test case through the test script, determining a test command corresponding to the test case and a parameter sequence corresponding to each test command, and the parameter type of the parameter sequence is the first programming language;
[0029] A command class instance extraction module for extracting a target command class instance matching the test command from the registered command class instances according to the parameter sequence;
[0030] A test module for parsing the parameter sequence according to the function interface of the target command class instance, obtaining test parameters with the parameter type of the second programming language, and testing the geometric modeling engine according to the test parameters to obtain the test result corresponding to the test case.
[0031] In some feasible embodiments, it further includes:
[0032] A logout module for logging out all command class instances in the test system in response to all test cases being tested.
[0033] In some feasible embodiments, the parameter sequence at least includes a command identifier, and the command class instance extraction module is specifically used for:
[0034] Extracting a target command class instance that matches the command identifier from the registered command class instances.
[0035] In some feasible embodiments, the test system at least includes a model library, and the model library at least includes all model object instances generated during the test run of the geometric modeling engine and the model identifiers corresponding to each model object instance. The device further includes:
[0036] A model object extraction module for extracting a target model object instance that matches the model identifier from the model library if there is a model identifier representing a model object instance in the parameter sequence.
[0037] In some feasible embodiments, the test module is specifically used for:
[0038] Testing the geometric modeling engine according to the test parameters and the target model object instance to obtain the test result corresponding to the test case.
[0039] In some feasible embodiments, the command class instance includes a parameter parsing function interface, the first programming language is Python, and the second programming language is C++. The test module is specifically used for:
[0040] Passing the parameter sequence of Python language type into the parameter parsing function interface for parameter type conversion to obtain test parameters with the parameter type of C++.
[0041] In some feasible embodiments, the command class instance further includes an execution function interface, and the test parameters at least include first geometric modeling parameters. The test module is specifically used for:
[0042] Pass the first geometric modeling parameter to the geometric modeling engine through the execution function interface, and in response to the geometric modeling engine executing a first geometric modeling operation corresponding to the first geometric modeling parameter, obtain a test result corresponding to the test case according to the first geometric modeling operation.
[0043] In some feasible embodiments, the test parameter at least includes a first geometric modeling parameter, and the test module is specifically configured to:
[0044] Obtain a second geometric modeling parameter corresponding to the target model object instance;
[0045] Pass the first geometric modeling parameter and the second geometric modeling parameter to the geometric modeling engine, and in response to the geometric modeling engine executing a second geometric modeling operation corresponding to the first geometric modeling parameter and the second geometric modeling parameter, obtain a test result corresponding to the test case according to the second geometric modeling operation.
[0046] In some feasible embodiments, the command class instance further includes a clearing function interface, and the device further includes:
[0047] A clearing module, configured to clear the test parameter through the clearing function interface in response to the geometric modeling engine finishing the test.
[0048] An embodiment of the present invention also discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;
[0049] The memory is used to store a computer program;
[0050] When the processor is used to execute the program stored in the memory, the method described in the embodiment of the present invention is implemented.
[0051] An embodiment of the present invention also discloses a computer-readable storage medium, on which instructions are stored. When executed by one or more processors, the processors are caused to execute the method described in the embodiment of the present invention.
[0052] The embodiments of the present invention have the following advantages:
[0053] In an embodiment of the present invention, a user can test a geometric modeling engine through a test system, run a corresponding test script on the test system, and the test script can be a script program configured based on a first programming language. During the testing process, a command class instance for testing the geometric modeling engine can be registered in the test system first, and several function interfaces are provided in the command class instance; then, the user can set test cases for the geometric modeling engine and execute the test cases through the test script to determine the test commands corresponding to the test cases and the parameter sequences corresponding to each test command, and the parameter type of the parameter sequence is the first programming language; then, based on the parameter sequence, a target command class instance matching the test command is extracted from the registered command class instances, and based on the extracted target command class instance, the parameter sequence can be further parsed according to the function interface of the target command class instance to obtain test parameters with the parameter type of the second programming language, and the geometric modeling engine is tested according to the test parameters to obtain the test results corresponding to the test cases. Therefore, during the testing of the geometric modeling engine, by registering the corresponding command class instances on the test system, the user can process the corresponding test parameters across programming languages at the custom command level, implement the testing of the geometric modeling engine, flexibly and efficiently parse and process different types of parameter data, support the transfer of parameter data of different programming language types, and at the same time facilitate the test program developers to write the corresponding test cases, reducing the workload of program development and maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 is a flowchart of the steps of a method for testing a geometric modeling engine provided in an embodiment of the present invention;
[0055] Figure 2 is a schematic diagram of an application scenario provided in an embodiment of the present invention;
[0056] Figure 3 is a block diagram of the structure of a device for testing a geometric modeling engine provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0057] In order to make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0058] As an example, the Python language has concise syntax, is easy to master, and supports multiple programming paradigms, including procedural, object-oriented, and functional programming. In the application of data classes in the Python language, it is often used as the dominant language for API binding. Through API binding, functions written in another language (such as the C++ language) that are commonly used or required in industrial applications are exposed for use by Python programs to achieve cross-language communication and take advantage of the respective advantages of the two languages.
[0059] However, in a system for testing a geometric modeling engine, in order to test the corresponding geometric modeling engine with multiple parameters and multiple boundary conditions, it is often necessary to add various test command functions and different numbers and types of test parameters that match the test command functions. The parameter data types involved in the test command functions are numerous and the structures are complex. In particular, for the test system platform, in order to better support extensibility and usability, the functions and parameters called by the test commands are often flexibly defined and adjusted according to user needs. For simple parameter types, although the parameter list of Python can be directly converted into the parameter form of C++. However, there are a large number of parameter forms of C++ structures or classes in the geometric modeling engine test, which means that the difficulty and cost for users to maintain custom built-in object types are very high.
[0060] For example, when users adopt the method of customizing a large number of built-in object types, there are the following disadvantages:
[0061] (1) Usually, according to the API names and their parameters written in the C++ language, corresponding Python built-in object types are written with the same or similar names (for example, adding a unified prefix or suffix text for distinction). In the geometric modeling engine test system, the C++ objects generated by the test commands have numerous and complex parameter data types. When writing the corresponding Python custom built-in object types, the programming workload is large.
[0062] (2) The features of C++ polymorphism and function overloading support the flexibility of the C++ object programming method, but the Python language does not have similar concepts. Therefore, when defining Python interface binding, it is also necessary to consider the implementation of multiple forms. According to the rules of Python built-in object types, corresponding Python classes are defined, and it is not easy to maintain the consistency of the command interfaces of the two language environments in the test system in terms of difficulty and workload.
[0063] In this regard, in the present invention, a user can test a geometric modeling engine through a test system, run a corresponding test script on the test system, and the test script can be a script program configured based on a first programming language. During the testing process, a command class instance for testing the geometric modeling engine can be registered in the test system first. A number of function interfaces are provided in the command class instance. Then, the user can set test cases for the geometric modeling engine and execute the test cases through the test script to determine the test commands corresponding to the test cases and the parameter sequences corresponding to the test commands. The parameter type of the parameter sequence is the first programming language. Then, based on the parameter sequence, a target command class instance matching the test command is extracted from the registered command class instances. Based on the extracted target command class instance, the parameter sequence can be further parsed according to the function interfaces of the target command class instance to obtain test parameters with the parameter type of the second programming language, and the geometric modeling engine is tested according to the test parameters to obtain the test results corresponding to the test cases.
[0064] Referring to Figure 1 , a flowchart of steps of a method for testing a geometric modeling engine provided in an embodiment of the present invention is shown, which relates to a test system and a geometric modeling engine. The test system runs a test script, and the test script is a script program configured based on a first programming language. Specifically, it may include the following steps:
[0065] Step 101, register a command class instance for testing the geometric modeling engine in the test system, and a number of function interfaces are provided in the command class instance;
[0066] For the geometric modeling engine, it can be a software library or tool for creating, editing, and analyzing geometric models (such as cuboids, cylinders, spheres, etc.). For example, it can be used for the creation and editing of geometric bodies, Boolean operations (such as union, difference, and intersection, etc.), transformation of geometric bodies (such as translation, rotation, scaling, etc.), and property calculation of geometric bodies (such as volume, surface area, etc.).
[0067] For the test system, it can be a framework or platform for verifying the functions of the geometric modeling engine. For example, it manages test cases and test scripts, calls the interfaces of the geometric modeling engine, and verifies test results and generates reports, etc. The test system provides unified test interfaces and tools to implement an automated test process and improve test efficiency.
[0068] For the test script, it can be a script program written based on a first programming language. For example, a script program written in Python can be used to define test logic and call the functions of the geometric modeling engine, etc., including the definition of test cases, the passing and verification of parameters, and the inspection and reporting of results, etc. The present invention does not limit this.
[0069] It should be noted that the first programming language is Python and the second programming language is C++. During the process of testing the geometric modeling engine, the user can write corresponding test cases (including test command functions and corresponding test parameters, etc.) in Python. During the testing process, the parameters involved in the test cases need to be converted into parameters that can be executed in the C++ language environment. In this regard, in the embodiments of the present invention, by constructing corresponding command class instances and registering the corresponding command class instances on the test system, the user can, at the custom command level, process the corresponding test parameters across programming languages, implement the testing of the geometric modeling engine, flexibly and efficiently parse and process different types of parameter data, support the transfer of parameter data of different programming language types, and at the same time facilitate the test program developers to write corresponding test cases, reducing the workload of program development and maintenance.
[0070] In the embodiments of the present invention, when the user performs a functional test of geometric modeling on the geometric modeling engine through the test system, a command class instance for testing the geometric modeling engine can be registered in the test system first. Among them, the command class instance provides several different function interfaces, and different function interfaces are used to implement different functions during the testing process. For example, they are used to execute test commands, clear test commands, parse parameters, transfer parameters, etc. Therefore, through the command class instance, various different types of parameter data can be flexibly and efficiently parsed and processed to support the transfer of parameter data of different programming languages, reducing the workload of program development and maintenance.
[0071] It should be noted that for the command class instance, the command class instance can be configured by customizing the C++ base class CmdBase of the command class and the implementation logic mechanism, so as to implement the corresponding functions through the command class instance. During the configuration process, all custom command classes are derived therefrom and implemented in the derived classes of the application program module.
[0072] In some feasible implementation manners, the command class instance includes a parameter parsing function interface, an execution function interface, and a clearing function interface. The parameter parsing function interface is used to parse the parameters of the first programming language into the parameters of the second programming language. The execution function interface is used to perform corresponding initialization to execute the test command. The clearing function interface is used to perform corresponding clearing work after the test command is executed, etc. Therefore, by defining corresponding function interfaces in the command class instance, various different types of parameter data can be flexibly and efficiently parsed and processed to support the transfer of parameter data of different programming languages, reducing the workload of program development and maintenance.
[0073] In some examples, the parameter parsing function interface can be AnalyzePyArgsss(), which defines the code logic for parsing a Python tuple object containing command parameter data. During the execution of test cases, the parameter list in the Python script is directly converted into parameters passed to a C++ function, where each member item corresponds to a parameter in the called parameter list. Through an extension library provided by Python, they can be converted into C++ types; the execution function interface can be Activate(), which is defined to be called when the command is activated and started. This interface can be used to analyze the incoming parameter data object, and after necessary initialization, execute the command; the cleanup function interface can be Deactivate(), which is defined to be called when the command is executed or terminated. This interface can be used to perform cleanup work before the command exits. Thus, by defining corresponding function interfaces in the command class instance, various different types of parameter data can be parsed and processed flexibly and efficiently to support the transfer of parameter data in different programming languages, reducing the workload of program development and maintenance.
[0074] Furthermore, for the command class instance, by registering the command class instances that may be needed during the test process on the test system, the command class instances have the corresponding concept of lifecycle, enabling users to allocate the command class instances according to actual needs, facilitating test program developers to manage the corresponding command class instances, test cases, etc., and effectively reducing the test cost.
[0075] In specific implementation, through functions such as registration and cancellation, the test script is allowed to register and cancel the corresponding command class instances on the test system. For example, through the corresponding function interface Register(), the registration function of custom commands is provided. Before using the command class instance, the user needs to register the command class instance in the test system, and the test system will manage the command class instance; correspondingly, for the already registered command class instances, after the corresponding test is completed, the user can cancel the corresponding command class instance in the test system. For example, through the corresponding function interface Unregister(), this interface provides the function for the test script to cancel the registration of the custom command class instance.
[0076] It should be noted that for the command class instances registered in the test system, the mapping relationship between the command class instances and the command identifiers has been established, so as to retrieve and find the corresponding command class instances through the command identifiers during the test, and further implement the geometric modeling test of the geometric modeling engine through the function interfaces provided by the command class instances.
[0077] Step 102: Determine test cases for the geometric modeling engine, execute the test cases through the test script, determine the test commands corresponding to the test cases and the parameter sequences corresponding to each test command, where the parameter type of the parameter sequence is the first programming language;
[0078] In the embodiments of the present invention, for the geometric modeling engine, the user can develop corresponding test cases for testing the geometric modeling engine. In the test cases, the test objectives and steps can be defined, including input, execution conditions, expected results, etc. Among them, a test case can include multiple test commands, and each test command can call a corresponding command class instance to execute specific operations.
[0079] During the testing process, the test cases configured by the user are test cases written based on the first programming language (such as Python). During the process of executing the test cases through the test script, the Python parameter sequence involved in the test case is passed through the unified command entry of the API binding. Specifically, during the process of the test script executing the test case, it can first determine each test command (such as creating geometric bodies, performing Boolean operations, geometric transformations, and geometric property calculations, etc.) and preconditions involved in the test case, and at the same time, determine the parameter sequences corresponding to each test command.
[0080] Step 103: Extract the target command class instance that matches the test command from the registered command class instances according to the parameter sequence;
[0081] After determining the parameter sequence corresponding to the test command, the target command class instance that matches the test command can be further found from the registered command class examples according to the parameter sequence, so as to test the geometric modeling engine based on the target command class instance.
[0082] In some feasible implementation manners, the parameter sequence at least includes a command identifier, and different test commands correspond to different command identifiers. Then, based on the command identifier and the constructed mapping relationship, a target command class instance matching the command identifier can be found from the command class instances. In addition, a corresponding model library is also configured in the test system. The model library at least includes all model object instances generated during the test run of the geometric modeling engine and the model identifiers corresponding to each model object instance. For the parameter sequence, it can also be detected whether it contains a corresponding model identifier for representing a model object. If there is a model identifier for representing a model object in the parameter sequence, a target model object instance matching the model identifier is extracted from the model library. Thus, by extracting a target command class instance matching the test command from the command class instances, and when there is a model identifier, extracting the corresponding model object instance, the geometric modeling function of the geometric modeling engine can be tested based on the target command class instance and / or the model object instance.
[0083] It should be noted that the model library configured in the test system contains all model object instances generated during the test process, such as cuboids, cylinders, etc. Each model object instance corresponds to a corresponding model identifier. Optionally, during the process of testing the geometric modeling engine, there may be some test commands that need to use the existing running results as preconditions, and these preconditions are often the generated model object instances. Therefore, there may be corresponding model identifiers in the parameter sequence to extract the corresponding model object instances from the model library through the model identifiers.
[0084] Step 104: Parse the parameter sequence according to the function interface of the target command class instance to obtain test parameters with the parameter type of the second programming language, and test the geometric modeling engine according to the test parameters to obtain the test result corresponding to the test case.
[0085] After determining the corresponding target command class instance, the parameter sequence can be parsed according to the function interface provided by the target command class instance, and the relevant parameters involved in the parameter sequence can be converted into parameters that can be executed in the language environment where the geometric modeling engine is located, to obtain test parameters with the parameter type of the second programming language, and test the geometric modeling engine according to the test parameters to obtain the test result corresponding to the test case. Therefore, during the process of testing the geometric modeling engine, by registering the corresponding command class instances on the test system, the user can process the corresponding test parameters across programming languages at the custom command level, implement the testing of the geometric modeling engine, flexibly and efficiently parse and process different types of parameter data, support the transfer of parameter data of different programming language types, and at the same time facilitate the test program developers to write the corresponding test cases, reducing the workload of program development and maintenance.
[0086] In a feasible implementation, when the first programming language is the Python language and the second programming language is the C++ language, the test script can pass a parameter sequence of the Python language type into the parameter parsing function interface for parameter type conversion to obtain test parameters of the C++ language type. Among them, the test parameters can include the first geometric modeling parameter, and the test script can pass the first geometric modeling parameter to the geometric modeling engine through the execution function interface. In response to the geometric modeling engine executing the first geometric modeling operation corresponding to the first geometric modeling parameter, the test result corresponding to the test case can be obtained according to the first geometric modeling operation. Thus, in the process of testing the geometric modeling engine, by registering the corresponding command class instance on the test system, the user can process the corresponding test parameters across programming languages at the custom command level, realize the testing of the geometric modeling engine, flexibly and efficiently parse and process different types of parameter data, support the transfer of parameter data of different programming language types, and at the same time facilitate the test program developer to write the corresponding test cases, reducing the workload of program development and maintenance.
[0087] It should be noted that after obtaining the corresponding geometric modeling parameters, the geometric modeling engine can perform corresponding geometric modeling operations, such as the creation and editing of geometric bodies, Boolean operations (such as union, difference, and intersection, etc.), the transformation of geometric bodies (such as translation, rotation, scaling, etc.), and the property calculation of geometric bodies (such as volume, surface area, etc.). After performing the corresponding geometric modeling operations, the corresponding test results can be obtained. For example, whether the created geometric object conforms to the geometric object expected by the user, whether the Boolean operation meets the corresponding conditions, whether the transformation of the geometric body meets the preset conditions, etc. When passing the corresponding test parameters, the test conditions can be passed in together to determine whether the geometric modeling operation meets the user's expectations, etc. The present invention does not limit this.
[0088] In another feasible implementation, if a model object instance is required during the testing process, after obtaining the corresponding model object instance, the geometric modeling engine can be tested based on the test parameters and the model object instance to obtain the test result corresponding to the test case. Among them, for the model object instance, it can essentially be regarded as a set of parameter data with complex structures, that is, the second geometric modeling parameter. After obtaining the second geometric modeling parameter corresponding to the target model object instance, the first geometric modeling parameter and the second geometric modeling parameter can be passed to the geometric modeling engine. In response to the geometric modeling engine executing the second geometric modeling operation corresponding to the first geometric modeling parameter and the second geometric modeling parameter, the test result corresponding to the test case can be obtained according to the second geometric modeling operation. Thus, during the process of testing the geometric modeling engine, by configuring a model library on the test system, users can flexibly and efficiently parse and process different types of parameter data sets from the custom command level through the parameters of the model identifier, support the transfer of parameter data of different programming language types, and at the same time facilitate the test program developers to write the corresponding test cases, reducing the workload of program development and maintenance.
[0089] After completing the above testing process, the test parameters can be cleared through the clear function interface, so that after the testing is completed, the relevant test parameters involved in the testing process can be cleared to release the corresponding memory and resources. In addition, after all test cases have been tested, since the test system also provides a function to cancel the registration of command class instances, it can respond to the completion of testing for each test case and cancel all command class instances in the test system. Thus, by canceling the corresponding command class instances, the corresponding memory and resources can be released, and at the same time, the command class instances have the corresponding concept of life cycle, enabling users to allocate the command class instances according to actual needs, facilitating the test program developers to manage the corresponding command class instances, test cases, etc., and effectively reducing the testing cost.
[0090] In one example, referring to Figure 2 , a schematic diagram of the application scenario provided in the embodiment of the present invention is shown. For the testing process, among them, the test system platform and the running environment can be based on the Python language system, and the geometric modeling engine can be based on the C++ language system. Parameter data can be transferred between the two through test cases (Python script programs). Specifically, the following process can be included:
[0091] (1) Define the C++ base class CmdBase of the custom command class;
[0092] (2) Define the custom command class and class instance class myCmd: public CmdBase {};
[0093] (3) Register() / Unregister();
[0094] (4) Custom command library (support for finding by name);
[0095] (5) Unified command entry for API Binding;
[0096] (6) Named model object library (support for finding by name);
[0097] (7) Command start: Activate()
[0098] Parse parameters: AnalyzePyArgsss();
[0099] Command stop: Deactivate();
[0100] (8) C++ parameter data for performing corresponding test operations based on the C++ parameter data.
[0101] In the above process, the API binding mechanism provided by Python can be utilized to implement an extension module for Python. This extension module provides a general Python C++ extension function entry. When running a Python script (i.e., a test script), the Python language interpreter can pass the command name and its parameters in the parameter sequence to the bound C++ API and perform parameter type conversion according to the Python interface binding rules. This API always includes self and args. Args can contain a set of parameters required by the Python script function (represented as C++ objects). For example, for create_box that generates a cuboid, it contains three geometric parameters of the cuboid (length 1.5, width 2.3, height 4.6); self contains at least one default parameter, which is the command identifier of the custom command class instance. Through this command identifier, the registered command class instance can be found; if more parameter data is passed in, the corresponding command class instance can be called to parse and process it through the AnalyzePyArgsss() interface; the parameter data distinguishes between ordinary text and text with specific meanings. Among them, ordinary text is the text representation of numerical parameters, such as the length 1.5 is represented as '1.5', and text with specific meanings can be used to identify model objects, such as the model object name, which needs to be used in conjunction with the established model object library.
[0102] During the functional testing of the geometric modeling engine by the test system, the test system provides the base class CmdBase of the custom command. Then, a custom command class (such as myCmd) is derived from the base class CmdBase, and the virtual function interfaces of Activate(), Deactivate(), and AnalyzePyArgsss() are overloaded to implement the custom parameter data parsing logic;
[0103]
[0104]
[0105] When the test system platform starts, call Register() to register the instance of the user-defined command class. When the test ends, Unregister() can be called to unregister all the registered command class instances. Then, the script program corresponding to the test case can be executed, and the Python parameter sequence is passed through the unified command entry of the API binding. During the parameter passing process, the default first parameter is the command identifier, and the myCmd command class instance can be found through the command identifier; if the passed parameters contain the model identifier representing the model object instance, the corresponding model object instance can be obtained from the model library through the model identifier. After finding the corresponding command class instance, the function interface provided by the custom command class instance can be started to parse the Python parameter sequence into the parameter data of the C++ type required by the myCmd command class instance, and other function interfaces are executed to perform the corresponding geometric modeling operations in the geometric modeling engine according to the parsed parameter data. Therefore, during the testing of the geometric modeling engine, by registering the corresponding command class instance on the test system, users can process the corresponding test parameters at the custom command level across programming languages, implement the testing of the geometric modeling engine, flexibly and efficiently parse and process different types of parameter data, support the passing of parameter data of different programming language types, and at the same time facilitate the test program developers to write the corresponding test cases, reducing the workload of program development and maintenance.
[0106] For example, if it is necessary to test the modeling capabilities of generating a cuboid and performing Boolean operations of a certain geometric modeling engine, the designed test cases are as follows:
[0107] (1) When the test commands developed by the user are respectively: create_box, create_cylinder, and boolean_cut test commands, these command functions must process the incoming different parameter forms respectively.
[0108] (2) In the Python language environment, these test command functions can be used.
[0109] ① Test case 1 is as follows:
[0110]
[0111] ② Test case 2 is as follows:
[0112]
[0113] For the test command function in the above Python language environment, the test script can extract a suitable target command class instance from the command class instances registered in the test system, and execute test commands, parse parameters, etc. through the function interfaces provided in the target command class instance, and transfer the corresponding geometric modeling parameters to the geometric modeling engine for testing to obtain the corresponding test results.
[0114] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It can be understood that those skilled in the art can also set according to actual needs under the guidance of the ideas of the embodiments of the present invention, and the present invention does not limit this.
[0115] In the embodiments of the present invention, the user can test the geometric modeling engine through the test system, and can run the corresponding test script on the test system. The test script can be a script program configured based on the first programming language. During the test, the command class instances for testing the geometric modeling engine can be registered in the test system first. There are several function interfaces provided in the command class instances. Then the user can set test cases for the geometric modeling engine, and execute the test cases through the test script to determine the test commands corresponding to the test cases and the parameter sequences corresponding to each test command. The parameter type of the parameter sequence is the first programming language. Then, according to the parameter sequence, the target command class instance matching the test command is extracted from the registered command class instances. Based on the extracted target command class instance, the parameter sequence can be further parsed according to the function interface of the target command class instance to obtain test parameters with the parameter type of the second programming language, and the geometric modeling engine is tested according to the test parameters to obtain the test results corresponding to the test cases.
[0116] It should be noted that for the method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequences, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for the embodiments of the present invention.
[0117] Refer to Figure 3, showing a structural block diagram of a test device for a geometric modeling engine provided in an embodiment of the present invention, related to a test system and a geometric modeling engine. The test system runs a test script, and the test script is a script program configured based on a first programming language. Specifically, it may include the following modules:
[0118] The registration module 301 is used to register, in the test system, a command class instance for testing the geometric modeling engine, and a number of function interfaces are provided in the command class instance;
[0119] The test case determination module 302 is used to determine a test case for the geometric modeling engine, execute the test case through the test script, determine a test command corresponding to the test case and a parameter sequence corresponding to each test command, and the parameter type of the parameter sequence is the first programming language;
[0120] The command class instance extraction module 303 is used to extract, from the registered command class instances according to the parameter sequence, a target command class instance that matches the test command;
[0121] The test module 304 is used to parse the parameter sequence according to the function interface of the target command class instance to obtain test parameters with the parameter type of a second programming language, and test the geometric modeling engine according to the test parameters to obtain a test result corresponding to the test case.
[0122] In some feasible embodiments, it further includes:
[0123] The cancellation module is used to cancel all command class instances in the test system in response to all test cases being tested.
[0124] In some feasible embodiments, the parameter sequence at least includes a command identifier, and the command class instance extraction module 303 is specifically used for:
[0125] Extracting a target command class instance that matches the command identifier from the registered command class instances.
[0126] In some feasible embodiments, the test system at least includes a model library, and the model library at least includes all model object instances generated during the test run of the geometric modeling engine and model identifiers corresponding to each model object instance. The device further includes:
[0127] The model object extraction module is used to extract a target model object instance that matches the model identifier from the model library if there is a model identifier representing a model object instance in the parameter sequence.
[0128] In some feasible embodiments, the test module 304 is specifically configured to:
[0129] Test the geometric modeling engine according to the test parameters and the target model object instance, and obtain the test result corresponding to the test case.
[0130] In some feasible embodiments, the command class instance includes a parameter parsing function interface, the first programming language is the Python language, the second programming language is the C++ language, and the test module 304 is specifically configured to:
[0131] Pass the parameter sequence of the Python language type into the parameter parsing function interface for parameter type conversion, and obtain test parameters with the parameter type of the C++ language.
[0132] In some feasible embodiments, the command class instance further includes an execution function interface, the test parameters at least include first geometric modeling parameters, and the test module 304 is specifically configured to:
[0133] Pass the first geometric modeling parameter to the geometric modeling engine through the execution function interface, and in response to the geometric modeling engine executing a first geometric modeling operation corresponding to the first geometric modeling parameter, obtain the test result corresponding to the test case according to the first geometric modeling operation.
[0134] In some feasible embodiments, the test parameters at least include first geometric modeling parameters, and the test module 304 is specifically configured to:
[0135] Obtain second geometric modeling parameters corresponding to the target model object instance;
[0136] Pass the first geometric modeling parameter and the second geometric modeling parameter to the geometric modeling engine, and in response to the geometric modeling engine executing a second geometric modeling operation corresponding to the first geometric modeling parameter and the second geometric modeling parameter, obtain the test result corresponding to the test case according to the second geometric modeling operation.
[0137] In some feasible embodiments, the command class instance further includes a clearing function interface, and the apparatus further includes:
[0138] A clearing module, configured to clear the test parameters through the clearing function interface in response to the completion of the test of the geometric modeling engine.
[0139] For the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For related parts, please refer to the partial description of the method embodiment.
[0140] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, it implements each process of the above-described embodiment of the test method for the geometric modeling engine and can achieve the same technical effects. To avoid repetition, details are not described herein again.
[0141] An embodiment of the present invention further provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, it implements each process of the above-described embodiment of the test method for the geometric modeling engine and can achieve the same technical effects. To avoid repetition, details are not described herein again. Among them, the computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.
[0142] Each embodiment in this specification is described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other.
[0143] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, an apparatus, or a computer program product. Therefore, the embodiments of the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, EEPROMs, Flash, and eMMC, etc.) containing computer-usable program codes.
[0144] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of processes and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for implementing the specified functions in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0145] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements in the process Figure 1 one process or multiple processes and / or blocks Figure 1 the functions specified in one block or multiple blocks.
[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, such that a series of operation steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0147] Although the preferred embodiments of the embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concepts. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0148] Finally, it should also be noted that in this article, relational terms such as first and second 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 term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising the element.
[0149] The above has introduced in detail a testing method for a geometric modeling engine and a testing device for a geometric modeling engine provided by the present invention. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A testing method for a geometric modeling engine, characterized in that, Relating to a test system and a geometric modeling engine, the test system runs a test script, and the test script is a script program configured based on a first programming language. The method includes: Registering an instance of a command class for testing the geometric modeling engine in the test system, and a number of function interfaces are provided in the instance of the command class; Determining a test case for the geometric modeling engine, executing the test case through the test script, determining a test command corresponding to the test case and a parameter sequence corresponding to each test command, and the parameter type of the parameter sequence is the first programming language; Extracting a target command class instance that matches the test command from the registered command class instances according to the parameter sequence; Parsing the parameter sequence according to the function interface of the target command class instance to obtain test parameters with a parameter type of a second programming language, and testing the geometric modeling engine according to the test parameters to obtain a test result corresponding to the test case.
2. The method according to claim 1, wherein It further includes: In response to all test cases being tested, canceling all instances of the command class in the test system.
3. The method according to claim 1 or 2, characterized in that, The parameter sequence at least includes a command identifier. The extracting a target command class instance that matches the test command from the registered command class instances according to the parameter sequence includes: Extracting a target command class instance that matches the command identifier from the registered command class instances.
4. The method according to claim 3, characterized in that, The test system at least includes a model library, and the model library at least includes all model object instances generated during the test run of the geometric modeling engine and model identifiers corresponding to each model object instance. The method further includes: If there is a model identifier in the parameter sequence for representing a model object instance, extracting a target model object instance that matches the model identifier from the model library.
5. The method according to claim 4, wherein The testing the geometric modeling engine according to the test parameters to obtain a test result corresponding to the test case includes: Testing the geometric modeling engine according to the test parameters and the target model object instance to obtain a test result corresponding to the test case.
6. The method according to claim 1 or 2, characterized in that, The instance of the command class includes a parameter parsing function interface, the first programming language is the Python language, and the second programming language is the C++ language. The parsing the parameter sequence according to the function interface of the target command class instance to obtain test parameters with a parameter type of a second programming language includes: Passing the parameter sequence of the Python language type into the parameter parsing function interface for parameter type conversion to obtain test parameters with a parameter type of the C++ language.
7. The method according to claim 6, wherein The instance of the command class further includes an execution function interface, and the test parameters at least include first geometric modeling parameters. The testing the geometric modeling engine according to the test parameters to obtain a test result corresponding to the test case includes: Through the execution function interface, the first geometric modeling parameter is passed to the geometric modeling engine. In response to the geometric modeling engine executing a first geometric modeling operation corresponding to the first geometric modeling parameter, the test result corresponding to the test case is obtained according to the first geometric modeling operation.
8. The method according to claim 4, characterized in that, The test parameter at least includes a first geometric modeling parameter. Testing the geometric modeling engine according to the test parameter and the target model object instance, and obtaining the test result corresponding to the test case includes: Obtaining a second geometric modeling parameter corresponding to the target model object instance; Passing the first geometric modeling parameter and the second geometric modeling parameter to the geometric modeling engine. In response to the geometric modeling engine executing a second geometric modeling operation corresponding to the first geometric modeling parameter and the second geometric modeling parameter, the test result corresponding to the test case is obtained according to the second geometric modeling operation.
9. The method according to claim 6, wherein The command class instance further includes a clearing function interface, and the method further includes: In response to the completion of the testing of the geometric modeling engine, the test parameter is cleared through the clearing function interface.
10. A test device for a geometric modeling engine, characterized in that, Relating to a test system and a geometric modeling engine, the test system runs a test script, and the test script is a script program configured based on a first programming language. The device includes: A registration module for registering a command class instance for testing the geometric modeling engine in the test system, and a plurality of function interfaces are provided in the command class instance; A test case determination module for determining a test case for the geometric modeling engine, executing the test case through the test script, determining a test command corresponding to the test case and a parameter sequence corresponding to each test command, and the parameter type of the parameter sequence is the first programming language; A command class instance extraction module for extracting a target command class instance matching the test command from the registered command class instances according to the parameter sequence; A test module for parsing the parameter sequence according to the function interface of the target command class instance to obtain a test parameter with a parameter type of a second programming language, and testing the geometric modeling engine according to the test parameter to obtain the test result corresponding to the test case.
11. An electronic device, characterized in that, Including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used for storing a computer program; When the processor is used to execute the program stored on the memory, the method described in any one of claims 1-9 is implemented.
12. A computer-readable storage medium, on which instructions are stored. When the instructions are executed by one or more processors, the processors are caused to execute the method described in any one of claims 1-9.
Citation Information
Patent Citations
Test method and application program starting time consumption test method
CN112181822A
Smart card test method, system and device and storage medium
CN118394648A
Mapping between native data type instances
US20040177160A1
Method for invoking UOML instructions
US20090187927A1
Generated object model for test automation
US20130061204A1