Software testing method, terminal equipment and storage medium

By automatically injecting dependent scenario data using fake class and target business information in software unit testing, the problem of high maintenance costs of mock service changes in the existing technology is solved, and more efficient and accurate unit testing is achieved, reducing R&D learning costs and feedback cycles.

CN120123219APending Publication Date: 2025-06-10ZTE CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311623618.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-29
Publication Date
2025-06-10

AI Technical Summary

Technical Problem

In the existing software unit testing methods, changes in mock services will affect existing test cases, resulting in high operating and maintenance costs of test cases and requires writing a large number of mock classes, resulting in a long writing cycle and result feedback cycle.

Method used

By obtaining the fake class and target business information of the software to be tested, determine the target test cases and target dependency service classes, and determine the target fake class corresponding to the target dependency service class based on the dependent service class and the fake class, and run the target test cases based on the target fake class to realize the testing of the software to be tested.

Benefits of technology

It realizes automatic injection of dependent scenario data, reduces R&D learning costs, shortens the software development feedback cycle, and reduces the amount of mock classes written in unit tests, improving the efficiency and accuracy of the test.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120123219A_ABST
    Figure CN120123219A_ABST
Patent Text Reader

Abstract

The invention provides a software testing method, terminal equipment and a storage medium, and belongs to the technical field of software testing. The software testing method comprises the steps of obtaining a fake class of software to be tested and corresponding target business information, wherein the target business information comprises an identifier of a dependent service class corresponding to the fake class; determining a target test case of the to-be-tested software and a target dependency service class corresponding to the target test case, wherein the target test case is used for performing unit testing on the to-be-tested software; and determining a target fake class corresponding to the target dependency service class according to the identifier of the dependency service class and the fake class, and running the target test case based on the target fake class to test the to-be-tested software to obtain a test result of the to-be-tested software. According to the method, the authenticity and effectiveness of various test case scenes can be met, the software research and development problem feedback period can be shortened, and the software research and development accuracy and efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software testing, and in particular, to a software testing method, a terminal device, and a storage medium. Background Art

[0002] With the popularization of the microservice architecture in the industry, the microservice architecture is more frequently used in software development. Before the software goes online, a series of tests are required to determine whether the software meets the online requirements. Currently, unit testing of software mainly provides business scenario data through the mock service method to achieve testing. For example, running preset scenario-based test cases. When the mock service changes, it will affect the running of the existing test cases, and the operation and maintenance cost of the test cases is high. Moreover, if the test cases involve many dependent services, a large number of mock classes need to be written to implement the dependent services, resulting in a long writing cycle and result feedback cycle. Summary of the Invention

[0003] The present application provides a software testing method, a terminal device, and a storage medium, aiming to achieve automatic injection of data during software testing, ensure software development quality, reduce software development costs, and shorten the software development feedback cycle.

[0004] In a first aspect, the present application provides a software testing method, including:

[0005] Obtain the fake class of the software to be tested and the corresponding target business information, where the target business information includes the identifier of the dependent service class corresponding to the fake class;

[0006] Determine the target test case of the software to be tested and the target dependent service class corresponding to the target test case, where the target test case is used for unit testing of the software to be tested;

[0007] Determine the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and run the target test case based on the target fake class to test the software to be tested, so as to obtain the test result of the software to be tested.

[0008] In a second aspect, the present application further provides a terminal device, where the terminal device includes a processor, a memory, a computer program stored on the memory and executable by the processor, and a data bus for realizing connection communication between the processor and the memory. When the computer program is executed by the processor, the steps of any software testing method provided in the specification of the present invention are implemented.

[0009] In a third aspect, the present application also provides a storage medium for computer-readable storage. The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any software testing method provided in the specification of the present invention.

