CN117331830A - Unit test method, unit test device, electronic equipment and readable storage medium - Google Patents

Unit test method, unit test device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN117331830A
CN117331830A CN202311276439.2A CN202311276439A CN117331830A CN 117331830 A CN117331830 A CN 117331830A CN 202311276439 A CN202311276439 A CN 202311276439A CN 117331830 A CN117331830 A CN 117331830A
Authority
CN
China
Prior art keywords
test
unit
annotation
strategy
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311276439.2A
Other languages
Chinese (zh)
Inventor
方海波
梁家鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Geely Holding Group Co Ltd
Zhejiang Zeekr Intelligent Technology Co Ltd
Original Assignee
Zhejiang Geely Holding Group Co Ltd
Zhejiang Zeekr Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Geely Holding Group Co Ltd, Zhejiang Zeekr Intelligent Technology Co Ltd filed Critical Zhejiang Geely Holding Group Co Ltd
Priority to CN202311276439.2A priority Critical patent/CN117331830A/en
Publication of CN117331830A publication Critical patent/CN117331830A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a unit testing method, a unit testing device, electronic equipment and a readable storage medium, wherein the unit testing method comprises the following steps: in response to a unit test request, determining a simulation test strategy corresponding to the unit test before executing the unit test; acquiring an IP address of test equipment for executing the unit test; and matching the IP address with the IP address in the IP white list to perform starting control on the simulation test strategy and execute the unit test.

Description

