CN109189672B - Automatic testing method for micro-service, server and computer readable storage medium - Google Patents

Automatic testing method for micro-service, server and computer readable storage medium Download PDF

Info

Publication number
CN109189672B
CN109189672B CN201810917613.XA CN201810917613A CN109189672B CN 109189672 B CN109189672 B CN 109189672B CN 201810917613 A CN201810917613 A CN 201810917613A CN 109189672 B CN109189672 B CN 109189672B
Authority
CN
China
Prior art keywords
test
service
target
micro
target micro
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
CN201810917613.XA
Other languages
Chinese (zh)
Other versions
CN109189672A (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.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201810917613.XA priority Critical patent/CN109189672B/en
Publication of CN109189672A publication Critical patent/CN109189672A/en
Application granted granted Critical
Publication of CN109189672B publication Critical patent/CN109189672B/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

Abstract

The invention is applicable to the technical field of computers, and provides an automatic testing method, a server and a medium for micro services, wherein the method comprises the following steps: if the fact that the compiling of the new source program is completed in the preset source program compiler is detected, acquiring a unique identifier of the micro-service represented by the source program; if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, starting a process for performing functional test on the target micro-service; if the current functional test of the process on the target micro service is the first functional test of the target micro service, the process is controlled to perform the functional test on the target micro service based on the target executable program of the target micro service and all test cases in the target test case file associated with the unique identification of the target micro service, thereby realizing the automatic test on the micro service function, saving the labor cost, improving the test efficiency, and improving the accuracy of the test result because the functional test is performed based on the sea test cases.

Description

Automatic testing method for micro-service, server and computer readable storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an automatic testing method for micro services, a server, and a computer readable storage medium.
Background
Micro-services are a new type of software architecture that is a lightweight service that is obtained by splitting a single large application or service for specific functions. In general, after a certain micro-service is developed, a developer needs to test each function of the micro-service, and after the test passes, the micro-service can be released to a next testing environment or a production environment.
In the prior art, when each function of the micro service is tested, the micro service to be tested needs to be manually called by means of an interface tool (such as postman and the like), each function of the micro service to be tested is tested by manually adopting a test case, meanwhile, the test result of the micro service to be tested is counted manually, however, the test efficiency of manually testing the function of the micro service is lower, the condition of missed test or statistic error of the test result often exists in the manual test, and the accuracy of the test result is reduced.
Disclosure of Invention
In view of the above, embodiments of the present invention provide an automatic testing method, a server and a computer readable storage medium for micro services, so as to solve the problems of low testing efficiency and low accuracy of testing results in the existing manual testing method for micro services.
A first aspect of an embodiment of the present invention provides an automatic testing method for a micro service, including:
if the fact that a new source program is compiled in a preset source program compiler is detected, acquiring a unique identifier of a micro-service represented by the source program from configuration information of the source program;
if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as a target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service;
if the current functional test of the process on the target micro-service is detected to be the first functional test of the target micro-service, acquiring a target test case file associated with the unique identification of the target micro-service from a first test case library;
and controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file.
A second aspect of an embodiment of the present invention provides a server comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of:
If the fact that a new source program is compiled in a preset source program compiler is detected, acquiring a unique identifier of a micro-service represented by the source program from configuration information of the source program;
if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as a target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service;
if the current functional test of the process on the target micro-service is detected to be the first functional test of the target micro-service, acquiring a target test case file associated with the unique identification of the target micro-service from a first test case library;
and controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file.
A third aspect of the embodiments of the present invention provides a computer-readable storage medium storing a computer program which, when executed by a processor, performs the steps of:
If the fact that a new source program is compiled in a preset source program compiler is detected, acquiring a unique identifier of a micro-service represented by the source program from configuration information of the source program;
if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as a target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service;
if the current functional test of the process on the target micro-service is detected to be the first functional test of the target micro-service, acquiring a target test case file associated with the unique identification of the target micro-service from a first test case library;
and controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file.
The automatic testing method, the server and the computer readable storage medium for the micro-service provided by the embodiment of the invention have the following beneficial effects:
when a new source program is compiled in a preset source program compiler, and the newly compiled source program is used for representing a target micro-service, the executable program obtained by compiling the new source program is identified as a target executable program of the target micro-service, and a process for performing functional test on the target micro-service is automatically started, and the process is controlled to perform functional test on the target micro-service based on the target executable program and a target test case file associated with the unique identification of the target micro-service, so that the automatic test on the micro-service function is realized, the labor cost is saved, and the test efficiency of the micro-service function test is improved; meanwhile, when the current functional test of the target micro-service is detected to be the first functional test of the target micro-service, controlling the process for carrying out the functional test of the target micro-service based on all test cases in the target test case file, and carrying out the functional test of the target micro-service, thereby avoiding the occurrence of the missing test condition.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that 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 showing an implementation of a method for automatically testing micro services according to a first embodiment of the present invention;
FIG. 2 is a flow chart showing an implementation of a method for automatically testing micro services according to a second embodiment of the present invention;
FIG. 3 is a flowchart showing a specific implementation of S15 in a method for automatically testing micro services according to a third embodiment of the present invention;
FIG. 4 is a flow chart showing an implementation of a method for automatically testing micro services according to a fourth embodiment of the present invention;
FIG. 5 is a flowchart of an implementation of a method for automatically testing micro services according to a fifth embodiment of the present invention;
FIG. 6 is a block diagram of a server according to an embodiment of the present invention;
fig. 7 is a block diagram of a server according to another embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating an implementation of a method for automatically testing a micro service according to a first embodiment of the present invention. In this embodiment, the execution subject of the automatic test method for micro services is a server. The automatic test method of micro services as shown in fig. 1 includes the steps of:
s11: if the fact that the compiling of the new source program is completed in the preset source program compiler is detected, the unique identification of the micro-service represented by the source program is obtained from the configuration information of the source program.
In the embodiment of the invention, a preset source program compiler is used for translating a source program written in a source language into an executable program which can be identified by a computer and is described by a binary language. In practical application, a developer may develop a set of monitoring program for monitoring a preset source program compiler in advance, and the server may monitor the preset source program compiler by installing the monitoring program. Specifically, when the server monitors that the compiling button of the preset source program compiler is triggered through the monitoring program, it is identified that a new source program in the preset source program compiler starts to compile, at this time, the server monitors the compiling progress of the preset source program compiler through the monitoring program, and when the compiling progress of the preset source program compiler is monitored to be 100%, it is identified that the preset source program compiler has a new source program to compile.
It should be noted that, in the embodiment of the present invention, the executable program obtained by compiling the source program is used to implement each function included in the micro-service represented by the source program. For example, an executable program obtained by compiling a source program for characterizing the premium calculation micro service is used to realize various functions included in the premium calculation micro service. The functions included in the premium calculation micro-service include, but are not limited to, a annual premium calculation function, a weak premium calculation function, a professional premium calculation function, and the like.
In the embodiment of the invention, in order to enable the server to automatically identify and distinguish the source programs corresponding to different micro-services, a developer adds the unique identifier of the micro-service represented by the source program into the configuration information of the source program when editing the source program. The unique identification of the micro-service may be the name of the micro-service.
In practical applications, the configuration information of the source program may be stored in a header file of the source program. In this embodiment, when detecting that a new source program is compiled in a preset source program compiler, the server acquires configuration information of the new source program from a header file of the new source program, and extracts a unique identifier of a micro-service represented by the source program from the configuration information of the new source program.
S12: and if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as the target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service.
In the embodiment of the invention, after the server acquires the unique identifier of the micro-service represented by the newly compiled source program, the unique identifier of the micro-service represented by the newly compiled source program is compared with the unique identifier of the target micro-service stored in advance so as to determine whether the micro-service represented by the newly compiled source program is the target micro-service. The target micro-service is a micro-service which needs to be subjected to functional test. For example, in practical applications, the target micro-service may be a premium calculation micro-service, an insurance product benefit demonstration micro-service, or the like. The developer may pre-store in the server a unique identification of the target micro-service that needs to be functionally tested. The unique identifier of the target micro service stored in the server in advance may be one or at least two, which is not limited herein.
If the server detects that the unique identifier of the micro-service represented by the newly compiled source program is identical to the unique identifier of the target micro-service, the server indicates that the micro-service represented by the newly compiled source program is the target micro-service to be tested, at this time, the server compiles the executable program obtained by compiling the newly compiled source program, and identifies the executable program obtained by compiling the newly compiled source program as the target executable program of the target micro-service, and at the same time, the server starts a process for performing functional test on the target micro-service so that the process automatically performs functional test on the target micro-service. Wherein the target executable program of the target micro-service is used for realizing various functions of the target micro-service.
In practical applications, test cases for functional testing of a microservice typically employ production data generated in a production environment from an old version of the microservice. That is, each piece of production data for performing a functional test on a micro-service is one test case of the micro-service. In this embodiment, the developer may store all test cases for performing the functional test on the target micro-service in the test case file associated with the unique identifier of the target micro-service in the first test case library.
It should be noted that, when the version of the micro service is updated once, a functional test needs to be performed on the micro service for a new version of the micro service, and in order to improve the test efficiency, when the first functional test is performed on a certain micro service, all test cases corresponding to the micro service are generally used for performing the functional test on the micro service, and when the non-first (such as the second time, the third time, etc.) functional test is performed on a certain micro service, if the time interval between the current functional test on the micro service and the last functional test on the micro service is shorter, the test cases of the current functional test may be used for the test cases of the micro service, where an abnormality occurs when the last functional test is performed on the micro service.
Specifically, after the server starts the process for performing the functional test on the target micro-service, it is detected whether the current functional test of the process on the target micro-service is the first functional test of the target micro-service. If the server detects that the current functional test of the process on the target micro service is the first functional test of the target micro service, S13 is executed.
In the embodiment of the invention, a developer can create a test log table for recording the test information of the micro service in the server in advance. Wherein the test information of the micro service includes, but is not limited to, the test time of each functional test of the micro service. The server records the test time of each functional test of the micro service, and stores the test time of each functional test of the micro service and the unique identification of the micro service in a test log table in a correlation manner. In practical application, the time when the micro service starts to perform the function test may be determined as the test time of the micro service current function test, or the time when the micro service current function test ends may be determined as the test time of the micro service current function test, which is not limited herein.
The server detects whether a unique identifier identical to the unique identifier of the target micro-service exists in the test log table when detecting that the newly compiled source program is used for characterizing the target micro-service. If the server detects that the unique identifier which is the same as the unique identifier of the target micro-service does not exist in the test log table, the server indicates that the target micro-service is never subjected to the functional test, and at the moment, the server determines the functional test of the process for carrying out the functional test on the target micro-service as the first functional test of the target micro-service; if the server detects that the unique identifier which is the same as the unique identifier of the target micro-service exists in the test log table, the server indicates that the target micro-service has been subjected to at least one functional test, and at this time, the server determines that the functional test of the process for performing the functional test on the target micro-service is not the first functional test of the target micro-service, namely, the server determines that the functional test of the process for performing the functional test on the target micro-service is not the first functional test of the target micro-service.
S13: if the current functional test of the process on the target micro-service is detected to be the first functional test of the target micro-service, a target test case file associated with the unique identification of the target micro-service is acquired from a first test case library.
In this embodiment, if the server detects that the current functional test of the target micro service by the process for performing the functional test on the target micro service is the first functional test of the target micro service, the server obtains a target test case file associated with the unique identifier of the target micro service from the first test case library.
It should be noted that, the first test case library stores a plurality of test case files, and different test case files are used for storing test cases for performing functional tests on different micro services. The test case file has an association relationship with the unique identifier of the micro service to which the stored test case belongs. In practical application, the test case file may be in text format or in table format, which is not limited herein.
As an embodiment of the invention, the test case files associated therewith may be named by the unique identification of the micro-service. The server may identify, as a target test case file, a test case file in the first test case library having a name identical to a unique identifier of the micro service represented by the newly compiled source program, and obtain the target test case file from the first test case library. As another embodiment of the present invention, the unique identification of the micro-service associated with the test case file may be stored in the configuration information of the test case file. The server can acquire the unique identifier of the micro service associated with the test case file from the configuration information of the test case file, and if the server detects that the unique identifier of the micro service stored in the configuration information of a certain test case file is identical to the unique identifier of the target micro service, the server identifies the test case file as a target test case file and acquires the target test case file from the first test case library.
S14: and controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file.
In the embodiment of the invention, after the server acquires the target test case file, the process for controlling the function test of the target micro-service is controlled to perform the function test of the target micro-service based on the target executable program and all test cases contained in the target test case file.
Specifically, the test case for performing a functional test on the microservice is composed of at least one input parameter and at least one output parameter. In the embodiment of the invention, the test case files comprise an in-parameter file and an out-parameter file. The input file is used for storing the values of the input parameters contained in each test case, and the output file is used for storing the values of the output parameters contained in each test case, that is, in this embodiment, the values of the input parameters and the values of the output parameters contained in the same test case are stored in different files, that is, the values of the input parameters of all test cases are stored in the input file, and the values of the output parameters of all test cases are stored in the output file. It should be noted that, there is an association relationship between the value of the input parameter and the value of the output parameter of the same test case, that is, the value of the input parameter and the value of the output parameter of the same test case have the same test case identifier. In practical applications, the test case identification may be a custom character or string of numbers and/or letters. For example, in practical applications, the values of the input parameters and the output parameters of the same test case may be associated by configuring the same numbers for the values of the input parameters and the values of the output parameters of the same test case.
Illustratively, the input parameters of each test case for performing a functional test on the premium calculation micro service may include, but are not limited to: the input parameters of each test case for functional testing of this micro-service for premium calculation may include, but are not limited to: annual premium, weak premium and professional premium.
In the embodiment of the invention, when controlling the process for performing functional test on the target micro-service to perform functional test on the target micro-service based on the target executable program and all test cases contained in the target test case file, specifically, the server can acquire the target entry file and the target exit file from the target test case file, after acquiring the target entry file and the target exit file, the server can call the target executable program of the target micro-service through the test interface, take the value of the input parameter of each test case contained in the target entry file as the input of the target executable program in sequence, execute the target executable program, and acquire the execution result corresponding to the value of the input parameter of each test case obtained after executing the target executable program. Based on the test case identification, the server acquires the value of the output parameter of each test case from the target parameter output file, compares the execution result corresponding to the value of the input parameter of each test case with the value of the output parameter of the test case, and further completes the target microservice function test.
In the embodiment of the invention, if the server detects that the execution results corresponding to the values of the input parameters of all the test cases are the same as the values of the output parameters of the corresponding test cases, the server determines that all the functions realized by the target executable program are normal. If the server detects that the execution result corresponding to the value of the input parameter of at least one test case is different from the value of the output parameter of the test case, determining that at least one function of the functions realized by the target executable program is abnormal. The server determines the test cases with different execution results corresponding to the values of the input parameters and the output parameters as the abnormal test cases.
As can be seen from the foregoing, in the automatic test method for a micro service provided in this embodiment, when it is detected that a preset source program compiler has a new source program compiled and completed, and the new source program compiled and completed is used to characterize a target micro service, an executable program obtained by compiling the new source program is identified as a target executable program of the target micro service, and a process for performing a functional test on the target micro service is automatically started, and the process is controlled to perform a functional test on the target micro service based on the target executable program and a target test case file associated with a unique identifier of the target micro service, thereby implementing an automatic test on a micro service function, saving labor cost, and improving test efficiency of the micro service function test; meanwhile, when the current functional test of the target micro-service is detected to be the first functional test of the target micro-service, controlling the process for carrying out the functional test of the target micro-service based on all test cases in the target test case file, and carrying out the functional test of the target micro-service, thereby avoiding the occurrence of the missing test condition.
Referring to fig. 2, fig. 2 is a flowchart illustrating an implementation of a method for automatically testing a micro service according to a second embodiment of the present invention. Compared with the corresponding embodiment of fig. 1, the automatic testing method for micro services provided in this embodiment further includes S15 to S17 after S12, and is described in detail as follows:
s15: if the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service, acquiring the first test time of the last functional test of the target micro-service from a preset test log table.
In practical applications, if the current functional test of the target micro service by the process for performing the functional test on the target micro service is not the first functional test of the target micro service, there are two general cases: one is to find that some functions of the micro-service are abnormal when the last functional test of the micro-service is performed, after the last functional test of the micro-service is finished, a developer immediately positions and repairs the abnormal functions of the micro-service based on an abnormal test case appearing in the last functional test and tests a version after functional repair again, and in this case, the time interval between the current functional test of the micro-service and the last functional test of the micro-service is shorter; in another case, when the last functional test of the micro service is performed, all the functions of the micro service are found to be normal, and after a period of time, a developer again develops a new version for the micro service, and needs to perform the functional test on the new version, where the time interval between the current functional test of the micro service and the last functional test of the micro service is relatively long. In this embodiment, if the first situation is the first case, it is generally not necessary to perform a functional test on the micro service through all test cases corresponding to the micro service, but only to perform a functional test on the micro service according to the test case having an abnormality in the previous functional test; in the second case, it is usually necessary to perform a functional test on the micro service through all test cases corresponding to the micro service.
Specifically, if the server detects that the current functional test of the target micro-service by the process for performing the functional test on the target micro-service is not the first functional test of the target micro-service, the server obtains the first test time of the last functional test of the target micro-service from the test log table based on the unique identifier of the target micro-service. The first test time is the test time closest to the current time among all the test times associated with the unique identification of the target micro service recorded in the test log table.
As an embodiment of the present invention, S15 may be specifically implemented by S151 to S152 shown in fig. 3, which are described in detail below:
s151: if the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service, acquiring all test time associated with the unique identification of the target micro-service from a preset test log table.
S152: and identifying the test time with the shortest time interval between the current time and the all test time as the first test time of the last functional test of the target micro-service.
In this embodiment, when the server detects that the current functional test of the target micro service by the process for performing the functional test on the target micro service is not the first functional test of the target micro service, all test times associated with the unique identifier of the target micro service are acquired from the test log table based on the unique identifier of the target micro service. After all the test times associated with the unique identification of the target micro-service are acquired, the server calculates the time interval between each acquired test time and the current time, determines the test time with the shortest time interval between the current time and the all the acquired test times, and identifies the test time with the shortest time interval between the current time and the all the acquired test times as the first test time of the last functional test of the target micro-service.
After determining the time interval between the first test time and the current time, the server compares the time interval with a preset duration threshold. The preset duration threshold is used for representing time generally required for bug fixes on the micro-service, and can be set according to actual conditions without limitation. For example, the preset duration threshold may be 24 hours to 48 hours. If the server detects that the time interval between the first test time and the current time is less than or equal to the preset duration threshold, the server indicates that the functional test on the target micro-service is the first case, and at this time, the server executes S16.
S16: and if the time interval between the first test time and the current time is smaller than or equal to a preset duration threshold value, acquiring an abnormal test case file associated with the unique identification of the target micro-service from a second test case library.
In this embodiment, if the server detects that the time interval between the first test time and the current time is less than or equal to the preset duration threshold, the server obtains an abnormal test case file associated with the unique identifier of the target micro-service from the second test case library. At least one abnormal test case file is stored in the second test case library. Different exception test files are used for storing test cases in which exceptions occur when different microservices are subjected to functional tests. The abnormal test case file has an association relationship with the unique identifier of the micro service to which the stored test case belongs. In practical application, the abnormal test case file may be in a text format or a table format, which is not limited herein.
The server may obtain an exception test case file associated with the unique identification of the target micro-service from the second test case library based on the unique identification of the target micro-service.
S17: and controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the abnormal test case file.
In this embodiment, after the server obtains the abnormal test case file associated with the unique identifier of the target micro service, the process for controlling the function test on the target micro service performs the function test on the target micro service based on the target executable program and all the test cases in the abnormal test case file.
Specifically, the abnormal test case file includes an abnormal entry file and an abnormal exit file. The abnormal input parameter file is used for storing values of input parameters included in each abnormal test case, and the abnormal output parameter file is used for storing values of output parameters included in each abnormal test case, that is, in this embodiment, values of input parameters and values of output parameters included in the same abnormal test case are stored in different files, that is, values of input parameters of all abnormal test cases are stored in the abnormal input parameter file, and values of output parameters of all abnormal test cases are stored in the abnormal output parameter file. It should be noted that, there is an association relationship between the values of the input parameters and the output parameters of the same test case in which an abnormality occurs, that is, the values of the input parameters and the output parameters of the same test case in which an abnormality occurs have the same test case identifier.
In this embodiment, when controlling a process for performing a functional test on a target micro service to perform a functional test on the target micro service based on a target executable program and all test cases included in an abnormal test case file, specifically, a server may obtain an abnormal entry file and an abnormal exit file from the abnormal test case file, after obtaining the abnormal entry file and the abnormal exit file, the server may call the target executable program of the target micro service through a test interface, sequentially take values of input parameters of each test case having an abnormality included in the abnormal entry file as inputs of the target executable program, execute the target executable program, and obtain an execution result corresponding to the values of the input parameters of each test case having an abnormality obtained after executing the target executable program. Based on the test case identification, the server acquires the value of the output parameter of each abnormal test case from the abnormal output parameter file, compares the execution result corresponding to the value of the input parameter of each abnormal test case with the value of the output parameter of the abnormal test case, and further completes the functional test of the target micro-service.
As can be seen from the foregoing, in the automatic testing method for a micro service provided in this embodiment, when it is detected that the process for performing a functional test on a target micro service does not perform the first functional test on the target micro service, and the time interval between the last functional test on the target micro service and the current time is less than or equal to the preset duration threshold, the functional test is performed on the target micro service only by using the test case in which the abnormality occurs during the last functional test on the target micro service, thereby further improving the testing efficiency.
Referring to fig. 4, fig. 4 is a flowchart illustrating an implementation of a method for automatically testing a micro service according to a fourth embodiment of the present invention. Compared with the corresponding embodiment of fig. 2, the automatic testing method for micro services provided in this embodiment further includes S18 to S19 after S15, and is described in detail as follows:
s18: and if the time interval between the first test time and the current time is greater than a preset duration threshold, acquiring a target test case file associated with the unique identifier of the target micro-service from a first test case library.
S19: and controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file.
In this embodiment, if the server detects that the time interval between the first test time and the current time is greater than the preset duration threshold, it indicates that the functional test on the target micro-service is the second case described in S15, at this time, the server obtains, from the first test case library, a target test case file associated with the unique identifier of the target micro-service, and controls a process for performing the functional test on the target micro-service, based on the target executable program and all test cases included in the target test case file, to perform the functional test on the target micro-service. It should be noted that, in this embodiment, the specific process of performing the functional test on the target micro service by the server is identical to S14, and the detailed description in S14 is omitted here.
As can be seen from the foregoing, in the automatic test method for a micro service provided in this embodiment, when it is detected that the process for performing a functional test on a target micro service does not perform the first functional test on the target micro service, and the time interval between the last functional test on the target micro service and the current time is greater than the preset duration threshold, the process for performing a functional test on the target micro service is controlled to perform a functional test on the target micro service based on the target executable program and the target test case file associated with the unique identifier of the target micro service and stored in the first test case library, thereby implementing an automatic test on the micro service function, saving labor cost, and improving the test efficiency of the micro service functional test.
Referring to fig. 5, fig. 5 is a flowchart illustrating an implementation of a method for automatically testing a micro service according to a fifth embodiment of the present invention. Compared with the corresponding embodiments of fig. 1 to 4, the automatic testing method for micro services provided in this embodiment further includes S20 to S21 after S14, and is described in detail as follows:
s20: and recording the test ending time of the process on the current functional test of the target micro-service, and identifying the test ending time as the test time of the current functional test of the target micro-service.
In this embodiment, in order to ensure that the functional test of the target micro-service is trace-searchable, the test time of each functional test of the target micro-service may be stored in a preset test log table.
Specifically, when the server detects that the current functional test of the target micro-service is finished by the process for performing the functional test on the target micro-service, the server records the time when the current functional test is finished, namely the test finishing time, and identifies the test finishing time as the test time of the current functional test of the target micro-service.
S21: and storing the test time of the current functional test of the target micro-service and the unique identification of the target micro-service in a test log table in a correlation manner.
In this embodiment, after determining the test time of the current functional test of the target micro service, the server stores the test time of the current functional test of the target micro service and the unique identifier of the target micro service in a preset test log table in an associated manner.
Therefore, it can be seen that when the automatic testing method for the micro service provided by the embodiment detects that the current functional test of the target micro service is finished, the testing finishing time of the current functional test of the target micro service is recorded, and the testing finishing time and the unique identifier of the target micro service are associated and stored in the testing log table, so that each functional test of the micro service is ensured to be trace-searchable.
Fig. 6 is a block diagram of a server according to an embodiment of the present invention, where the server includes units for performing steps in the embodiments corresponding to fig. 1 to 5. Please refer to fig. 1 to 5 and the related descriptions in the embodiments corresponding to fig. 1 to 5. For convenience of explanation, only the portions related to the present embodiment are shown. Referring to fig. 6, the server 600 includes: a first acquisition unit 61, a starting unit 62, a second acquisition unit 63 and a testing unit 64. Wherein:
The first obtaining unit 61 is configured to obtain, if it is detected that a new source program is compiled in a preset source program compiler, a unique identifier of a micro service represented by the source program from configuration information of the source program.
The starting unit 62 is configured to identify the executable program obtained by compiling the source program as a target executable program of the target micro service if the unique identifier of the micro service represented by the source program is the same as the unique identifier of the target micro service, and start a process for performing a functional test on the target micro service.
The second obtaining unit 63 is configured to obtain, if it is detected that the current functional test of the process on the target micro service is a first functional test of the target micro service, a target test case file associated with a unique identifier of the target micro service from a first test case library.
The test unit 64 is configured to control the process to perform a functional test on the target microservice based on the target executable program and all test cases in the target test case file.
The server 600 may further include a third acquisition unit and a fourth acquisition unit as an embodiment of the present invention. Wherein:
The third obtaining unit is used for obtaining a first test time of the last functional test of the target micro-service from a preset test log table if the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service;
the fourth obtaining unit is configured to obtain, from the second test case library, an abnormal test case file associated with the unique identifier of the target micro-service if the time interval between the first test time and the current time is less than or equal to a preset duration threshold.
The test unit 64 is further configured to control the process to perform a functional test on the target microservice based on the target executable program and all test cases in the abnormal test case file.
The server 600 may further include a fifth acquisition unit as an embodiment of the present invention.
And the fifth acquisition unit is used for acquiring a target test case file associated with the unique identification of the target micro-service from the first test case library if the time interval between the first test time and the current time is greater than a preset duration threshold.
The test unit 64 is further configured to control the process to perform a functional test on the target microservice based on the target executable program and all test cases in the target test case file.
As an embodiment of the present invention, the third acquisition unit specifically includes: and a test time acquisition unit and a first identification unit. Wherein:
the test time acquisition unit is used for acquiring all test times associated with the unique identification of the target micro-service from a preset test log table if the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service.
The first identifying unit is used for identifying the test time with the shortest time interval between the current time and the test time as the first test time of the last functional test of the target micro-service.
The server 600 may further include a recording unit and a storage unit as an embodiment of the present invention. Wherein:
the recording unit is used for recording the test ending time of the current functional test of the process on the target micro-service, and identifying the test ending time as the test time of the current functional test of the target micro-service.
The storage unit is used for storing the test time of the current functional test of the target micro-service and the unique identification of the target micro-service in a test log table in a correlated mode.
As can be seen from the foregoing, when a server provided in this embodiment detects that a preset source program compiler has a new source program compiled and completed, and the newly compiled source program is used to characterize a target micro-service, an executable program obtained by compiling the newly compiled source program is identified as a target executable program of the target micro-service, and a process for performing a functional test on the target micro-service is automatically started, and the process is controlled to perform a functional test on the target micro-service based on the target executable program and a target test case file associated with a unique identification of the target micro-service, thereby implementing an automatic test on a micro-service function, saving labor cost, and improving test efficiency of the micro-service functional test; meanwhile, when the current functional test of the target micro-service is detected to be the first functional test of the target micro-service, controlling the process for carrying out the functional test of the target micro-service based on all test cases in the target test case file, and carrying out the functional test of the target micro-service, thereby avoiding the occurrence of the missing test condition.
Fig. 7 is a block diagram of a server according to another embodiment of the present invention. As shown in fig. 7, the server 7 of this embodiment includes: a processor 70, a memory 71 and a computer program 72 stored in said memory 71 and executable on said processor 70, for example a program for an automatic test method of a premium calculation service. The processor 70, when executing the computer program 72, implements the steps of the above-described embodiments of the automatic test method for each premium calculation service, such as S11 to S14 shown in fig. 1. Alternatively, the processor 70 may implement the functions of each unit in the embodiment corresponding to fig. 6, for example, the functions of the units 61 to 64 shown in fig. 6, when executing the computer program 72, and the detailed description of the embodiment corresponding to fig. 6 will be referred to herein, which is omitted.
By way of example, the computer program 72 may be divided into one or more units, which are stored in the memory 71 and executed by the processor 70 to accomplish the present invention. The one or more units may be a series of computer program instruction segments capable of performing a specific function for describing the execution of the computer program 72 in the server 7. For example, the computer program 72 may be divided into a first acquisition unit, a start-up unit, a second acquisition unit and a test unit, each unit functioning specifically as described above.
The server may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of the server 7 and is not limiting of the server 7, and may include more or fewer components than shown, or may combine some components, or different components, e.g., the server may also include input and output devices, network access devices, buses, etc.
The processor 70 may be a central processing unit (Central Processing Unit, CPU), or may be another general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the server 7, such as a hard disk or a memory of the server 7. The memory 71 may be an external storage device of the server 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the server 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the server 7. The memory 71 is used for storing the computer program as well as other programs and data required by the server. The memory 71 may also be used for temporarily storing data that has been output or is to be output.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.

Claims (4)

1. An automatic test method for micro services, comprising:
if the fact that a new source program is compiled in a preset source program compiler is detected, acquiring a unique identifier of a micro-service represented by the source program from configuration information of the source program; the configuration information of the source program is stored in a header file of the source program;
if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as a target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service;
If the current functional test of the process on the target micro-service is detected to be the first functional test of the target micro-service, acquiring a target test case file associated with the unique identification of the target micro-service from a first test case library;
controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file;
and if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as the target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service, wherein the method further comprises the following steps:
if the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service, acquiring the first test time of the last functional test of the target micro-service from a preset test log table;
if the time interval between the first test time and the current time is smaller than or equal to a preset duration threshold value, acquiring an abnormal test case file associated with the unique identification of the target micro-service from a second test case library;
Controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the abnormal test case file;
if the current functional test of the process on the target micro service is detected not to be the first functional test of the target micro service, acquiring the first test time of the last functional test of the target micro service from a preset test log table, and then further including:
if the time interval between the first test time and the current time is greater than a preset duration threshold, acquiring a target test case file associated with the unique identifier of the target micro-service from a first test case library;
controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file;
if the current functional test of the process on the target micro service is detected not to be the first functional test of the target micro service, acquiring the first test time of the last functional test of the target micro service from a preset test log table, including:
if the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service, acquiring all test time associated with the unique identification of the target micro-service from a preset test log table;
And identifying the test time with the shortest time interval between the current time and the all test time as the first test time of the last functional test of the target micro-service.
2. The automatic test method of micro services according to claim 1, wherein the controlling the process further comprises, after performing the functional test on the target micro services based on the target executable program and all test cases in the target test case file:
recording the test ending time of the process on the current functional test of the target micro-service, and identifying the test ending time as the test time of the current functional test of the target micro-service;
and storing the test time of the current functional test of the target micro-service and the unique identification of the target micro-service in a test log table in a correlation manner.
3. A server comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the steps of when executing the computer program:
if the fact that a new source program is compiled in a preset source program compiler is detected, acquiring a unique identifier of a micro-service represented by the source program from configuration information of the source program; the configuration information of the source program is stored in a header file of the source program;
If the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as a target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service;
if the current functional test of the process on the target micro-service is detected to be the first functional test of the target micro-service, acquiring a target test case file associated with the unique identification of the target micro-service from a first test case library;
controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file;
and if the unique identifier of the micro-service represented by the source program is the same as the unique identifier of the target micro-service, identifying the executable program obtained by compiling the source program as the target executable program of the target micro-service, and starting a process for performing functional test on the target micro-service, wherein the method further comprises the following steps:
if the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service, acquiring the first test time of the last functional test of the target micro-service from a preset test log table;
If the time interval between the first test time and the current time is smaller than or equal to a preset duration threshold value, acquiring an abnormal test case file associated with the unique identification of the target micro-service from a second test case library;
controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the abnormal test case file;
if the current functional test of the process on the target micro service is detected not to be the first functional test of the target micro service, acquiring the first test time of the last functional test of the target micro service from a preset test log table, and then further including:
if the time interval between the first test time and the current time is greater than a preset duration threshold, acquiring a target test case file associated with the unique identifier of the target micro-service from a first test case library;
controlling the process to perform functional test on the target micro-service based on the target executable program and all test cases in the target test case file;
if the current functional test of the process on the target micro service is detected not to be the first functional test of the target micro service, acquiring the first test time of the last functional test of the target micro service from a preset test log table, including:
If the current functional test of the process on the target micro-service is detected not to be the first functional test of the target micro-service, acquiring all test time associated with the unique identification of the target micro-service from a preset test log table;
and identifying the test time with the shortest time interval between the current time and the all test time as the first test time of the last functional test of the target micro-service.
4. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method according to any one of claims 1 to 2.
CN201810917613.XA 2018-08-13 2018-08-13 Automatic testing method for micro-service, server and computer readable storage medium Active CN109189672B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810917613.XA CN109189672B (en) 2018-08-13 2018-08-13 Automatic testing method for micro-service, server and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810917613.XA CN109189672B (en) 2018-08-13 2018-08-13 Automatic testing method for micro-service, server and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN109189672A CN109189672A (en) 2019-01-11
CN109189672B true CN109189672B (en) 2024-03-29

Family

ID=64921660

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810917613.XA Active CN109189672B (en) 2018-08-13 2018-08-13 Automatic testing method for micro-service, server and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN109189672B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112416757B (en) * 2020-11-03 2021-11-12 前海飞算云智软件科技(深圳)有限公司 Component development method, device, storage medium and electronic equipment
CN112685321A (en) * 2021-01-11 2021-04-20 河南中原消费金融股份有限公司 Method, system and storage medium for testing microservice

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1932776A (en) * 2006-09-29 2007-03-21 上海科泰世纪科技有限公司 Automatic operating method for interface test in embedded operating system
WO2013139081A1 (en) * 2012-03-21 2013-09-26 天津书生软件技术有限公司 Method for managing test cases
CN103377123A (en) * 2012-04-25 2013-10-30 腾讯科技(深圳)有限公司 Automatic test method and device for web page codes
CN104731701A (en) * 2013-12-23 2015-06-24 展讯通信(上海)有限公司 Test system and method and device for executing test tasks
CN105938453A (en) * 2016-04-14 2016-09-14 上海斐讯数据通信技术有限公司 Automatic test method and system
CN106293704A (en) * 2016-07-26 2017-01-04 北京北森云计算股份有限公司 Dynamic micro services edit methods, device and the server of multilingual cloud compiling
US9781122B1 (en) * 2016-05-11 2017-10-03 Oracle International Corporation Multi-tenant identity and data security management cloud service
CN108038051A (en) * 2017-11-03 2018-05-15 深圳市牛鼎丰科技有限公司 Dissemination method, device, computer equipment and the storage medium of micro services
CN108279892A (en) * 2018-02-27 2018-07-13 郑州云海信息技术有限公司 It is a kind of to split the method, apparatus and equipment that large-scale application service is micro services

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090282136A1 (en) * 2008-05-08 2009-11-12 Oracle International Corporation Automatic Generation of Web Service client for Web Services Interoperability Testing
US11323508B2 (en) * 2009-05-22 2022-05-03 Comcast Interactive Media, Llc Web service system and method

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1932776A (en) * 2006-09-29 2007-03-21 上海科泰世纪科技有限公司 Automatic operating method for interface test in embedded operating system
WO2013139081A1 (en) * 2012-03-21 2013-09-26 天津书生软件技术有限公司 Method for managing test cases
CN103377123A (en) * 2012-04-25 2013-10-30 腾讯科技(深圳)有限公司 Automatic test method and device for web page codes
CN104731701A (en) * 2013-12-23 2015-06-24 展讯通信(上海)有限公司 Test system and method and device for executing test tasks
CN105938453A (en) * 2016-04-14 2016-09-14 上海斐讯数据通信技术有限公司 Automatic test method and system
US9781122B1 (en) * 2016-05-11 2017-10-03 Oracle International Corporation Multi-tenant identity and data security management cloud service
CN106293704A (en) * 2016-07-26 2017-01-04 北京北森云计算股份有限公司 Dynamic micro services edit methods, device and the server of multilingual cloud compiling
CN108038051A (en) * 2017-11-03 2018-05-15 深圳市牛鼎丰科技有限公司 Dissemination method, device, computer equipment and the storage medium of micro services
CN108279892A (en) * 2018-02-27 2018-07-13 郑州云海信息技术有限公司 It is a kind of to split the method, apparatus and equipment that large-scale application service is micro services

Also Published As

Publication number Publication date
CN109189672A (en) 2019-01-11

Similar Documents

Publication Publication Date Title
US9672029B2 (en) Determining test case priorities based on tagged execution paths
US10061685B1 (en) System, method, and computer program for high volume test automation (HVTA) utilizing recorded automation building blocks
US9898387B2 (en) Development tools for logging and analyzing software bugs
US20140365990A1 (en) Software evaluation device and method
US10049031B2 (en) Correlation of violating change sets in regression testing of computer software
US11748245B2 (en) Object-oriented regression-candidate filter
US10579513B2 (en) Test run control method and apparatus
CN109471768B (en) Service problem monitoring method and device and electronic equipment
US11748072B2 (en) Apparatus and method for source code optimisation
CN109189672B (en) Automatic testing method for micro-service, server and computer readable storage medium
JP2015011372A (en) Debug support system, method, program, and recording medium
JP2011145824A (en) Information processing apparatus, fault analysis method, and fault analysis program
US10474443B2 (en) Code lineage tool
US9734458B2 (en) Predicting outcome based on input
US20100306745A1 (en) Efficient Code Instrumentation
CN109240906B (en) Database configuration information adaptation method and device, computer equipment and storage medium
CN111143229A (en) Software testing method and device, computer equipment and computer readable storage medium
US11874688B2 (en) Identification of diagnostic messages corresponding to exceptions
US9311080B2 (en) Instrumented file deployment
JP2012256279A (en) Information processing device, method, and program
CN107943676B (en) Performance test data processing method and device for operating nonvolatile memory by application
US20220229766A1 (en) Development of applications using telemetry data and performance testing
US8751870B2 (en) Method and system for providing a random sequence coverage
JP2021005294A (en) Information processing apparatus and debugging program
US20130007528A1 (en) Using reverse time for coverage analysis

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