[0010] The present application provides a software testing method, a terminal device, and a storage medium. The present application obtains the fake class of the software to be tested and the corresponding target service information, where the target service information includes the identifier of the dependent service class corresponding to the fake class, and determines the target test case of the software to be tested and the target dependent service class corresponding to the target test case. Then, according to the identifier of the dependent service class and the fake class, the target fake class corresponding to the target dependent service class is determined, and the target test case is run based on the target fake class to implement the testing of the software to be tested and obtain the test result of the software to be tested. By using the target fake class to implement the real scenario data of the dependency and other microservices of the dependency, there is no need to write a large number of mock classes. Moreover, when running the target test case, it can meet the authenticity and effectiveness of various scenarios, and the injection method of the target fake class is automatic injection. Therefore, when implementing coding, coders can better design test cases according to the scenario and quickly implement them in the coding process, reducing the R & D learning cost and shortening the problem feedback cycle. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0012] Figure 1 It is a schematic diagram of the relationship between the microservices and implementation classes of the software in the software testing method provided by an embodiment of the present application;

[0013] Figure 2 It is a flowchart of the steps of the software testing method provided by an embodiment of the present application;

[0014] Figure 3 It is a flowchart of the software testing method provided by an embodiment of the present application;

[0015] Figure 4 It is a flowchart of the software testing method provided by another embodiment of the present application;

[0016] Figure 5 It is a flowchart of the software testing method provided by yet another embodiment of the present application;

[0017] Figure 6A structural schematic block diagram of a terminal device provided by an embodiment of the present application. Detailed implementation manners

[0018] Next, the technical solutions in the present application will be clearly and completely described in conjunction with the accompanying drawings in the present application. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0019] The flowcharts shown in the accompanying drawings are only illustrative, and do not necessarily include all contents and operations / steps, nor do they necessarily need to be executed in the described order. For example, some operations / steps can be decomposed, combined or partially merged, so the actual execution order may be changed according to the actual situation.

[0020] It should be understood that the terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include the plural forms.

[0021] The present application provides a software testing method, a terminal device and a storage medium. Among them, the software testing method can be applied to a mobile terminal, and the mobile terminal can be an electronic device such as a mobile phone, a tablet computer, a notebook computer, a desktop computer, etc.

[0022] Exemplarily, in the services of business development in software development, there are multiple service dependencies, including common services, other basic services in the system, and self-developed basic services, such as Figure 1 as shown Figure 1A schematic diagram of the relationship between the microservices and implementation classes of the software in the software testing method provided by an embodiment of the present application. As shown in the figure, the service / class on the far left in the figure (such as restful result data, timer, service startup, message monitored by kafka) relies on the service / class combination and unification provided by other businesses to realize business functions, and provides services to the outside through external scheduling / interface encapsulation; wherein, the dependency injection form is active injection and hermit injection, and the Service class in the figure includes but is not limited to its own business class, calling the remaining service interfaces, database, kafka, es, ftp. In the software development process, it is necessary to test the software to confirm whether the software can run the above-mentioned microservices and / or classes normally, and when testing the software, the quality of software development is generally guaranteed by the test layering method, that is, system testing, functional testing and unit testing; through test layering, from code implementation logic to functional interaction and dependence on software systems and other aspects, the functions and usage scenarios of the software are fully covered, thereby ensuring that the developed software is truly available. This application realizes the authenticity and effectiveness of various scenarios when designing and implementing the use case of unit testing through improvements to unit testing, and reduces the cost of research and development learning and shortens the problem feedback cycle.

[0023] It should be understood that in functional testing, the entire business delivery function and scenario are tested by actually deploying real business services and relying on microservices. Use cases are designed through functional business scenarios, and then the functional input of the scenario is constructed to verify the correctness of its return to ensure the functional correctness and accuracy of software development.

[0024] In the software testing method provided by the present application, the dependent service class is loaded into the container of the test environment through the target business information before the target test case of the unit test is run, ensuring that the real data in the functional test can be called when the target test case is run, and realizing automatic dependency injection, thereby improving the reliability, accuracy, effectiveness and integrity of the target test case of the unit test in the software development process. In addition, since the test case of the scenario is sunk to the stage of unit testing, the coding implementation can quickly verify the correctness of its implementation, and through the rapid feedback of the actual results of the target test case in the unit test, the feedback cycle of software development result verification is shortened.

[0025] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0026] Please refer to Figure 2 , Figure 2 A flowchart of the steps of a software testing method provided in one embodiment of the present application.

[0027] like Figure 2As shown, the software testing method includes steps S101 to S103.

[0028] Step S101: Obtain the fake class of the software to be tested and the corresponding target business information, where the target business information includes the identifier of the dependent service class corresponding to the fake class.

[0029] Among them, the software to be tested includes, but is not limited to, the software used on terminal devices, such as apps on mobile phones and / or control system software on devices. The fake class of the software to be tested can simulate the dependent service and / or the interface of the dependent service, so as to fake the real behavior data into the running environment of unit testing.

[0030] Exemplarily, the target business information includes the identifier of the dependent service class required by the fake class. After determining the dependent service class that the software to be tested needs to verify, the corresponding fake class can be determined through the target business information to implement the behavior of the fake class simulating the dependent service.

[0031] In the specific implementation process, create and write the fake class of the dependent service class to override the dependent service method through the fake class, so as to directly return the real data and simulate the behavior of the dependent service. After writing the fake class of the service class, scan the external dependencies and / or common service classes stored in all paths under the project package, and establish the replacement relationship between the fake class and the dependent service by determining the identifier of the dependent service class required by the fake class to obtain the business information. It can be understood that the above process of writing the fake class and determining the business information can be pre-processed, so that when testing the software to be tested, the fake class of the software to be tested and the corresponding target business information can be directly obtained.

[0032] Step S102: Determine the target test case of the software to be tested and the target dependent service class corresponding to the target test case, where the target test case is used to perform unit testing on the software to be tested.

[0033] Exemplarily, multiple test cases are obtained by manually writing test cases, so as to determine the target test case from multiple test cases when the software to be tested needs to test the corresponding unit function. Among them, the scenario design and functional acceptance of the target test case ensure that the logic finally implemented by the target test case can meet the real scenario results after the external interface is encapsulated, reduce the joint debugging time of multi-module interaction, further shorten the software development time and improve the software development quality.

[0034] It is understandable that different dependent service classes need to be used in different test cases to achieve the purpose of testing different functions of the software. Therefore, after determining the target test case to be run, it is necessary to determine the target dependent service class corresponding to the target test case, that is, to determine the target dependent service class required when running the target test case.

[0035] Step S103: Determine the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and run the target test case based on the target fake class to test the software to be tested, so as to obtain the test result of the software to be tested.

[0036] Exemplarily, according to the correspondence between the fake class in the target business information and the identifier of the dependent service class, determine the target fake class corresponding to the target dependent service class. It is understandable that the target fake class can simulate the external service dependency behavior of the target dependent service class. Therefore, running the target test case through the target fake class can obtain the running result of the target test case, and thus obtain the test result of the software to be tested according to the running result of the target test case.

[0037] It should be noted that to implement the scenario-based use cases in the functional test in the unit test development environment, it is necessary to solve the return of the microservices or interfaces that are actually dependent during the scenario test of the functional test cases. Through the fake class and the identifier of the dependent service class required by the fake class in the target business information, the automatic loading of the basic service can be realized, and in the specific test process, various loading methods such as manual loading, unified modular loading of public services, and data-driven can also be realized to complete the preloading of the dependent service before running the target test case; and this software testing method also provides a unified encapsulation acceptance interface for links such as use case writing and use case result verification, ensuring the convenience of coders when implementing use case writing, reducing the learning cost, improving the convenience of use case implementation, and thus improving the quality and efficiency of software development.

[0038] In some embodiments, determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and running the target test case based on the fake class to test the software to be tested, obtaining the test result of the software to be tested, includes: determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and calling the test data corresponding to the software to be tested when performing functional testing or calling the software to be tested when performing system testing according to the target test case; running the target test case based on the target fake class and the test data to test the software to be tested, so as to obtain the test result of the software to be tested.

[0039] Exemplarily, when performing unit testing on the software to be tested with the target test case, the entry of the software to be tested when executing functional testing or the entry of the software to be tested when executing system testing is called according to the target test case to enter the unit testing, and during the unit testing process, the external service behavior of the software to be tested is simulated based on the target fake class to obtain the corresponding test result.

[0040] In some embodiments, determining the target fake class corresponding to the target dependent service class based on the identifier of the dependent service class and the fake class includes: when running to access an external interface or an external dependent service, determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, so that the target fake class replaces the target dependent service class to run the target test case.

[0041] In the specific implementation process, during the execution of the unit testing process, when running to the situation of accessing an external interface or an external dependency, the established fake framework determines the target fake class corresponding to the target dependent service class required by the target test case according to the relationship between the identifier of the dependent service class in the target service information and the fake class, and replaces the target dependent service class in the target test case running environment with the target fake class to achieve the purpose of simulating the external service behavior.

[0042] Please refer to Figure 3 , Figure 3 which is the flowchart of the software testing method provided by an embodiment of the present application. As Figure 3 shown and hereinafter, a use case is created with the target test case as the target task to illustrate the specific implementation process of the unit testing.

[0043] Exemplarily, write the target test case for unit testing: Create target task_Creation successful_Return successful. It can be understood that this target test case is used to verify whether the software to be tested can create a target task, where the target task includes but is not limited to real-time tasks.

[0044] In some embodiments, determining the target fake class corresponding to the target dependent service class based on the identifier of the dependent service class and the fake class, and calling the corresponding test data of the software to be tested when executing functional testing or calling the software to be tested when executing system testing according to the target test case includes: when the target test case is a target task creation use case and the target dependent service class is a real-time task microservice, determining the target fake class as the FakeRealTask class according to the identifier of the dependent service class and the fake class, and calling the task creation test data corresponding to the software to be tested when executing functional testing.

[0045] Exemplarily, when the target test case is a test case for creating a target task, a FakeRealTask class is created to simulate the create interface of RealTask, and the real entry data of the functional test is used to simulate the functional data for the performance microservice to create a task.

[0046] In some embodiments, the target test case is run based on the target fake class and test data to test the software under test, and the test result of the software under test is obtained, including: performing a creation test of the target task on the software under test based on the FakeRealTask class and the task creation test data, and determining the test result of the software under test according to the creation test result of the target task.

[0047] Exemplarily, during the process of running the target test case, the entry provided by the performance microservice is called: createRealTask of RealTaskService; after the fake framework is initialized, all classes in the project package path are scanned and loaded, and the interface class of RealTask is replaced with FakeRealTask to perform the creation test of the target task, and the creation test result of the target task is obtained, so as to determine the test result of the software under test through the creation test result of the target task.

[0048] In some embodiments, determining the test result of the software under test according to the creation test result of the target task includes: obtaining the target task creation data obtained by the software under test after performing the functional test; when the similarity between the creation test result of the target task and the target task creation data is greater than or equal to the target threshold, determining that the software under test passes the test.

[0049] Exemplarily, after the software under test completes the creation test of the target task and obtains the creation test result of the target task, the creation test result of the target task is verified by the target task creation data obtained by the software under test in the functional test.

[0050] Specifically, the target task creation data includes the operation result of creating the target task in the actual functional test, that is, when the creation test result of the target task is the same as the operation result of creating the target task in the actual functional test, it is determined that the software under test passes the creation test of the target task. Otherwise, it is determined that the software under test fails this test.

[0051] Through the test process provided by the above embodiments, the unit test has completed the functional test effect of task creation, completed the unit test of the software to be tested, and during this actual test process, it took 5 minutes to write test cases and 0.56 seconds to run the test cases, greatly shortening the duration of the test. It should be noted that the time taken to write test cases and run test cases mentioned above are the data measured in the actual application scenario, and the time taken may change in other actual scenarios.

[0052] Please refer to Figure 4 , Figure 4 which is a flowchart of a software testing method provided by another embodiment of the present application. As Figure 4 shown and described below, taking the target test case as the network element deletion test case, the specific implementation process of the unit test will be described.

[0053] In this target test case, when the configuration microservice listens to the kafka message that needs to delete the network element, it executes the action of deleting the network element. Among them, the kafka message belongs to the public service, and the KafkaClientService class of the kafka public service is used to access the client of kafka, and the Consumer interface is used to pull and consume the kafka message.

[0054] In some embodiments, according to the identifier of the dependent service class and the fake class, the target fake class corresponding to the target dependent service class is determined, and according to the target test case, the test data corresponding to the software to be tested when performing functional testing or the software to be tested when performing system testing is called, including: when the target test case is the network element deletion test case and the target dependent service class is the kafka public service class, determining the target fake class according to the identifier of the dependent service class and the fake class includes the FakeKafkaClientService class and the FakeConsumer class, and calling the target network element and the kafka message corresponding to the software to be tested when performing system testing.

[0055] Exemplarily, when the target test case is the network element deletion test case, determining the target dependent service class: the target fake class corresponding to the kafka public service class includes at least the FakeKafkaClientService class and the FakeConsumer class, and calling the target network element and the kafka message corresponding to the software to be tested when performing system testing.

[0056] In a specific implementation process, write a network element deletion test case: given_receiving a Kafka message_when_deleting a network element_then_deleting the IP records related to the network element. Create a FakeKafkaClientService class that inherits from the KafkaClientService class to simulate sending Kafka messages; create a FakeConsumer class that implements the Consumer interface to simulate consuming Kafka messages; and call the target network element and Kafka message corresponding to the software under test when performing system testing. After determining that the target test case is the network element deletion test case, obtain the above information to run the network element deletion test case.

[0057] In some embodiments, the software under test is tested by running the target test case based on the target fake class and test data, and the test result of the software under test is obtained, including: performing a deletion test of the target network element on the software under test based on the FakeKafkaClientService class, the FakeConsumer class, and the Kafka message, and determining the test result of the software under test according to the deletion test result of the target network element.

[0058] In a specific implementation process, run the network element deletion test case. Construct the target network element by obtaining the information corresponding to the real target network element in the system test, so as to achieve the purpose of simulating the construction of the target network element; send the real Kafka message obtained from the system test to achieve the purpose of simulating the sending of the Kafka message for deleting the target network element; initialize the fake framework, use the FakeKafkaClientService class to replace the KafkaClientService class in the running environment, and use the FakeConsumer class to replace the Consumer class in the running environment, so as to implement the deletion processing of the target network element through the FakeKafkaClientService class and the FakeConsumer class.

[0059] In some embodiments, the test result of the software under test is determined according to the deletion processing result of the target network element, including: obtaining the target network element data obtained by the software under test after performing system testing; and determining that the software under test passes the test when the similarity between the deletion test result of the target network element and the data of the target network element is greater than or equal to the target threshold.

[0060] Exemplarily, after obtaining the deletion test result of the target network element by completing the target network element deletion test case, the deletion test result of the target network element is verified by the running result of the software under test in the system test. Specifically, when the similarity between the deletion test result of the target network element and the data of the target network element is greater than or equal to the target threshold, it is determined that the software under test passes the network element deletion test; otherwise, it is determined that the software under test fails the network element deletion test.

[0061] Through the test process provided by the above embodiments, the unit test has completed the functional test effect of network element deletion. During this test process, it took 10 minutes to write test cases and 1.25 seconds to run the test cases, greatly shortening the duration of the test.

[0062] In some embodiments, obtaining target service information includes: when there is historical test information, determining whether there is information identical to the target service information in the historical test information; in the case where there is information identical to the target service information, obtaining the target service information from the historical test information.

[0063] Exemplarily, when testing the software to be tested, it is necessary to run all test sets in the microservice project. When running tests where a microservice depends on other microservices (such as creating a target task) and a microservice depends on a common service (kafka), corresponding test cases will be obtained in each unit test suite, and all classes in all projects will be scanned and loaded during the initialization of the fake framework.

[0064] Please refer to Figure 5 , Figure 5 which is a flowchart of the software testing method provided by another embodiment of the present application.

[0065] In the specific implementation process, when there are multiple test cases in the test set of the microservice project, it is necessary to run all test cases to complete the test of the software to be tested. Specifically, when running the first test case (for example, running the target task creation test case provided by the above embodiment), the fake framework initializes, scans, and loads all classes in the project, caches them, and generates historical test information. Thus, when completing the running of the first test case and then running the second test case (the second test case such as the network element deletion test case provided by the above embodiment), and if the target service information required by the second test case exists in the cached data (historical test information), there is no need to repeatedly load the classes in the project, and the cached data is directly used when running the second test case. According to the above rules, continue to run the (N + 1)-th test case (N is a natural number greater than 1) until all test cases in the test set are completed. By obtaining the target service information from the historical test information, the number of times of information scanning and loading is reduced, the efficiency of running test cases is improved, thereby shortening the test time of the software to be tested and improving the test efficiency.

[0066] The software testing method provided by the above embodiments realizes automatic injection, can truly simulate the scenario data of public services and dependent services, enables the unit test to achieve the automation effect of functional testing, reduces the R & D learning cost, improves the protection effect, and provides a friendly foundation for the TDD R & D mode. And it realizes end-to-end unit testing from the entrance. All products use the same set of SDKs, without the need for customized development, non-invasive, without generating quality risks, greatly reducing the code volume of unit testing, lowering the technical threshold of unit testing, without mocks throughout the process, and without the need to learn various complex mock frameworks (PowerMockito, Mockito, JMock, etc.), which can perfectly replace most of the functional tests and friendly support code refactoring. It ensures the R & D quality of the software and improves the R & D efficiency of the software.

[0067] Please refer to Figure 6 , Figure 6 which is a schematic block diagram of the structure of a terminal device provided by an embodiment of the present application.

[0068] As Figure 6 shown, the terminal device 300 includes a processor 301 and a memory 302. The processor 301 and the memory 302 are connected through a bus 303, and this bus is, for example, an I2C (Inter - integrated Circuit) bus.

[0069] Specifically, the processor 301 is used to provide computing and control capabilities to support the operation of the entire terminal device. The processor 301 can be a central processing unit (CPU), and this processor 301 can also be other general - purpose processors, digital signal processors (DSPs), application - specific integrated circuits (ASICs), field - programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general - purpose processor can be a microprocessor or this processor can also be any conventional processor, etc.

[0070] Specifically, the memory 302 can be a Flash chip, read - only memory (ROM), disk, optical disc, USB flash drive, or mobile hard disk, etc.

[0071] Those skilled in the art can understand that Figure 6The structure shown is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the terminal device to which the solution of this application is applied. Specifically, the server may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0072] Wherein, the processor is used to run a computer program stored in the memory, and when executing the computer program, implement any one of the software testing methods provided by this application.

[0073] In one embodiment, the processor is used to run a computer program stored in the memory, and when executing the computer program, implement the following steps:

[0074] Obtain the fake class of the software to be tested and the corresponding target service information, where the target service information includes the identifier of the dependent service class corresponding to the fake class;

[0075] Determine the target test case of the software to be tested and the target dependent service class corresponding to the target test case, where the target test case is used to perform unit testing on the software to be tested;

[0076] Determine the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and run the target test case based on the target fake class to test the software to be tested, and obtain the test result of the software to be tested.

[0077] In one embodiment, when the processor implements determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and running the target test case based on the target fake class to test the software to be tested, and obtaining the test result of the software to be tested, it is used to implement:

[0078] Determine the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and call the test data corresponding to the software to be tested when performing function testing or call the software to be tested when performing system testing according to the target test case;

[0079] Run the target test case based on the target fake class and the test data to test the software to be tested, and obtain the test result of the software to be tested.

[0080] In one embodiment, when the processor implements determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and calling the test data corresponding to the software under test when performing a function test or calling the software under test when performing a system test according to the target test case, it is used to implement:

[0081] When the target test case is a use case for creating a target task and the target dependent service class is a real-time task microservice, determine that the target fake class is the FakeRealTask class according to the identifier of the dependent service class and the fake class, and call the task creation test data corresponding to the software under test when performing a function test.

[0082] In one embodiment, when the processor implements testing the software under test by running the target test case based on the target fake class and the test data to obtain the test result of the software under test, it is used to implement:

[0083] Perform the creation test of the target task on the software under test based on the FakeRealTask class and the task creation test data, and determine the test result of the software under test according to the creation test result of the target task.

[0084] In one embodiment, when the processor implements determining the test result of the software under test according to the creation test result of the target task, it is used to implement:

[0085] Obtain the target task creation data obtained by the software under test after performing the function test;

[0086] When the similarity between the creation test result of the target task and the target task creation data is greater than or equal to the target threshold, determine that the software under test passes the test.

[0087] In one embodiment, when the processor implements determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and calling the test data corresponding to the software under test when performing a function test or calling the software under test when performing a system test according to the target test case, it is used to implement:

[0088] When the target test case is a network element deletion case and the target dependent service class is the kafka public service class, determine that the target fake class includes the FakeKafkaClientService class and the FakeConsumer class according to the identifier of the dependent service class and the fake class, and call the target network element and kafka message corresponding to the software under test when performing system testing.

[0089] In one embodiment, when the processor implements testing the software under test by running the target test case based on the target fake class and the test data to obtain the test result of the software under test, it is used to implement:

[0090] Perform the deletion test of the target network element on the software under test based on the FakeKafkaClientService class, the FakeConsumer class, and the kafka message, and determine the test result of the software under test according to the deletion test result of the target network element.

[0091] In one embodiment, when the processor implements determining the test result of the software under test according to the deletion processing result of the target network element, it is used to implement:

[0092] Obtain the target network element data obtained by the software under test after performing system testing;

[0093] When the similarity between the deletion test result of the target network element and the target network element data is greater than or equal to the target threshold, determine that the software under test passes the test.

[0094] In one embodiment, when the processor implements obtaining the target service information, it is used to implement:

[0095] When there is historical test information, determine whether there is information in the historical test information that is the same as the target service information;

[0096] When there is information that is the same as the target service information, obtain the target service information from the historical test information.

[0097] In one embodiment, when the processor implements determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, it is used to implement:

[0098] When running to access an external interface or an external dependent service, determine the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, so that the target fake class replaces the target dependent service class to run the target test case.

[0099] It should be noted that those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working process of the above-described terminal device can refer to the corresponding process in the foregoing software testing method embodiments and will not be elaborated herein.

[0100] The present application also provides a storage medium for computer-readable storage. The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of any software testing method provided in the specification of the present application.

[0101] Among them, the storage medium may be an internal storage unit of the terminal device described in the foregoing embodiments, such as the hard disk or memory of the terminal device. The storage medium may also be an external storage device of the terminal device, such as a plug-in hard disk equipped on the terminal device, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc.

[0102] Those of ordinary skill in the art can understand that all or some of the steps in the methods disclosed above, and the functional modules / units in systems and devices, can be implemented as software, firmware, hardware, and their appropriate combinations. In the hardware embodiment, the division between the functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, one physical component can have multiple functions, or one function or step can be executed by several physical components in cooperation. Some or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or can be implemented as hardware, or can be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. The computer storage medium includes, but is not limited to, RAM, ROM, EEPROM, flash memory, or other memory technologies, CD-ROM, digital versatile disk (DVD), or other optical disk storage, magnetic cassette, tape, magnetic disk storage, or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, a communication medium typically contains computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium.

[0103] It should be understood that the term "and / or" used in the specification and appended claims of the present invention refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations. It should be noted that in this text, the term "comprises," "comprising," or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a series of elements includes not only those elements but also other elements that are not expressly listed, or elements that are inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an..." does not exclude the presence of additional identical elements in the process, method, article, or system that comprises the element.

