CN112463634B - Software testing method and device under micro-service architecture - Google Patents

Software testing method and device under micro-service architecture Download PDF

Info

Publication number
CN112463634B
CN112463634B CN202011449518.5A CN202011449518A CN112463634B CN 112463634 B CN112463634 B CN 112463634B CN 202011449518 A CN202011449518 A CN 202011449518A CN 112463634 B CN112463634 B CN 112463634B
Authority
CN
China
Prior art keywords
service
micro
test
services
under
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.)
Active
Application number
CN202011449518.5A
Other languages
Chinese (zh)
Other versions
CN112463634A (en
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.)
PEOPLE'S BANK OF CHINA NATIONAL CLEARING CENTER
Original Assignee
PEOPLE'S BANK OF CHINA NATIONAL CLEARING CENTER
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 PEOPLE'S BANK OF CHINA NATIONAL CLEARING CENTER filed Critical PEOPLE'S BANK OF CHINA NATIONAL CLEARING CENTER
Priority to CN202011449518.5A priority Critical patent/CN112463634B/en
Publication of CN112463634A publication Critical patent/CN112463634A/en
Application granted granted Critical
Publication of CN112463634B publication Critical patent/CN112463634B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/3684Test management for test design, e.g. generating new test cases
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (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 embodiment of the application provides a software testing method and device under a micro-service architecture, wherein the method comprises the following steps: acquiring a dependency calling relation among all micro services under a preset micro service architecture, and obtaining a calling relation configuration file among the services; determining basic test codes of all the micro services according to the calling relation configuration file among the services; receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result; the method and the device can automatically, conveniently and accurately finish software testing work under the micro-service architecture.

Description

Software testing method and device under micro-service architecture
Technical Field
The present invention relates to the field of software testing, and in particular, to a method and an apparatus for testing software under a micro-service architecture.
Background
The micro-service is an architecture and organization method for developing software, and is composed of independently operated small-sized services, the services communicate through defined interfaces, and the services can be updated, deployed and expanded independently so as to meet the requirements of specific functions of application programs.
The inventor has found that after a conventional application system is split into a plurality of micro services each having its own role, the unit test procedure of a single micro service may depend on the plurality of micro services, thereby causing the problem of being not easy to write and run locally.
Disclosure of Invention
Aiming at the problems in the prior art, the application provides a software testing method and device under a micro-service architecture, which can automatically, conveniently and accurately finish the software testing work under the micro-service architecture.
In order to solve at least one of the above problems, the present application provides the following technical solutions:
in a first aspect, the present application provides a method for testing software under a micro-service architecture, including:
acquiring a dependency calling relation among all micro services under a preset micro service architecture, and obtaining a calling relation configuration file among the services;
determining basic test codes of all the micro services according to the calling relation configuration file among the services;
and receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result.
Further, the obtaining the dependency calling relationship between the micro services under the preset micro service architecture to obtain the calling relationship configuration file between the services includes:
acquiring service class files under each micro service source code directory under a preset micro service architecture;
and determining the dependency calling relation among the micro services according to the service class file, and writing a preset calling relation configuration file among the services.
Further, the determining the basic test code of each micro service according to the calling relation configuration file between services includes:
according to the dependency calling relation in the calling relation configuration file among the services, determining the dependency calling information of each service method under each service class in each micro service;
and generating basic test codes according to the dependency call information.
Further, the receiving the target micro service test case sent by the user, and executing the micro service test operation according to the target micro service test case and the basic test code corresponding to the target micro service to obtain a micro service test result, including:
receiving a junit test case sent by a user, introducing a basic test code corresponding to the junit test case, generating a test unit and executing the test unit;
and monitoring whether each variable value and branch circulation in the execution process of the test unit are abnormal, if not, judging that the micro service test passes, otherwise, judging that the micro service test does not pass.
In a second aspect, the present application provides a software testing apparatus under a micro-service architecture, including:
the configuration file determining module is used for obtaining the dependence calling relation among the micro services under the preset micro service architecture and obtaining a calling relation configuration file among the services;
the basic test code determining module is used for determining basic test codes of the micro services according to the calling relation configuration file among the services;
and the micro-service test operation module is used for receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result.
Further, the profile determination module includes:
the service class file acquisition unit is used for acquiring service class files under the micro service source code directory under the preset micro service architecture;
and the dependency calling relation determining unit is used for determining the dependency calling relation among the micro services according to the service class file and writing a preset calling relation configuration file among the services.
Further, the basic test code determination module includes:
the dependence call information determining unit is used for determining dependence call information of each service method under each service class in each micro service according to the dependence call relation in the inter-service call relation configuration file;
and the basic test code generating unit is used for generating basic test codes according to the dependence calling information.
Further, the micro service test operation module includes:
the test unit execution unit is used for receiving the junit test cases sent by the user, introducing basic test codes corresponding to the junit test cases, generating a test unit and executing the test unit;
and the test unit monitoring unit is used for monitoring whether each variable value and branch flow in the execution process of the test unit are abnormal, if not, judging that the micro service test passes, and if not, judging that the micro service test does not pass.
In a third aspect, the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the steps of the software testing method under the micro-service architecture when the program is executed.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a software testing method under a micro-service architecture as described.
According to the technical scheme, the software testing method and the device under the micro-service architecture are provided, the dependence calling relation among the micro-services under the preset micro-service architecture is automatically acquired, and the basic testing codes corresponding to the micro-services are generated, so that development testers do not need to spend effort on simulating other service calls, service logic to be verified in the testing codes can be concentrated more, the testing iteration speed is improved, and the software testing process is simple and visual.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a software testing method under a micro-service architecture according to an embodiment of the present application;
FIG. 2 is a second flow chart of a software testing method under a micro-service architecture according to an embodiment of the present application;
FIG. 3 is a third flow chart of a software testing method under the micro-service architecture according to the embodiment of the present application;
FIG. 4 is a flowchart of a software testing method under a micro-service architecture according to an embodiment of the present application;
FIG. 5 is one of the block diagrams of a software testing device under a micro-service architecture in an embodiment of the present application;
FIG. 6 is a second block diagram of a software testing device under a micro-service architecture in an embodiment of the present application;
FIG. 7 is a third block diagram of a software testing device under a micro-service architecture in an embodiment of the present application;
FIG. 8 is a fourth block diagram of a software testing device under a micro-service architecture in an embodiment of the present application;
FIG. 9 is a diagram illustrating a dependency call relationship between services in a micro-service architecture according to an embodiment of the present application;
FIG. 10 is a schematic diagram illustrating a process for generating an inter-service call relationship configuration file according to an embodiment of the present application;
FIG. 11 is a schematic diagram of performing a micro-service test operation in an embodiment of the present application;
fig. 12 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In consideration of the problem that after a conventional application system is split into a plurality of micro services with functions, because a unit test program of a single micro service possibly depends on the plurality of micro services, local writing and running are not easy to perform, the application provides a software test method and a software test device under a micro service architecture.
In order to automatically, conveniently and accurately complete the software testing work under the micro-service architecture, the application provides an embodiment of a software testing method under the micro-service architecture, referring to fig. 1, the software testing method under the micro-service architecture specifically includes the following contents:
step S101: and acquiring the dependency calling relation among the micro services under the preset micro service architecture, and obtaining the calling relation configuration file among the services.
It can be understood that, referring to fig. 9, the micro service architecture is characterized by a large number of micro services, and the functions of one service interface need to call a plurality of associated services, so that the functions are not easy to write and run locally, but the application can obtain the dependency calling relationship between each micro service under the preset micro service architecture, so that the code blocks or code units corresponding to the dependency calling relationship are prepared before specific software testing work is executed.
Alternatively, referring to fig. 10, the present application may identify a Service class file (a java file annotated by @ Service before a class declaration is a micro Service class file) by querying a specified micro Service source code directory (which may contain one or more micro Service codes), and then read the Service class file to identify dependent micro services (the dependent Service uses @ rpcc reference mark declaration), record dependent Service information (the micro Service names microsername and the schema id thereof), and further continue to read common methods of the Service class file, identify which methods of the dependent micro services are called by each method of the present Service, record call information of the dependent Service methods, write the recorded micro Service dependency information into a Service-to-Service call relationship configuration file, and store the Service class file for subsequent use, thereby enabling a developer to concentrate more on a Service logic aspect to be verified in a test code, without having to spend on simulating the other Service calls, and achieving accurate implementation of the dependent call relationship when writing the test code.
Alternatively, in some possible embodiments of the present application, the present application may obtain the test result by receiving a test case (EXCEL or other) provided by a user, extracting and forming a configuration file according to the content of the case, and combining the configuration file generated by the test case with the basic test code when the test is run.
Specifically, the specific execution program for extracting the case contents from the test cases to form the configuration file includes:
step S102: and determining basic test codes of the micro services according to the calling relation configuration file among the services.
Optionally, the application may read in the inter-service call relationship configuration file and traverse the inter-service call relationship configuration file, so as to obtain the dependency information of each service method under each specific service class under each micro service, and generate the basic test code of the service method according to the dependency information.
Alternatively, a particular service class of each micro-service may generate a test class (i.e., base test code) that contains a reference declaration of a dependent service or other corresponding and necessary code.
Step S103: and receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result.
Alternatively, the present application may employ JMockit to simulate external system behavior so that the test program may run locally.
It will be appreciated that Jmockit is a framework for JAVA unit testing by the mock method, and mock testing is a testing method in which a virtual object is created for testing purposes for objects that are not easily constructed or easily obtained during testing.
Optionally, referring to fig. 11, the user writes the junit test case code and adds the service logic verification to be performed in the junit test case code, and then the application automatically introduces the corresponding basic test code for implementing the dependency calling relationship required by the junit test case in operation.
Alternatively, when the junit test case is run, whether the running process is normal can be confirmed by observing whether each variable value and branch circulation are normal in the running process.
Optionally, the local running junit case observes each variable value and branch circulation in the running process to confirm whether the running process is normal.
As can be seen from the above description, according to the software testing method under the micro-service architecture provided by the embodiment of the application, the dependency calling relationship between each micro-service under the preset micro-service architecture can be automatically obtained, and the basic testing code corresponding to each micro-service is generated, so that development and testing personnel do not need to spend effort on simulating other service calls, service logic to be verified in the testing code can be concentrated more, and meanwhile, the testing iteration speed is improved, so that the software testing process is simple and visual.
In order to automatically and accurately obtain the dependency call relationship between the micro services, in an embodiment of the software testing method under the micro service architecture of the present application, referring to fig. 2, the step S101 may further specifically include the following:
step S201: and obtaining service class files under the micro service source code directory under the preset micro service architecture.
Step S202: and determining the dependency calling relation among the micro services according to the service class file, and writing a preset calling relation configuration file among the services.
Optionally, the application may identify a Service class file (a java file annotated by @ Service before a class declaration is a micro Service class file) by querying a specified micro Service source code directory (which may contain one or more micro Service codes), and then read the Service class file to identify a dependent micro Service (the dependent Service uses @ RpcReference tag declaration), record dependent Service information (the micro Service names microserviceName and the schema id thereof), further continuously read common methods of the Service class file, identify which methods of the dependent micro Service are called by each method of the Service, record call information of the dependent Service methods, write the recorded micro Service dependency information into a Service-to-Service call relationship configuration file, and store the Service dependency relationship configuration file for subsequent use, thereby enabling a developer to concentrate on a Service logic aspect to be verified in a test code without spending effort on simulating other Service calls, and achieving automatic and accurate realization of a call relationship when writing the test program.
In order to prepare the required basic test code capable of implementing the dependency call function in advance before executing the software test according to the dependency call relationship between the micro services, in an embodiment of the software test method under the micro service architecture of the present application, referring to fig. 3, the step S102 may further specifically include the following:
step S301: and determining the dependency calling information of each service method under each service class in each micro service according to the dependency calling relation in the inter-service calling relation configuration file.
Step S302: and generating basic test codes according to the dependency call information.
Optionally, the application may obtain the dependency information of each service method under each specific service class under each micro service by reading the inter-service call relationship configuration file and traversing the inter-service call relationship configuration file, and generate the basic test code of the service method according to the dependency information.
In order to automatically and accurately refer to the dependency calling relationship between the micro services and accurately execute the test work during the software test, in an embodiment of the software test method under the micro service architecture of the present application, referring to fig. 4, the step S103 may further specifically include the following:
step S401: and receiving the junit test cases sent by the user, introducing basic test codes corresponding to the junit test cases, generating test units and executing the test units.
Step S402: and monitoring whether each variable value and branch circulation in the execution process of the test unit are abnormal, if not, judging that the micro service test passes, otherwise, judging that the micro service test does not pass.
Optionally, the user writes the junit test case code, adds the service logic verification to be performed in the junit test case code, and then automatically introduces the corresponding basic test code to realize the dependency calling relationship required by the junit test case in operation.
Alternatively, when the junit test case is run, whether the running process is normal can be confirmed by observing whether each variable value and branch circulation are normal in the running process.
Optionally, the local running junit case observes each variable value and branch circulation in the running process to confirm whether the running process is normal.
In order to automatically, conveniently and accurately complete the software testing work under the micro-service architecture, the application provides an embodiment of a software testing device under the micro-service architecture for implementing all or part of the content of the software testing method under the micro-service architecture, referring to fig. 5, the software testing device under the micro-service architecture specifically includes the following contents:
the configuration file determining module 10 is configured to obtain a dependency calling relationship between each micro service under a preset micro service architecture, and obtain an inter-service calling relationship configuration file.
And the basic test code determining module 20 is used for determining the basic test codes of the micro services according to the calling relation configuration file among the services.
The micro service test operation module 30 is configured to receive a target micro service test case sent by a user, and execute a micro service test operation according to the target micro service test case and the basic test code corresponding to the target micro service, so as to obtain a micro service test result.
As can be seen from the above description, the software testing device under the micro-service architecture provided by the embodiment of the application can automatically obtain the dependency calling relationship between each micro-service under the preset micro-service architecture and generate the basic testing code corresponding to each micro-service, so that development and testing personnel do not need to spend effort on simulating other service calls, service logic to be verified in the testing code can be concentrated more, and meanwhile, the testing iteration speed is improved, so that the software testing process is simple and visual.
In order to automatically and accurately obtain the dependency call relationship between the micro services, in an embodiment of the software testing apparatus under the micro service architecture of the present application, referring to fig. 6, the configuration file determining module 10 includes:
the service class file obtaining unit 11 is configured to obtain service class files under the micro service source code directory under the preset micro service architecture.
And the dependency calling relation determining unit 12 is used for determining the dependency calling relation among the micro services according to the service class file and writing a preset calling relation configuration file among the services.
In order to prepare the required basic test code capable of implementing the dependency call function in advance before executing the software test according to the dependency call relationship between the micro services, in an embodiment of the software test apparatus under the micro service architecture of the present application, referring to fig. 7, the basic test code determining module 20 includes:
the dependency call information determining unit 21 is configured to determine dependency call information of each service method under each service class in each micro service according to the dependency call relationship in the inter-service call relationship configuration file.
And a basic test code generating unit 22, configured to generate basic test code according to the dependency call information.
In order to automatically and accurately refer to the dependency calling relationship between the micro services and accurately execute the test work during the software test, in an embodiment of the software test apparatus under the micro service architecture of the present application, referring to fig. 8, the micro service test operation module 30 includes:
and the test unit executing unit 31 is used for receiving the junit test cases sent by the user, introducing basic test codes corresponding to the junit test cases, generating a test unit and executing the test unit.
And the test unit monitoring unit 32 is used for monitoring whether each variable value and branch flow in the execution process of the test unit are abnormal, if not, determining that the micro service test passes, and if not, determining that the micro service test does not pass.
In order to further explain the present solution, the present application further provides a specific application example for implementing the software testing method under the micro service architecture by using the software testing device under the micro service architecture, which specifically includes: the system comprises an information acquisition module and a test code generation module.
The information acquisition module is specifically realized:
1. the program identifies the Service class files (the java files annotated with @ Service before the class declaration are the micro Service class files) according to a specified micro Service source code directory (which may contain one or more micro Service codes).
2. The program reads the service class file, identifies the dependent microservices (the dependent services use @ rpcc reference mark declaration), and records the dependent service information (its microservices names microservices name and schema id).
3. The program continues to read the common methods of the service class file, identifies which methods of which dependent micro-services are called by each method of the service, and records the call information of the dependent service methods (dependent services from the previous step).
4. The program writes the recorded micro-service dependent information into a configuration file and stores the configuration file into a designated directory;
examples of profile segments generated are as follows:
the test code generation module specifically realizes:
1. the program reads in the dependency configuration file.
2. The program traverses the configuration file, and the dependency information of each service method under each specific service class under each micro service.
3. And the program generates basic test codes of the service method according to the information of the last step.
4. Generating a test class for a specific service class of each micro-service, wherein the test class contains a reference statement of the dependent service, and a dependent service method called by a test method of each public method;
examples of test code fragments generated are as follows:
the specific working process is as follows:
1. and on a system storing all micro service codes, an information acquisition module is operated, and the module acquires all micro service calls from the codes, records and stores the calls in an automatically generated configuration file in a corresponding relation mode.
2. The test code generating module is operated, a micro service name for generating the test code, a test object interface/class or a method detailed under the interface/class is input/selected from the control console, and the module automatically generates a unit test code containing information such as a function called method, initial parameters of the called method, a dependence simulation class of the calling method, simulation return initial parameters and the like.
With the above, the present application can at least achieve the following technical effects:
1. the method and the system for automatically collecting the dependent services used by the service method.
2. Automatically generating a record file of the dependency relationship among services, and generating the record file once for multiple people to use.
3. And generating basic test codes of all or appointed micro services for users, so that the basic test codes are more centralized and verified with service functions, and the method is quick and accurate and saves manpower.
In order to automatically, conveniently and accurately complete software testing work under a micro-service architecture from a hardware level, the application provides an embodiment of an electronic device for implementing all or part of contents in a software testing method under the micro-service architecture, where the electronic device specifically includes the following contents:
a processor (processor), a memory (memory), a communication interface (Communications Interface), and a bus; the processor, the memory and the communication interface complete communication with each other through the bus; the communication interface is used for realizing information transmission between the software testing device under the micro-service architecture and related equipment such as a core service system, a user terminal, a related database and the like; the logic controller may be a desktop computer, a tablet computer, a mobile terminal, etc., and the embodiment is not limited thereto. In this embodiment, the logic controller may refer to an embodiment of the software testing method under the micro service architecture in the embodiment and an embodiment of the software testing device under the micro service architecture, and the contents thereof are incorporated herein and are not repeated here.
It is understood that the user terminal may include a smart phone, a tablet electronic device, a network set top box, a portable computer, a desktop computer, a Personal Digital Assistant (PDA), a vehicle-mounted device, a smart wearable device, etc. Wherein, intelligent wearing equipment can include intelligent glasses, intelligent wrist-watch, intelligent bracelet etc..
In practical applications, part of the software testing method under the micro-service architecture may be executed on the electronic device side as described above, or all operations may be completed in the client device. Specifically, the selection may be made according to the processing capability of the client device, and restrictions of the use scenario of the user. The present application is not limited in this regard. If all operations are performed in the client device, the client device may further include a processor.
The client device may have a communication module (i.e. a communication unit) and may be connected to a remote server in a communication manner, so as to implement data transmission with the server. The server may include a server on the side of the task scheduling center, and in other implementations may include a server of an intermediate platform, such as a server of a third party server platform having a communication link with the task scheduling center server. The server may include a single computer device, a server cluster formed by a plurality of servers, or a server structure of a distributed device.
Fig. 12 is a schematic block diagram of a system configuration of an electronic device 9600 of an embodiment of the present application. As shown in fig. 12, the electronic device 9600 may include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. Notably, this fig. 12 is exemplary; other types of structures may also be used in addition to or in place of the structures to implement telecommunications functions or other functions.
In one embodiment, the software testing method functionality under the micro-service architecture may be integrated into the CPU 9100. The central processor 9100 may be configured to perform the following control:
step S101: and acquiring the dependency calling relation among the micro services under the preset micro service architecture, and obtaining the calling relation configuration file among the services.
Step S102: and determining basic test codes of the micro services according to the calling relation configuration file among the services.
Step S103: and receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result.
As can be seen from the above description, in the electronic device provided by the embodiment of the present application, by automatically acquiring the dependency calling relationship between each micro service under the preset micro service architecture and generating the basic test code corresponding to each micro service, the development tester does not need to spend effort on simulating other service calls, and can concentrate on the service logic to be verified in the test code, and meanwhile, the test iteration speed is also improved, so that the software test process is simple and visual.
In another embodiment, the software testing device under the micro-service architecture may be configured separately from the central processor 9100, for example, the software testing device under the micro-service architecture may be configured as a chip connected to the central processor 9100, and the software testing method function under the micro-service architecture is implemented by the control of the central processor.
As shown in fig. 12, the electronic device 9600 may further include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is noted that the electronic device 9600 need not include all of the components shown in fig. 12; in addition, the electronic device 9600 may further include components not shown in fig. 12, and reference may be made to the related art.
As shown in fig. 12, the central processor 9100, sometimes referred to as a controller or operational control, may include a microprocessor or other processor device and/or logic device, which central processor 9100 receives inputs and controls the operation of the various components of the electronic device 9600.
The memory 9140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable media, a volatile memory, a non-volatile memory, or other suitable device. The information about failure may be stored, and a program for executing the information may be stored. And the central processor 9100 can execute the program stored in the memory 9140 to realize information storage or processing, and the like.
The input unit 9120 provides input to the central processor 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to provide power to the electronic device 9600. The display 9160 is used for displaying display objects such as images and characters. The display may be, for example, but not limited to, an LCD display.
The memory 9140 may be a solid state memory such as Read Only Memory (ROM), random Access Memory (RAM), SIM card, etc. But also a memory which holds information even when powered down, can be selectively erased and provided with further data, an example of which is sometimes referred to as EPROM or the like. The memory 9140 may also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application/function storage portion 9142, the application/function storage portion 9142 storing application programs and function programs or a flow for executing operations of the electronic device 9600 by the central processor 9100.
The memory 9140 may also include a data store 9143, the data store 9143 for storing data, such as contacts, digital data, pictures, sounds, and/or any other data used by an electronic device. The driver storage portion 9144 of the memory 9140 may include various drivers of the electronic device for communication functions and/or for performing other functions of the electronic device (e.g., messaging applications, address book applications, etc.).
The communication module 9110 is a transmitter/receiver 9110 that transmits and receives signals via an antenna 9111. A communication module (transmitter/receiver) 9110 is coupled to the central processor 9100 to provide input signals and receive output signals, as in the case of conventional mobile communication terminals.
Based on different communication technologies, a plurality of communication modules 9110, such as a cellular network module, a bluetooth module, and/or a wireless local area network module, etc., may be provided in the same electronic device. The communication module (transmitter/receiver) 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide audio output via the speaker 9131 and to receive audio input from the microphone 9132 to implement usual telecommunications functions. The audio processor 9130 can include any suitable buffers, decoders, amplifiers and so forth. In addition, the audio processor 9130 is also coupled to the central processor 9100 so that sound can be recorded locally through the microphone 9132 and sound stored locally can be played through the speaker 9131.
The embodiments of the present application further provide a computer readable storage medium capable of implementing all the steps in the software testing method in the micro-service architecture in which the execution subject is a server or a client, and the computer readable storage medium stores a computer program thereon, where the computer program when executed by a processor implements all the steps in the software testing method in the micro-service architecture in which the execution subject is a server or a client, for example, the processor implements the following steps when executing the computer program:
step S101: and acquiring the dependency calling relation among the micro services under the preset micro service architecture, and obtaining the calling relation configuration file among the services.
Step S102: and determining basic test codes of the micro services according to the calling relation configuration file among the services.
Step S103: and receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result.
As can be seen from the above description, the computer readable storage medium provided in the embodiment of the present application automatically obtains the dependency calling relationship between each micro service under the preset micro service architecture, and generates the basic test code corresponding to each micro service, so that the development tester does not need to spend effort on simulating other service calls, and can concentrate on the service logic to be verified in the test code, and meanwhile, the test iteration speed is improved, so that the software test process is simple and intuitive.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (devices), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principles and embodiments of the present invention have been described in detail with reference to specific examples, which are provided to facilitate understanding of the method and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (8)

1. A method for testing software in a micro-service architecture, the method comprising:
acquiring a dependency calling relation among all micro services under a preset micro service architecture, and obtaining a calling relation configuration file among the services;
determining basic test codes of all the micro services according to the calling relation configuration file among the services;
receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result;
the determining the basic test code of each micro service according to the calling relation configuration file between services comprises the following steps:
reading in an inter-service call relationship configuration file, traversing the inter-service call relationship configuration file, acquiring the dependency information of each service method under each specific service class under each micro service, and generating a basic test code of the service method according to the dependency information;
a particular service class of each micro-service may generate a base test code that includes a reference statement or other corresponding and necessary code that depends on the service;
the method for receiving the target micro-service test case sent by the user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result comprises the following steps:
receiving a junit test case sent by a user, introducing a basic test code corresponding to the junit test case, generating a test unit and executing the test unit;
and monitoring whether each variable value and branch circulation in the execution process of the test unit are abnormal, if not, judging that the micro service test passes, otherwise, judging that the micro service test does not pass.
2. The method for testing software under a micro-service architecture according to claim 1, wherein the obtaining the dependency call relationship between the micro-services under the preset micro-service architecture to obtain the service call relationship configuration file comprises:
acquiring service class files under each micro service source code directory under a preset micro service architecture;
and determining the dependency calling relation among the micro services according to the service class file, and writing a preset calling relation configuration file among the services.
3. The method for testing software under a micro-service architecture according to claim 1, wherein determining the basic test code of each micro-service according to the inter-service call relationship configuration file comprises:
according to the dependency calling relation in the calling relation configuration file among the services, determining the dependency calling information of each service method under each service class in each micro service;
and generating basic test codes according to the dependency call information.
4. A software testing apparatus under a micro-service architecture, comprising:
the configuration file determining module is used for obtaining the dependence calling relation among the micro services under the preset micro service architecture and obtaining a calling relation configuration file among the services;
the basic test code determining module is used for determining basic test codes of the micro services according to the calling relation configuration file among the services;
the micro-service test operation module is used for receiving a target micro-service test case sent by a user, and executing micro-service test operation according to the target micro-service test case and the basic test code corresponding to the target micro-service to obtain a micro-service test result;
the basic test code determining module is specifically used for acquiring the dependency information of each service method under each specific service class under each micro service by reading in the inter-service call relation configuration file and traversing the inter-service call relation configuration file, and generating a basic test code of the service method according to the dependency information; a particular service class of each micro-service may generate a base test code that includes a reference statement or other corresponding and necessary code that depends on the service;
the micro-service test operation module comprises:
the test unit execution unit is used for receiving the junit test cases sent by the user, introducing basic test codes corresponding to the junit test cases, generating a test unit and executing the test unit;
and the test unit monitoring unit is used for monitoring whether each variable value and branch flow in the execution process of the test unit are abnormal, if not, judging that the micro service test passes, and if not, judging that the micro service test does not pass.
5. The software testing apparatus under a micro-service architecture according to claim 4, wherein the profile determination module comprises:
the service class file acquisition unit is used for acquiring service class files under the micro service source code directory under the preset micro service architecture;
and the dependency calling relation determining unit is used for determining the dependency calling relation among the micro services according to the service class file and writing a preset calling relation configuration file among the services.
6. The software testing apparatus under a micro-service architecture according to claim 4, wherein the basic test code determining module comprises:
the dependence call information determining unit is used for determining dependence call information of each service method under each service class in each micro service according to the dependence call relation in the inter-service call relation configuration file;
and the basic test code generating unit is used for generating basic test codes according to the dependence calling information.
7. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the software testing method under the micro-service architecture of any one of claims 1 to 3 when the program is executed by the processor.
8. A computer readable storage medium having stored thereon a computer program, which when executed by a processor, implements the steps of the software testing method under the micro-service architecture of any of claims 1 to 3.
CN202011449518.5A 2020-12-11 2020-12-11 Software testing method and device under micro-service architecture Active CN112463634B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011449518.5A CN112463634B (en) 2020-12-11 2020-12-11 Software testing method and device under micro-service architecture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011449518.5A CN112463634B (en) 2020-12-11 2020-12-11 Software testing method and device under micro-service architecture

Publications (2)

Publication Number Publication Date
CN112463634A CN112463634A (en) 2021-03-09
CN112463634B true CN112463634B (en) 2024-03-29

Family

ID=74802059

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011449518.5A Active CN112463634B (en) 2020-12-11 2020-12-11 Software testing method and device under micro-service architecture

Country Status (1)

Country Link
CN (1) CN112463634B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112905486B (en) * 2021-03-26 2022-07-08 建信金融科技有限责任公司 Service integration test method, device and system
CN113285849B (en) * 2021-04-06 2022-09-27 武汉虹信科技发展有限责任公司 Equipment testing method and device based on micro-service
CN114064475A (en) * 2021-11-11 2022-02-18 中国联合网络通信集团有限公司 Cloud native application testing method, device, equipment and storage medium
CN114826899B (en) * 2022-03-16 2024-01-23 青岛海尔科技有限公司 Debugging method and device for equipment control service, storage medium and electronic device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096437A (en) * 2019-04-12 2019-08-06 平安普惠企业管理有限公司 The test method and Related product of micro services framework
CN110413673A (en) * 2019-07-08 2019-11-05 中国人民银行清算总中心 The unified acquisition of database data and distribution method and system
CN110659206A (en) * 2019-08-30 2020-01-07 平安普惠企业管理有限公司 Simulation architecture establishing method, device, medium and electronic equipment based on microservice
CN110990262A (en) * 2019-11-08 2020-04-10 安徽继远检验检测技术有限公司 Test method and tool integration based on micro-service architecture
CN111209210A (en) * 2020-01-15 2020-05-29 北京明略软件系统有限公司 Method and device for generating test case, electronic equipment and storage medium
CN111382055A (en) * 2018-12-29 2020-07-07 贝壳技术有限公司 Automatic unit testing method and device based on unified description language
CN111506505A (en) * 2020-04-13 2020-08-07 北京奇艺世纪科技有限公司 Test case obtaining method and device
CN111897738A (en) * 2020-08-21 2020-11-06 中国工商银行股份有限公司 Automatic testing method and device based on atomic service

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111382055A (en) * 2018-12-29 2020-07-07 贝壳技术有限公司 Automatic unit testing method and device based on unified description language
CN110096437A (en) * 2019-04-12 2019-08-06 平安普惠企业管理有限公司 The test method and Related product of micro services framework
CN110413673A (en) * 2019-07-08 2019-11-05 中国人民银行清算总中心 The unified acquisition of database data and distribution method and system
CN110659206A (en) * 2019-08-30 2020-01-07 平安普惠企业管理有限公司 Simulation architecture establishing method, device, medium and electronic equipment based on microservice
CN110990262A (en) * 2019-11-08 2020-04-10 安徽继远检验检测技术有限公司 Test method and tool integration based on micro-service architecture
CN111209210A (en) * 2020-01-15 2020-05-29 北京明略软件系统有限公司 Method and device for generating test case, electronic equipment and storage medium
CN111506505A (en) * 2020-04-13 2020-08-07 北京奇艺世纪科技有限公司 Test case obtaining method and device
CN111897738A (en) * 2020-08-21 2020-11-06 中国工商银行股份有限公司 Automatic testing method and device based on atomic service

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Model Extraction and Test Generation from JUnit Test Suites;Pablo Lamela Seijas等;《2016 IEEE/ACM 11th International Workshop in Automation of Software Test (AST)》;第8-14页 *
基于微服务的客户服务平台的设计与实现;孟凡玥;《cnki优秀硕士学位论文全文库 工程科技Ⅱ辑》(第01期);第C042-55页 *

Also Published As

Publication number Publication date
CN112463634A (en) 2021-03-09

Similar Documents

Publication Publication Date Title
CN112463634B (en) Software testing method and device under micro-service architecture
CN110377462B (en) Interface testing method and device and terminal equipment
CN110413528B (en) Intelligent configuration method and system for test environment
CN111930617A (en) Automatic testing method and device based on data objectification
CN111897738B (en) Automatic testing method and device based on atomic service
CN109710214A (en) Construction method, device, terminal device and the storage medium of electronic signature software
CN112784112A (en) Message checking method and device
CN111371695B (en) Service flow limiting method and device
CN114153856A (en) Host data double-writing method and device
CN110278273A (en) Multimedia file method for uploading, device, terminal, server and storage medium
CN111930624B (en) Test link message data processing method and device
CN111367561B (en) Remote development method and device for software program
CN103853546A (en) Feedback system and feedback method
CN116150029A (en) Automatic overdue batch testing method and device for loan system
CN113791984B (en) Automatic interface testing method and device
CN113515447B (en) Automatic testing method and device for system
CN113050936B (en) Front-end data processing method and device based on integrated development environment
CN112905464B (en) Application running environment data processing method and device
CN115495519A (en) Report data processing method and device
CN114328215A (en) Test data deployment method, device, equipment, readable storage medium and product
CN114637531A (en) Method and device for dynamically generating application program interface
CN112102058A (en) Management system parameter configuration method and device
CN113553530A (en) Information reporting dynamic page configuration method and device
CN113342330B (en) Front-end engineering generation method and device
CN113377677B (en) Unit testing 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
GR01 Patent grant
GR01 Patent grant