Unit test environment container generation method, unit test method and device
Patent Information
- Application Number
- CN202210880272.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-25
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2042-07-25
AI Technical Summary
并且目前的前端单元测试需要在浏览器中运行,不利于测试代码的移植
[0014] Based on the unit test environment container generation method and apparatus, unit test method and apparatus, computer-readable storage medium, electronic device, and computer program product provided in the above embodiments of this disclosure, by setting up an operating system for running a graphics rendering program and creating a unit test environment container within the operating system, and then setting up a test environment for unit testing within the unit test environment container based on a data package for establishing the unit test environment, a graphics rendering environment can be simulated within the unit test environment container. Graphics rendering test cases can be run without relying on a browser, improving the portability of unit tests. The unit test environment container can be exported as a unit test environment image. When performing unit tests using the unit test environment image, unit tests can be automatically run using the unit test environment image simply by entering commands, without needing to configure a browser, thus improving the efficiency of unit testing.
Smart Images

Figure CN115237779B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method, apparatus, computer-readable storage medium, computer program product, and electronic device for generating a unit test environment container. Background Technology
[0002] Unit testing refers to the inspection and verification of the smallest testable unit in software. It is a crucial part of front-end engineering, ensuring the stability of continuous iteration of front-end projects by checking and verifying these smallest testable units. It mainly includes the unit testing environment, unit test cases, and unit test execution commands. Front-end code typically runs in a browser. For example, in projects involving 3D graphics rendering, current testing primarily uses assertions to test simple code. Furthermore, current front-end unit tests require browser execution, which hinders code portability. Summary of the Invention
[0003] Embodiments of this disclosure provide a method, apparatus, computer-readable storage medium, electronic device, and computer program product for generating a unit test environment container.
[0004] Embodiments of this disclosure provide a method for generating a unit test environment container. The method includes: acquiring project data to be unit tested in a simulated graphics rendering environment, wherein the project data includes at least one unit test case; setting an operating system for running a graphics rendering program and creating a basic container in the operating system; setting a test environment for unit testing in the basic container based on a preset data package for establishing a unit test environment; and setting the project data in the basic container to obtain the unit test environment container.
[0005] In some embodiments, acquiring a test rendering tool for simulating a graphics rendering environment includes: acquiring initial project data; determining whether the runtime environment of the initial project data is a unit test environment based on the runtime environment flag in the initial project data; and if it is a unit test environment, determining that the initial project data is a test rendering tool for simulating a graphics rendering environment.
[0006] In some embodiments, before acquiring the engineering data to be unit tested in a simulated graphics rendering environment, the method further includes: generating rendering configuration information based on a preset data package for establishing a graphics rendering environment; and generating engineering data based on the rendering configuration information.
[0007] In some embodiments, the data package used to establish a graphics rendering environment includes a graphics drawing data package and a graphics library data package.
[0008] According to another aspect of the present disclosure, a unit testing method is provided, the method comprising: running a pre-set unit test environment image to generate a unit test environment container for simulating a graphics rendering environment, wherein the unit test environment image is generated by exporting the unit test environment container in advance, and the unit test environment container is generated according to the above-described unit test environment container generation method; executing at least one preset unit test case in the unit test environment container to obtain test results corresponding to the test cases in the at least one unit test case; and generating a test report based on the generated at least one test result.
[0009] According to another aspect of the present disclosure, an apparatus for generating a unit test environment container is provided. The apparatus includes: an acquisition module for acquiring engineering data to be unit tested in a simulated graphics rendering environment, wherein the engineering data includes at least one unit test case; a creation module for setting an operating system for running a graphics rendering program and creating a basic container in the operating system; a setting module for setting a test environment for performing unit tests in the basic container based on a preset data package for establishing a unit test environment; and a first generation module for setting the engineering data in the basic container to obtain the unit test environment container.
[0010] According to another aspect of the present disclosure, a unit testing apparatus is provided, comprising: a fourth generation module, configured to run a pre-set unit test environment image to generate a unit test environment container for simulating a graphics rendering environment, wherein the unit test environment image is generated by exporting the unit test environment container in advance, and the unit test environment container is generated according to the above-described unit test environment container generation method; a testing module, configured to execute at least one preset unit test case in the unit test environment container to obtain test results corresponding to the test cases in the at least one unit test case; and a fifth generation module, configured to generate a test report based on the generated at least one test result.
[0011] According to another aspect of the present disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the steps of the above-described method for generating a unit test environment container or a unit test method.
[0012] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; and a processor for reading executable instructions from the memory and executing the instructions to implement the above-described method for generating a unit test environment container or a unit test method.
[0013] According to another aspect of the present disclosure, a computer program product is provided, including computer program instructions that, when executed by a processor, implement the steps of the above-described method for generating a unit test environment container or a unit test method.
[0014] Based on the unit test environment container generation method and apparatus, unit test method and apparatus, computer-readable storage medium, electronic device, and computer program product provided in the above embodiments of this disclosure, by setting up an operating system for running a graphics rendering program and creating a unit test environment container within the operating system, and then setting up a test environment for unit testing within the unit test environment container based on a data package for establishing the unit test environment, a graphics rendering environment can be simulated within the unit test environment container. Graphics rendering test cases can be run without relying on a browser, improving the portability of unit tests. The unit test environment container can be exported as a unit test environment image. When performing unit tests using the unit test environment image, unit tests can be automatically run using the unit test environment image simply by entering commands, without needing to configure a browser, thus improving the efficiency of unit testing.
[0015] The technical solutions of this disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0016] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of the embodiments thereof in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.
[0017] Figure 1 This is the system diagram to which this disclosure applies.
[0018] Figure 2 This is a flowchart illustrating a method for generating a unit test environment container provided in an exemplary embodiment of this disclosure.
[0019] Figure 3 This is a flowchart illustrating a method for generating a unit test environment container provided in another exemplary embodiment of this disclosure.
[0020] Figure 4 This is a flowchart illustrating a method for generating a unit test environment container provided in another exemplary embodiment of this disclosure.
[0021] Figure 5 This is a flowchart illustrating a unit testing method provided in an exemplary embodiment of this disclosure.
[0022] Figure 6 This is a schematic diagram of the structure of a unit test environment container generation apparatus provided in an exemplary embodiment of this disclosure.
[0023] Figure 7 This is a schematic diagram of the structure of a unit test environment container generation apparatus provided in another exemplary embodiment of this disclosure.
[0024] Figure 8 This is a schematic diagram of the structure of a unit test apparatus provided in an exemplary embodiment of the present disclosure.
[0025] Figure 9 This is a structural diagram of an electronic device provided in an exemplary embodiment of this disclosure. Detailed Implementation
[0026] Hereinafter, exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present disclosure, and not all embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described herein.
[0027] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of this disclosure.
[0028] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of this disclosure are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.
[0029] It should also be understood that in the embodiments disclosed herein, "a plurality of" may refer to two or more, and "at least one" may refer to one, two or more.
[0030] It should also be understood that any component, data or structure mentioned in the embodiments of this disclosure can generally be understood as one or more unless expressly defined or given to the contrary in the context.
[0031] Furthermore, the term "and / or" in this disclosure is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this disclosure generally indicates that the preceding and following related objects have an "or" relationship.
[0032] It should also be understood that the description of the various embodiments in this disclosure emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.
[0033] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0034] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.
[0035] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0036] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0037] The embodiments disclosed herein can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate together with a wide range of other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.
[0038] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are executed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.
[0039] Application Overview
[0040] Because unit testing requires significant manpower and maintenance, there are currently few examples of unit testing in front-end engineering. This is especially true for front-end projects in graphics rendering scenarios. Some graphics rendering front-end projects may appear to have unit tests, but these often only test simple code using assertions and do not involve comprehensive unit testing using rendering tools such as WebGL (Web Graphics Library, a 3D graphics protocol). Many front-end projects add unit testing capabilities to the project without placing them in a containerized environment, which is very detrimental to front-end engineering integration and portability, hindering integration with project pipelines and the output of test reports.
[0041] Exemplary System
[0042] Figure 1 An exemplary system architecture 100 is shown for a method or apparatus for generating a unit test environment container to which embodiments of the present disclosure may be applied, as well as a unit test method or unit test apparatus.
[0043] like Figure 1 As shown, system architecture 100 may include terminal device 101, network 102, and server 103. Network 102 is used as a medium to provide a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0044] Users can use terminal device 101 to interact with server 103 via network 102 to receive or send messages, etc. Various communication client applications can be installed on terminal device 101, such as web browser applications, search applications, shopping applications, instant messaging tools, etc.
[0045] Terminal device 101 can be various electronic devices, including but not limited to mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers.
[0046] Server 103 can be a server providing various services, such as a background test server running the unit test environment image uploaded by terminal device 101 to perform unit tests in a simulated graphics rendering environment. The background test server can run the unit test environment image and generate test reports. Server 103 can also pre-create a unit test environment container, set up the unit test environment, test rendering tools, and test cases in the unit test environment container, and generate a unit test environment image.
[0047] It should be noted that the unit test environment container generation method or unit test method provided in the embodiments of this disclosure can be executed by the server 103 or by the terminal device 101. Accordingly, the unit test environment container generation device or unit test device can be set in the server 103 or in the terminal device 101.
[0048] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0049] Exemplary methods
[0050] Figure 2 This is a schematic flowchart illustrating a method for generating a unit test environment container according to an exemplary embodiment of this disclosure. This embodiment can be applied to electronic devices (such as...). Figure 1 On the terminal device 101 or server 103 shown, such as Figure 2 As shown, the method includes the following steps:
[0051] Step 201: Obtain the project data to be used for unit testing in the simulated graphics rendering environment.
[0052] In this embodiment, the electronic device can acquire project data for unit testing in a simulated graphics rendering environment, either locally or remotely. This project data includes at least one unit test case. The project data can be data used for image rendering using a graphics rendering tool; for example, the graphics rendering tool can be WebGL, and the project data can be data included in a WebGL project. At least one unit test case can be pre-written. For example, one test case might test whether the expected coordinates match the actual coordinates after converting the client's coordinate system to the WebGL coordinate system; another test case might test whether the graphic obtained after rendering a 3D image is the expected graphic.
[0053] Step 202: Set up the operating system for running the graphics rendering program and create a basic container within the operating system.
[0054] In this embodiment, the electronic device can be configured with an operating system for running graphics rendering programs, and a basic container can be created within the operating system.
[0055] As an example, an electronic device can retrieve an operating system image from a remote location by entering a command and then run that image to set up the operating system. For instance, an electronic device can use the command "docker pull ubuntu" to pull the Ubuntu image from a remote location and set up the Ubuntu operating system.
[0056] The aforementioned base container can be created using existing containerization tools. For example, the base container can be created using the open-source tool Docker, and then a simulated graphics rendering environment can be created within the base container through the following steps. The created container is lightweight, portable, and fully sandboxed; the environment within the container is configurable and does not affect the operating system.
[0057] Step 203: Based on the preset data package for establishing the unit test environment, set up the test environment for unit testing in the base container.
[0058] In this embodiment, the electronic device can set up a test environment for unit testing in the basic container based on a preset data packet for establishing a unit test environment.
[0059] As an example, the aforementioned data packages may include NodeJS (a platform built on top of the Chrome JavaScript runtime) data packages, NPM (Node Package Manager, a package management tool for the JavaScript language) data packages, and so on. These data packages can be used to install NodeJS applications, NPM dependencies, and provide a testing environment for unit testing.
[0060] Step 204: Set the engineering data in the base container to obtain the unit test environment container.
[0061] In this embodiment, the electronic device can set up engineering data in a base container to obtain a unit test environment container. Specifically, the engineering data can be stored in a corresponding system folder, and the dependency packages required for unit testing (such as NPM dependency packages) can be installed. After configuring the unit test environment and test cases in the base container, the unit test environment container is obtained.
[0062] Typically, electronic devices can export unit test environment containers as unit test environment images.
[0063] Exporting the unit test environment container as a unit test environment image can be accomplished using existing technologies. For example, the existing Docker containerization command "docker commit containerID kemagic-test" can be used to save the container as an image, and then the command "docker export -o kemagic-test.tar kemagic-test" can be used to export the image, thus obtaining the unit test environment image.
[0064] The method provided by the above embodiments of this disclosure sets up an operating system for running a graphics rendering program, creates a unit test environment container in the operating system, and then sets up a test environment for unit testing in the unit test environment container based on the data package used to establish the unit test environment. This realizes the simulation of a graphics rendering environment in the unit test environment container, and graphics rendering test cases can be run without relying on a browser, thereby improving the portability of unit tests.
[0065] In some alternative implementations, such as Figure 3 As shown, step 201 may include the following sub-steps:
[0066] Step 2011: Obtain initial project data.
[0067] The initial engineering data can be extracted from multiple pre-established engineering data sets to be rendered graphically. This engineering data includes engineering data from actual engineering applications and engineering data to be unit tested.
[0068] Step 2012: Based on the runtime environment marker in the initial project data, determine whether the runtime environment of the initial project data is a unit test environment.
[0069] As an example, the runtime environment variable of the NODE service can be used as a runtime environment marker to determine whether the current initial project data is running in a unit test environment. Specifically, `process.env.NODE_ENV` is the runtime environment variable. When `process.env.NODE_ENV` is "test", the current runtime environment is determined to be a unit test environment, and unit testing of the aforementioned initial project data is required. When `process.env.NODE_ENV` is "product", the current runtime environment is determined to be a production environment, i.e., the actual application environment, and unit testing is not required; instead, graphical rendering in the browser is necessary.
[0070] Step 2013: If it is a unit testing environment, determine that the initial project data is the project data to be unit tested in the simulated graphics rendering environment.
[0071] This embodiment can automatically identify whether initial engineering data needs to be unit tested by judging the runtime environment tags in the initial engineering data, and accurately intercept engineering data to be unit tested, thereby helping to improve the efficiency of unit testing.
[0072] In some alternative implementations, such as Figure 4 As shown, prior to step 201, the method further includes:
[0073] Step 401: Generate rendering configuration information based on the preset data package used to establish the graphics rendering environment.
[0074] The data package used to establish the graphics rendering environment can be configured arbitrarily as needed. The rendering configuration information is used to configure the graphics rendering tools and generate a virtual graphics rendering environment.
[0075] Optionally, the data packages used to establish the graphics rendering environment include graphics drawing data packages and / or graphics library data packages. For example, the graphics drawing data package can be an existing Canvas data package. The Canvas data package can be used to create a canvas for drawing 3D geometry, and all 3D graphics drawing takes place on this canvas. The graphics library data package can be an existing OpenGL (Open Graphics Library) data package, which can be used to establish a virtual graphics rendering environment. By using graphics drawing data packages and graphics library data packages, a fully functional virtual graphics rendering environment can be established, which helps in generating a fully functional unit test environment image.
[0076] As an example, using the OpenGL data package and Canvas data mentioned above, two instances can be created: the WebGL context information (which can be labeled glContext) and the canvas element (which can be labeled canvasGL). glContext and canvasGL constitute the rendering configuration information. Furthermore, rendering configuration information can be created as needed to create simulated shots and simulated scenes.
[0077] Step 402: Generate engineering data based on rendering configuration information.
[0078] By using the rendering configuration information, a virtual rendering environment can be configured in the project file created under the graphics rendering tool, and project data can be generated.
[0079] This embodiment utilizes data packets for establishing a graphics rendering environment to generate rendering configuration information, and generates project data based on the rendering configuration information. This enables the configuration of project files generated by the graphics rendering tool, allowing the simulation of a graphics rendering environment without a browser, thereby facilitating the accurate generation of unit test environment images.
[0080] Figure 5 This is a flowchart illustrating a unit testing method provided in an exemplary embodiment of this disclosure. This embodiment can be applied to electronic devices (such as...). Figure 1 On the terminal device 101 or server 103 shown, such as Figure 5 As shown, the method includes the following steps:
[0081] Step 501: Run the pre-configured unit test environment image to generate a unit test environment container for simulating a graphics rendering environment.
[0082] In this embodiment, the electronic device can run a pre-set unit test environment image to generate a unit test environment container for simulating a graphics rendering environment. The unit test environment image is generated by exporting the unit test environment container in advance, and the unit test environment image is pre-defined based on... Figure 2 Generated by the method described in the corresponding embodiment.
[0083] Typically, unit test environment images can be pre-imported into electronic devices, and the unit test image can be run when a start command is received. The start command can be triggered by a user control page, which may contain a test interface; calling this interface will trigger the start command.
[0084] Step 502: In the unit test environment container, execute at least one preset unit test case to obtain the test results corresponding to the test cases in the at least one unit test case.
[0085] In this embodiment, the electronic device can execute at least one preset unit test case in the unit test environment container to obtain the test results corresponding to the test cases in the at least one unit test case.
[0086] Since the unit test environment container can simulate the runtime environment of graphics rendering, at least one of the above unit test cases can be run automatically in the unit test environment container.
[0087] Step 503: Generate a test report based on at least one generated test result.
[0088] In this embodiment, the electronic device can generate a test report based on at least one generated test result. The test report may include the name of the tested method, information on whether the tested method was successful, the test time, etc. The generated test report can be further output in various ways, for example, it can be directly displayed on the screen of the aforementioned electronic device, or it can be sent to a server for storage.
[0089] The method provided in the above embodiments of this disclosure generates a unit test environment container for simulating a graphics rendering environment by running a pre-set unit test environment image. Then, at least one unit test case is executed within the unit test environment container to obtain test results. Finally, a test report is generated based on the generated test results. This eliminates the need for unit testing of graphics rendering within a browser. The unit test environment image can run on various types of software and hardware platforms, greatly expanding the scope of unit testing and improving the portability of unit test cases. Furthermore, users do not need to understand the testing process when using the unit test environment image; they can directly run the test to obtain a test report, thereby improving the efficiency of unit testing.
[0090] Exemplary device
[0091] Figure 6 This is a schematic diagram of the structure of a unit test environment container generation apparatus provided in an exemplary embodiment of this disclosure. This embodiment can be applied to electronic devices, such as... Figure 6 As shown, the unit test environment container generation device includes: an acquisition module 601, used to acquire project data to be unit tested in a simulated graphics rendering environment, wherein the project data includes at least one unit test case; a creation module 602, used to set the operating system for running the graphics rendering program and create a basic container in the operating system; a setting module 603, used to set the test environment for unit testing in the basic container based on a preset data package for establishing the unit test environment; and a first generation module 604, used to set the project data in the basic container to obtain the unit test environment container.
[0092] In this embodiment, the acquisition module 601 can acquire project data for unit testing in a simulated graphics rendering environment from either local or remote sources. The project data includes at least one unit test case. This project data can be data used for image rendering using a graphics rendering tool; for example, the graphics rendering tool can be WebGL, and the project data can be data included in a WebGL project. The at least one unit test case can be pre-written. For example, one test case might be used to test whether the expected coordinates match the actual coordinates after converting the client's coordinate system to the WebGL coordinate system; another test case might be used to test whether the graphic obtained after rendering a 3D image is the expected graphic.
[0093] In this embodiment, the creation module 602 can set up an operating system for running the graphics rendering program and create a basic container in the operating system.
[0094] As an example, module 602 can retrieve an operating system image from a remote location by entering a command and then run the operating system image to set up the operating system. For instance, module 602 can use the command "docker pullubuntu" to pull an Ubuntu image from a remote location and set up the Ubuntu operating system.
[0095] The aforementioned base container can be created using existing containerization tools. For example, the base container can be created using the open-source tool Docker, and then a simulated graphics rendering environment can be created within the base container through the following steps. The created container is lightweight, portable, and fully sandboxed; the environment within the container is configurable and does not affect the operating system.
[0096] In this embodiment, the setting module 603 can set up a test environment for unit testing in the basic container based on a preset data packet for establishing a unit test environment.
[0097] As an example, the aforementioned data packages may include NodeJS (a platform built on top of the Chrome JavaScript runtime) data packages, NPM (Node Package Manager, a package management tool for the JavaScript language) data packages, and so on. These data packages can be used to install NodeJS applications, NPM dependencies, and provide a testing environment for unit testing.
[0098] In this embodiment, the first generation module 604 can set the project data in a base container to obtain a unit test environment container. Specifically, the project data can be stored in a corresponding system folder, and the dependency packages required for unit testing (such as NPM dependency packages) can be installed. After configuring the unit test environment and test cases in the base container, the unit test environment container is obtained.
[0099] Typically, this device can export a unit test environment container as a unit test environment image.
[0100] Exporting the unit test environment container as a unit test environment image can be accomplished using existing technologies. For example, the existing Docker containerization command "docker commit containerID kemagic-test" can be used to save the container as an image, and then the command "docker export -o kemagic-test.tar kemagic-test" can be used to export the image, thus obtaining the unit test environment image.
[0101] Reference Figure 7 , Figure 7This is a schematic diagram of the structure of a unit test environment container generation apparatus provided in another exemplary embodiment of this disclosure.
[0102] In some optional implementations, the acquisition module 601 includes: an acquisition unit 6011 for acquiring initial project data; a first determination unit 6012 for determining whether the runtime environment of the initial project data is a unit test environment based on the runtime environment flag in the initial project data; and a second determination unit 6013 for determining, if it is a unit test environment, that the initial project data is a test rendering tool for simulating a graphics rendering environment.
[0103] In some optional implementations, the device further includes: a second generation module 606, used to generate rendering configuration information based on a preset data package for establishing a graphics rendering environment; and a third generation module 607, used to generate engineering data based on the rendering configuration information.
[0104] In some alternative implementations, the data packages used to establish the graphics rendering environment include graphics drawing data packages and graphics library data packages.
[0105] The unit test environment container generation apparatus provided in the above embodiments of this disclosure sets up an operating system for running a graphics rendering program, creates a unit test environment container in the operating system, sets up a test environment for performing unit tests in the unit test environment container based on a data packet for establishing the unit test environment, and finally exports the unit test environment container as a unit test environment image. This realizes the simulation of a graphics rendering environment in the unit test environment container, and allows graphics rendering test cases to be run without relying on a browser, thereby improving the portability of unit tests.
[0106] Figure 8 This is a schematic diagram of the structure of a unit test environment container generation apparatus provided in an exemplary embodiment of this disclosure. This embodiment can be applied to electronic devices, such as... Figure 8 As shown, the unit test environment container generation device includes: a fourth generation module 801, used to run a pre-set unit test environment image to generate a unit test environment container for simulating a graphics rendering environment, wherein the unit test environment image is generated by exporting the unit test environment container in advance, and the unit test environment container is generated according to the above... Figure 2 The method described in the corresponding embodiment generates: Test module 802, which is used to execute at least one preset unit test case in a unit test environment container to obtain test results corresponding to the test cases in the at least one unit test case; and fifth generation module 803, which is used to generate a test report based on the generated at least one test result.
[0107] In this embodiment, the fourth generation module 801 can run a pre-set unit test environment image to generate a unit test environment container for simulating a graphics rendering environment. The unit test environment image is generated by exporting the unit test environment container beforehand, and the unit test environment image is pre-generated based on... Figure 2 Generated by the method described in the corresponding embodiment.
[0108] Typically, unit test environment images can be pre-imported into electronic devices, and the unit test image can be run when a start command is received. The start command can be triggered by a user control page, which may contain a test interface; calling this interface will trigger the start command.
[0109] In this embodiment, the test module 802 can execute at least one preset unit test case in the unit test environment container to obtain the test results corresponding to the test cases in the at least one unit test case.
[0110] Since the unit test environment container can simulate the runtime environment of graphics rendering, at least one of the above unit test cases can be run automatically in the unit test environment container.
[0111] In this embodiment, the fifth generation module 803 can generate a test report based on at least one generated test result. The test report may include the name of the tested method, information on whether the tested method was successful, the test time, etc. The generated test report can be further output in various ways, for example, it can be directly displayed on the screen of the aforementioned electronic device, or it can be sent to a server for storage.
[0112] The unit test environment container generation apparatus provided in the above embodiments of this disclosure generates a unit test environment container for simulating a graphics rendering environment by running a pre-set unit test environment image. Then, at least one unit test case is executed within the unit test environment container to obtain test results. Finally, a test report is generated based on the generated test results. This eliminates the need for graphics rendering unit testing within a browser. The unit test environment image can run on various types of software and hardware platforms, greatly expanding the scope of unit testing and improving the portability of unit test cases. Furthermore, users do not need to understand the testing process when using the unit test environment image; they can directly run the test to obtain a test report, thereby improving the efficiency of unit testing.
[0113] Exemplary electronic devices
[0114] Below, for reference Figure 9 To describe an electronic device according to embodiments of the present disclosure. The electronic device may be as follows: Figure 1The terminal device 101 and server 103 shown, or either one or both, or a standalone device independent of them, can communicate with the terminal device 101 and server 103 to receive the collected input signals from them.
[0115] Figure 9 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0116] like Figure 9 As shown, the electronic device 900 includes one or more processors 901 and memory 902.
[0117] The processor 901 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 900 to perform desired functions.
[0118] The memory 902 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 901 may execute the program instructions to implement the unit test environment container generation method or unit test method of the various embodiments of this disclosure described above, and / or other desired functions. Various contents such as unit test environment images and test reports may also be stored in the computer-readable storage medium.
[0119] In one example, the electronic device 900 may also include an input device 903 and an output device 904, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0120] For example, when the electronic device is a terminal device 101 or a server 103, the input device 903 can be a mouse, keyboard, or other similar device used to input test cases, start commands, etc. When the electronic device is a standalone device, the input device 903 can be a communication network connector used to receive input test cases, start commands, etc. from the terminal device 101 and the server 103.
[0121] The output device 904 can output various information to the outside, including the generated unit test environment image, the generated test report, etc. The output device 904 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0122] Of course, for the sake of simplicity, Figure 9 Only some of the components of the electronic device 900 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 900 may include any other suitable components depending on the specific application.
[0123] Exemplary computer program products and computer-readable storage media
[0124] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the methods for generating unit test environment containers according to various embodiments of this disclosure as described in the foregoing portions of this specification.
[0125] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0126] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform the steps in the method for generating a unit test environment container or a unit test method according to various embodiments of this disclosure as described in the "Exemplary Methods" section above.
[0127] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0128] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0129] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0130] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0131] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.
[0132] It should also be noted that in the apparatus, devices, and methods of this disclosure, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions to this disclosure.
[0133] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0134] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. A method for generating a unit testing environment container, comprising: Obtain project data to be unit tested in a simulated graphics rendering environment, wherein the project data is the data to be used for graphics rendering using a graphics rendering tool, and the project data includes at least one unit test case. Set up an operating system for running the graphics rendering program, and create a basic container within the operating system; Based on a preset data packet for establishing a unit test environment, a test environment for performing unit tests is set up in the base container. The engineering data is set in the basic container to obtain a unit test environment container that simulates the graphics rendering environment and does not depend on the browser, and the unit test environment container is exported as a unit test environment image. Before acquiring the engineering data to be unit tested in the simulated graphics rendering environment, the method further includes: Based on the preset data package used to establish the graphics rendering environment, generate rendering configuration information; The project data is generated based on the rendering configuration information.
2. The method according to claim 1, wherein, The acquisition of project data to be used for unit testing in a simulated graphics rendering environment includes: Obtain initial project data; Based on the runtime environment marker in the initial engineering data, determine whether the runtime environment of the initial engineering data is a unit test environment; If it is a unit testing environment, the initial project data is determined to be the project data to be unit tested in the simulated graphics rendering environment.
3. The method according to any one of claims 1-2, wherein, The data packets used to establish the graphics rendering environment include graphics drawing data packets and graphics library data packets.
4. A unit testing method, comprising: Run a pre-configured unit test environment image to generate a unit test environment container for simulating a graphics rendering environment, wherein the unit test environment image is generated by exporting the unit test environment container in advance, and the unit test environment container is generated according to any one of claims 1-3. In the unit test environment container, at least one preset unit test case is executed to obtain the test results corresponding to the test cases in the at least one unit test case; A test report is generated based on at least one of the generated test results.
5. An apparatus for generating a unit test environment container, comprising: The acquisition module is used to acquire project data to be unit tested in a simulated graphics rendering environment, wherein the project data is the data to be used for graphics rendering by a graphics rendering tool, and the project data includes at least one unit test case. Create a module to set up the operating system for running the graphics rendering program, and create a basic container within the operating system; The configuration module is used to configure a test environment for unit testing in the base container based on a preset data packet for establishing a unit test environment. The first generation module is used to set the engineering data in the basic container to obtain a unit test environment container for simulating a graphics rendering environment and not relying on a browser, and to export the unit test environment container as a unit test environment image. The device also includes: The second generation module is used to generate rendering configuration information based on a preset data package for establishing a graphics rendering environment; The third generation module is used to generate the project data based on the rendering configuration information.
6. A unit testing apparatus, comprising: The fourth generation module is used to run a pre-set unit test environment image and generate a unit test environment container for simulating a graphics rendering environment. The unit test environment image is generated by exporting the unit test environment container in advance, and the unit test environment container is generated according to the method of any one of claims 1-3. The testing module is used to execute at least one preset unit test case in the unit test environment container and obtain the test results corresponding to the test cases in the at least one unit test case. The fifth generation module is used to generate a test report based on at least one generated test result.
7. An electronic device, characterized in that, include: Memory, used to store computer program products; A processor for executing a computer program product stored in the memory, wherein when the computer program product is executed, it implements the method described in any one of claims 1-4.
8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1-4.
9. A computer program product comprising computer program instructions, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1-4.
Citation Information
Patent Citations
Docker-based WebUI automated test method
CN108920365A