[0104] The above serial numbers of this application are only for description and do not represent the advantages or disadvantages of the embodiments. The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A software testing method, characterized in that, it includes: Obtain the fake class of the software to be tested and the corresponding target business information, where the target business information includes the identifier of the dependent service class corresponding to the fake class; Determine the target test cases of the software to be tested and the target dependent service class corresponding to the target test cases, where the target test cases are used for unit testing of the software to be tested; Determine the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and run the target test cases based on the target fake class to test the software to be tested, and obtain the test result of the software to be tested.

2. The software testing method according to claim 1, characterized in that, The step of determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and running the target test cases based on the target fake class to test the software to be tested, and obtaining the test result of the software to be tested includes: Determine the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and call the test data corresponding to the software to be tested when performing function testing or call the software to be tested when performing system testing according to the target test cases; Run the target test cases based on the target fake class and the test data to test the software to be tested, and obtain the test result of the software to be tested.

3. The software testing method according to claim 2, characterized in that, The step of determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and calling the test data corresponding to the software to be tested when performing function testing or call the software to be tested when performing system testing according to the target test cases includes: When the target test case is a target task creation case and the target dependent service class is a real-time task microservice, determine that the target fake class is the FakeRealTask class according to the identifier of the dependent service class and the fake class, and call the task creation test data corresponding to the software to be tested when performing function testing.

4. The software testing method according to claim 3, characterized in that, The step of running the target test cases based on the target fake class and the test data to test the software to be tested, and obtaining the test result of the software to be tested includes: Perform the creation test of the target task on the software to be tested based on the FakeRealTask class and the task creation test data, and determine the test result of the software to be tested according to the creation test result of the target task.

5. The software testing method according to claim 4, characterized in that, The step of determining the test result of the software to be tested according to the creation test result of the target task includes: Obtain the target task creation data obtained after the software to be tested executes the function test; When the similarity between the creation test result of the target task and the target task creation data is greater than or equal to the target threshold, determine that the software to be tested passes the test.

6. The software testing method according to claim 2, characterized in that, The determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, and calling the test data corresponding to the software to be tested when executing the function test or calling the software to be tested when executing the system test according to the target test case includes: When the target test case is a network element deletion use case and the target dependent service class is a kafka public service class, determining the target fake class according to the identifier of the dependent service class and the fake class includes the FakeKafkaClientService class and the FakeConsumer class, and calling the target network element and kafka message corresponding to the software to be tested when executing the system test.

7. The software testing method according to claim 6, characterized in that, The running the target test case based on the target fake class and the test data to test the software to be tested to obtain the test result of the software to be tested includes: Performing the deletion test of the target network element on the software to be tested based on the FakeKafkaClientService class, the FakeConsumer class and the kafka message, and determining the test result of the software to be tested according to the deletion test result of the target network element.

8. The software testing method according to claim 7, characterized in that, The determining the test result of the software to be tested according to the deletion processing result of the target network element includes: Obtain the target network element data obtained after the software to be tested executes the system test; When the similarity between the deletion test result of the target network element and the target network element data is greater than or equal to the target threshold, determine that the software to be tested passes the test.

9. The software testing method according to any one of claims 1-8, characterized in that, The obtaining the fake class of the software to be tested and the corresponding target service information includes: When there is historical test information, determine whether there is information identical to the target service information in the historical test information; When there is information identical to the target service information, obtain the target service information from the historical test information.

10. The software testing method according to any one of claims 1-8, characterized in that, The determining the target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class includes: When running to access an external interface or an external dependent service, determine a target fake class corresponding to the target dependent service class according to the identifier of the dependent service class and the fake class, so that the target fake class replaces the target dependent service class to run the target test case.

11. A terminal device, characterized in that the terminal device includes a processor, a memory, a computer program stored on the memory and executable by the processor, and a data bus for realizing connection communication between the processor and the memory, wherein when the computer program is executed by the processor, the steps of the software testing method according to any one of claims 1 to 10 are implemented.

12. A storage medium for computer-readable storage, characterized in that the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the software testing method according to any one of claims 1 to 10.