Unit test method, unit test device, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a unit testing method, a unit testing device, an electronic device, and a readable storage medium.
Background
In the software research and development process, the software test is a very important ring for guaranteeing the software functions and the software quality, but when the software test is performed, the cost and difficulty for constructing abnormal data are high, particularly when the abnormal test is performed, some abnormal data can not be constructed even through a normal path, and some special business scene data are also used when some business functions are tested.
Thus, developers typically create simulation test strategies for different unit tests, i.e., mock tests, which is a software test method used to simulate and replace certain components or objects in a system. Its purpose is to isolate and control the dependencies of the system under test during the test, thus making the test more reliable and repeatable. When performing simulation tests, a developer creates virtual, simulated objects instead of actual dependencies to simulate expected behavior and interactions.
Disclosure of Invention
The application provides a unit testing method which is applied to a testing system; the test system is respectively configured with at least one simulation test strategy aiming at least one unit to be tested corresponding to the unit test; the test system maintains an IP whitelist for initiating control of the at least one simulated test strategy, the method comprising:
in response to a unit test request, determining a simulation test strategy corresponding to the unit test before executing the unit test;
acquiring an IP address of test equipment for executing the unit test;
and matching the IP address with the IP address in the IP white list to perform starting control on the simulation test strategy and execute the unit test.
Optionally, the matching the IP address with an IP address in the IP whitelist to perform start control for the simulation test policy includes:
matching the IP address with the IP address in the IP white list, and if the matching is successful, starting a simulation test strategy corresponding to the unit test; and otherwise, not starting a simulation test strategy corresponding to the unit test.
Optionally, the method further comprises:
after the unit test is performed, the simulation test strategy corresponding to the unit test is stopped.
Optionally, the method further comprises:
for any simulated test strategy, a custom annotation is created, the custom annotation comprising a first annotation for starting the simulated test strategy and a second annotation for stopping the simulated test strategy.
Optionally, before executing the unit test, starting a simulation test strategy corresponding to the unit test case, including:
before executing the unit test, a simulated test strategy corresponding to the unit test is initiated based on the first annotation.
Optionally, after the unit test is performed, stopping the simulation test strategy, including:
after the unit test is performed, stopping the simulated test strategy corresponding to the unit test based on the second annotation.
Optionally, the creating a custom annotation for any simulated test strategy includes:
creating a custom annotation by a section file aiming at any simulation strategy; the section file comprises annotation parameters and annotation execution logic corresponding to the first annotation and the second annotation.
The application provides a unit testing device which is applied to a testing system; the test system is respectively configured with at least one simulation test strategy aiming at least one unit to be tested corresponding to the unit test; the test system maintains an IP whitelist for enabling control of the at least one simulated test strategy, the apparatus comprising:
the strategy configuration unit is used for responding to the unit test request and determining a simulation test strategy corresponding to the unit test before executing the unit test;
an address acquisition unit configured to acquire an IP address of a test device that performs the unit test;
and the address matching unit is used for matching the IP address with the IP address in the IP white list so as to perform starting control on the simulation test strategy and execute the unit test.
Optionally, the address matching unit is further configured to match the IP address with an IP address in the IP whitelist, and if the matching is successful, start a simulation test policy corresponding to the unit test; and otherwise, not starting a simulation test strategy corresponding to the unit test.
Optionally, the apparatus further includes:
and the strategy stopping unit is used for stopping the simulation test strategy corresponding to the unit test after the unit test is executed.
Optionally, the apparatus further includes:
an annotation creation unit for creating a custom annotation for any simulated test strategy, the custom annotation comprising a first annotation for starting the simulated test strategy and a second annotation for stopping the simulated test strategy.
Optionally, the annotation creation unit is further configured to initiate a simulation test policy corresponding to the unit test based on the first annotation before executing the unit test.
Optionally, the policy stopping unit is further configured to stop the simulated test policy corresponding to the unit test based on the second annotation after the unit test is performed.
Optionally, the annotation creation unit is further configured to create, for any simulation policy, a custom annotation through a section file; the section file comprises annotation parameters and annotation execution logic corresponding to the first annotation and the second annotation.
The application also provides electronic equipment, which comprises a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are connected with each other through the bus;
the memory stores machine readable instructions and the processor performs the method by invoking the machine readable instructions.
The present application also provides a computer readable storage medium storing machine readable instructions that when invoked and executed by a processor implement the above-described methods.
In the solution described in the above embodiment, by maintaining the IP address white list in advance, before performing the unit test, whether to start the simulation test policy is determined according to the IP address of the network device performing the unit test, which can effectively avoid the influence of different simulation test policies on other unit tests, and only when the specific device performs the specific unit test, the corresponding simulation test policy is started.
Drawings
Fig. 1 is a flow chart of a unit testing method according to an exemplary embodiment.
Fig. 2 is a schematic application diagram of a unit testing method according to an exemplary embodiment.
Fig. 3 is a hardware configuration diagram of an electronic device in which a unit testing apparatus is located according to an exemplary embodiment.
Fig. 4 is a block diagram of a unit testing apparatus provided by an exemplary embodiment.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than described in this specification. Furthermore, individual steps described in this specification, in other embodiments, may be described as being split into multiple steps; while various steps described in this specification may be combined into a single step in other embodiments. '
In performing unit testing, a developer typically configures different simulation test strategies for different units under test for simulating certain components or objects in different and alternative systems.
However, when the simulated test strategy is started, the simulated test strategy is likely to affect normal business logic or business processes, so some restrictions need to be added to the tested unit for starting the simulated test strategy to prevent the normal business processes or other tested units from being affected after the simulated test strategy is started.
In view of this, the present application proposes a technical solution for performing start control for a simulation test policy through an IP address whitelist based on the IP address whitelist.
When implemented, a simulation test strategy corresponding to the unit test can be determined in response to a unit test request before the unit test is executed;
acquiring an IP address of the network equipment for executing the unit test;
and matching the IP address with the IP address in the IP white list to perform starting control on the simulation test strategy and execute the unit test.
In the solution described in the above embodiment, by maintaining the IP address white list in advance, before performing the unit test, whether to start the simulation test policy is determined according to the IP address of the network device performing the unit test, which can effectively avoid the influence of different simulation test policies on other unit tests, and only when the specific device performs the specific unit test, the corresponding simulation test policy is started.
Referring to fig. 1, fig. 1 is a flow chart of a unit testing method according to an exemplary embodiment. The method may be applied to a test system.
A test system refers to a collection of tools, techniques, and procedures for performing software testing. It provides a structured and systematic way to verify the function, performance and quality of a software system. The test system may discover potential problems and errors and ensure that the software system meets the expected functional and performance requirements. By using an appropriate test system, the efficiency of the software development process can be improved and a reliable basis provided to ensure quality and stability of the software prior to delivery to the user.
In this specification, the test system configures at least one simulation test strategy for each unit under test corresponding to at least one unit test.
Unit testing is a test method in software development for verifying the smallest testable unit in a software system. These minimum testable units are typically separate units of code such as functions, methods or classes.
The unit under test refers to a specific code unit that is independently tested and verified when the unit test is performed. It may be a function, a method, a class, or even smaller code segments, depending on the structure and design of the software system under test.
Since the unit under test may depend on different components or objects, etc., the test system may configure at least one simulation test strategy for the unit under test.
The simulation test strategy, i.e., the Mock strategy, refers to the specific strategy and method that is adopted when performing the Mock test.
In unit testing, a common simulation strategy may include using Mock objects instead of dependencies of the system under test, such as databases, web services, or external AP I. By simulating expected behavior and responses, the test can be performed without actual dependencies and isolate instabilities in the test process.
Interactions between the system under test and the dependent items are simulated by defining the behavior of Mock objects. This includes defining return values, exception throws, callback functions, etc. to ensure the expected behavior of the system under test when interacting with the dependent items.
Simulation data is generated using Mock objects to simulate data returned by dependent items. This is very useful for testing data intensive scenarios, avoiding complex setup and preparation work, etc., that rely on real data sources.
In this specification, the test system may also maintain an IP whitelist for performing start-up control of the at least one simulated test strategy.
The IP address whitelist is a security measure for limiting access to or execution of specific operations only by the IP addresses listed in the whitelist. In this specification, when an IP address is added to the whitelist, the corresponding simulation test strategy can be initiated.
The method may comprise the steps of:
step 102, in response to a unit test request, determining a simulation test strategy corresponding to the unit test before executing the unit test.
In this specification, a developer may determine tasks performed by a unit under test and its dependencies on other components or systems based on the function and behavior of the unit under test. At the same time, dependencies between the unit under test and other components or services may be further determined. If the unit under test relies on external resources (e.g., databases, file systems, APIs, etc.), then it may be selected to simulate those dependencies, creating at least one simulated test strategy for the unit under test.
The test system may respond to a unit test request and determine a unit under test corresponding to the unit test before executing the unit test, and may further determine a pre-configured simulation test strategy corresponding to the unit under test.
Step 104, obtaining the IP address of the test equipment for executing the unit test.
The test system may obtain the IP address of the test device currently performing the unit test. For example, the IP address information may be found in a network setup or configuration interface of the test equipment. The test equipment may also be scanned and its IP address obtained by using a network scanning tool (such as Nmap, angry IP Scanner, etc.), which is not particularly limited in this specification.
In the maven project developed based on java language, the test system can acquire all interfaces related to the network from the network interface object through a network interface. Further, all elements of the network related interface can be traversed and acquired by a nextElement () method, and network address information in the elements can be acquired by a getInetAddress () method.
And step 106, matching the IP address with the IP address in the IP white list to perform starting control on the simulation test strategy and execute the unit test.
In this specification, the test system may compare the IP address of the test device with each IP address in the IP whitelist after acquiring the IP address of the test device. Based on the result of the comparison, it is determined whether the IP address of the test device matches any IP address in the whitelist. If the IP address of the test device matches any of the IP addresses in the whitelist, a corresponding simulated test strategy may be initiated and the unit test performed.
Otherwise, if the IP address of the test device does not match any IP address in the white list, it indicates that after the test device starts the corresponding simulation test policy, it may affect the testing of other units in the test system, so that the corresponding simulation policy cannot be started.
In one embodiment, the test system may stop the simulated test strategy corresponding to the unit test after performing the unit test.
By starting the simulation test strategy before executing the unit test and stopping the simulation test strategy after executing the unit test, the impact of the simulation test strategy on the test system and other test units can be minimized.
In one embodiment, custom annotations may be created for any simulated test strategy. The custom annotations may include a first annotation that initiates the simulated test strategy and a second annotation that stops the simulated test strategy.
Custom annotations are one way to use metadata in the Java programming language. Additional information can be added to elements such as classes, methods, fields, etc. in the program through custom annotations, which are processed at runtime to implement specific logic or functionality.
In this specification, a first annotation for launching a simulated test strategy may be added before the code corresponding to the simulated test strategy, whereby after the simulated test strategy is configured onto the unit test, the corresponding simulated test strategy may be launched directly based on the first annotation.
Meanwhile, a second annotation for stopping the simulation test strategy may be added after the code corresponding to the simulation test strategy, and thus, after the unit test execution is completed, the corresponding simulation test strategy may be stopped directly based on the second annotation.
In one embodiment, custom annotations may be created by a section file. The section file comprises annotation parameters and annotation execution logic corresponding to the first annotation and the second annotation.
The cut plane (Aspect) is a modular way for transecting points of interest (Cross-cutting centers). The cut plane may be provided with processing logic that transects the point of interest by separating specific functions and behaviors from the application without modifying the source code.
Custom annotations (Custom Annotation) are one mechanism for appending additional information to a program element. Custom annotations allow developers to mark specific elements in code and specific logic or functionality may be implemented based on these annotations.
The relationship between the facet and the custom annotation is established by facet-oriented programming (AOP). AOP is a programming paradigm that can use a facet to capture and process transection points of interest, and custom annotations can be used as marker points to determine the location of application of the facet.
Typically, a framework (e.g., spring framework) implementing AOP would allow developers to use custom annotations to mark where the section needs to be applied. In the AOP framework, the application point of a facet is declared by defining a facet class and using custom annotations.
In practice, a profile @ pinterface may be created, while a first annotation @ berpore (mockstart (mockid)) is created in the profile, where the first annotation is used to initiate a simulated test strategy. And a second annotation @ after (mockstop (mockid) "), wherein the second annotation is used to stop simulating the test strategy.
In the solution described in the above embodiment, by maintaining the IP address white list in advance, before performing the unit test, whether to start the simulation test policy is determined according to the IP address of the network device performing the unit test, which can effectively avoid the influence of different simulation test policies on other unit tests, and only when the specific device performs the specific unit test, the corresponding simulation test policy is started.
Referring to fig. 2, fig. 2 is a schematic diagram illustrating an application of a unit testing method according to an exemplary embodiment.
As shown in fig. 2, the test system may obtain an IP address of the test device in response to the unit test request, and match the IP address with a preset IP whitelist.
If the matching is successful, a simulated test strategy corresponding to the unit test may be initiated and the unit test may be further performed. After the unit test execution is completed, the simulation test strategy is stopped.
If the matching fails, the simulation test strategy is not started, the unit test is exited, and the subsequent processing is waited.
The present specification also provides an embodiment of the unit testing device, corresponding to the embodiment of the unit testing method described above.
Referring to fig. 3, fig. 3 is a hardware configuration diagram of an electronic device in which a unit testing apparatus is shown in an exemplary embodiment. At the hardware level, the device includes a processor 302, an internal bus 304, a network interface 306, memory 308, and non-volatile storage 310, although other hardware required for the service is possible. One or more embodiments of the present description may be implemented in a software-based manner, such as by the processor 303 reading a corresponding computer program from the non-volatile storage 310 into the memory 308 and then running. Of course, in addition to software implementation, one or more embodiments of the present disclosure do not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
Referring to fig. 4, fig. 4 is a block diagram of a unit testing apparatus according to an exemplary embodiment. The unit testing device can be applied to the electronic equipment shown in fig. 3 to realize the technical scheme of the specification. The unit testing device may include:
a policy configuration unit 402, configured to determine, in response to a unit test request, a simulated test policy corresponding to the unit test before executing the unit test;
an address acquisition unit 404 for acquiring an IP address of a test device that performs the unit test;
and an address matching unit 406, configured to match the IP address with an IP address in the IP whitelist, perform start control for the simulation test policy, and perform the unit test.
In this embodiment, the address matching unit is further configured to match the IP address with an IP address in the IP whitelist, and if the matching is successful, start a simulation test policy corresponding to the unit test; and otherwise, not starting a simulation test strategy corresponding to the unit test.
In this embodiment, the apparatus further includes:
and the strategy stopping unit is used for stopping the simulation test strategy corresponding to the unit test after the unit test is executed.
In this embodiment, the apparatus further includes:
an annotation creation unit for creating a custom annotation for any simulated test strategy, the custom annotation comprising a first annotation for starting the simulated test strategy and a second annotation for stopping the simulated test strategy.
In this embodiment, the annotation creation unit is further configured to initiate a simulation test policy corresponding to the unit test based on the first annotation before executing the unit test.
In this embodiment, the policy stopping unit is further configured to stop the simulated test policy corresponding to the unit test based on the second annotation after the unit test is performed.
In this embodiment, the annotation creation unit is further configured to create, for any simulation policy, a custom annotation through a section file; the section file comprises annotation parameters and annotation execution logic corresponding to the first annotation and the second annotation.
The implementation process of the functions and roles of each unit in the above device is specifically shown in the implementation process of the corresponding steps in the above method, and will not be described herein again.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are illustrative only, in that the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present description. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
User information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in this specification are both information and data authorized by the user or sufficiently authorized by the parties, and the collection, use and processing of relevant data requires compliance with relevant laws and regulations and standards of the relevant country and region, and is provided with corresponding operation portals for the user to choose authorization or denial.
The present specification also provides an embodiment of a computer-readable storage medium. The computer readable storage medium stores machine readable instructions that, when invoked and executed by a processor, implement the unit testing method provided by any of the embodiments in this specification.
The computer readable storage medium provided by the embodiments of the present specification may include, but is not limited to, any type of disk including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks, ROMs (Read-Only memories), RAMs (Random Access Memory, random access memories), EPROMs (Erasable Programmable Read-Only memories), EEPROMs (Electrically Erasable Programmable Read-Only memories), flash memories, magnetic cards, or optical fiber cards. That is, a readable storage medium includes a readable medium that can store or transfer information.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, read only compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by the computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in one or more embodiments of the present description to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
The foregoing description of the preferred embodiment(s) is (are) merely intended to illustrate the embodiment(s) of the present invention, and it is not intended to limit the embodiment(s) of the present invention to the particular embodiment(s) described.

Claims (16)

1. A unit testing method is applied to a testing system; the test system is respectively configured with at least one simulation test strategy aiming at least one unit to be tested corresponding to the unit test; the test system maintains an IP whitelist for initiating control of the at least one simulated test strategy, the method comprising:
in response to a unit test request, determining a simulation test strategy corresponding to the unit test before executing the unit test;
acquiring an IP address of test equipment for executing the unit test;
and matching the IP address with the IP address in the IP white list to perform starting control on the simulation test strategy and execute the unit test.
2. The method of claim 1, the matching the IP address with an IP address in the IP whitelist to enable control for the simulated test policy, comprising:
matching the IP address with the IP address in the IP white list, and if the matching is successful, starting a simulation test strategy corresponding to the unit test; and otherwise, not starting a simulation test strategy corresponding to the unit test.
3. The method of claim 2, the method further comprising:
after the unit test is performed, the simulation test strategy corresponding to the unit test is stopped.
4. The method of claim 1, the method further comprising:
for any simulated test strategy, a custom annotation is created, the custom annotation comprising a first annotation for starting the simulated test strategy and a second annotation for stopping the simulated test strategy.
5. The method of claim 4, the launching a simulation test strategy corresponding to the unit test case prior to performing the unit test, comprising:
before executing the unit test, a simulated test strategy corresponding to the unit test is initiated based on the first annotation.
6. The method of claim 4, stopping the simulated test strategy after the unit test execution is complete, comprising:
after the unit test is performed, stopping the simulated test strategy corresponding to the unit test based on the second annotation.
7. The method of claim 4, the creating custom annotations for any simulated test strategy, comprising:
creating a custom annotation by a section file aiming at any simulation strategy; the section file comprises annotation parameters and annotation execution logic corresponding to the first annotation and the second annotation.
8. A unit testing device is applied to a testing system; the test system is respectively configured with at least one simulation test strategy aiming at least one unit to be tested corresponding to the unit test; the test system maintains an IP whitelist for enabling control of the at least one simulated test strategy, the apparatus comprising:
the strategy configuration unit is used for responding to the unit test request and determining a simulation test strategy corresponding to the unit test before executing the unit test;
an address acquisition unit configured to acquire an IP address of a test device that performs the unit test;
and the address matching unit is used for matching the IP address with the IP address in the IP white list so as to perform starting control on the simulation test strategy and execute the unit test.
9. The apparatus of claim 8, the address matching unit further to match the IP address with an IP address in the IP whitelist, and if matching is successful, initiate a simulated test policy corresponding to the unit test; and otherwise, not starting a simulation test strategy corresponding to the unit test.
10. The apparatus of claim 9, the apparatus further comprising:
and the strategy stopping unit is used for stopping the simulation test strategy corresponding to the unit test after the unit test is executed.
11. The apparatus of claim 8, the apparatus further comprising:
an annotation creation unit for creating a custom annotation for any simulated test strategy, the custom annotation comprising a first annotation for starting the simulated test strategy and a second annotation for stopping the simulated test strategy.
12. The apparatus of claim 11, the annotation creation unit further to initiate a simulated test strategy corresponding to the unit test based on the first annotation prior to performing the unit test.
13. The apparatus of claim 11, the policy stopping unit further to stop a simulated test policy corresponding to the unit test based on a second annotation after the unit test is performed.
14. The apparatus of claim 11, the annotation creation unit further configured to create a custom annotation from a section file for any simulation policy; the section file comprises annotation parameters and annotation execution logic corresponding to the first annotation and the second annotation.
15. An electronic device comprises a communication interface, a processor, a memory and a bus, wherein the communication interface, the processor and the memory are connected with each other through the bus;
the memory stores machine readable instructions, and the processor performs the method of any of claims 1-7 by invoking the machine readable instructions.
16. A computer readable storage medium storing machine readable instructions which, when invoked and executed by a processor, implement the method of any one of claims 1-7.
CN202311276439.2A 2023-09-28 2023-09-28 Unit test method, unit test device, electronic equipment and readable storage medium Pending CN117331830A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311276439.2A CN117331830A (en) 2023-09-28 2023-09-28 Unit test method, unit test device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311276439.2A CN117331830A (en) 2023-09-28 2023-09-28 Unit test method, unit test device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN117331830A true CN117331830A (en) 2024-01-02

Family

ID=89294719

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311276439.2A Pending CN117331830A (en) 2023-09-28 2023-09-28 Unit test method, unit test device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN117331830A (en)

Similar Documents

Publication Publication Date Title
CN109800258B (en) Data file deployment method, device, computer equipment and storage medium
TWI575397B (en) Point-wise protection of application using runtime agent and dynamic security analysis
US20160283357A1 (en) Call stack relationship acquiring method and apparatus
US10353809B2 (en) System and method for executing integration tests in multiuser environment
Shahriar et al. Testing of memory leak in android applications
CN110968437A (en) Method, device, equipment and medium for parallel execution of single contract based on Java intelligent contract
US20150143342A1 (en) Functional validation of software
CN111124870A (en) Interface testing method and device
US20130254832A1 (en) Security Protection Domain-Based Testing Framework
US20130305228A1 (en) Reducing application startup time through algorithm validation and selection
CN111221721B (en) Automatic recording and executing method and device for unit test cases
CN113094252A (en) Test case generation method and device, computer equipment and storage medium
CN113032202B (en) Chip verification method, system, device, computer equipment and storage medium
CN110263548A (en) A kind of web application hole detection rule generating method, terminal and storage medium
CN110471828B (en) Operating system testing method, device and equipment thereof
CN115617668A (en) Compatibility testing method, device and equipment
CN117331830A (en) Unit test method, unit test device, electronic equipment and readable storage medium
CN114691496A (en) Unit testing method, unit testing device, computing equipment and medium
CN114817047A (en) Compiler test method, case generation method and device and instruction storage structure
CN110297625B (en) Application processing method and device
CN113626333A (en) Automatic interface testing method and device
CN113626307A (en) Data verification method and device based on K8S container platform
CN112817663B (en) SECCOMP rule acquisition method and device for application program
CN109446091B (en) Business entity object testing method and device
CN112882720B (en) Compiling method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination