CN115129574A - Code testing method and device - Google Patents

Code testing method and device Download PDF

Info

Publication number
CN115129574A
CN115129574A CN202110313760.8A CN202110313760A CN115129574A CN 115129574 A CN115129574 A CN 115129574A CN 202110313760 A CN202110313760 A CN 202110313760A CN 115129574 A CN115129574 A CN 115129574A
Authority
CN
China
Prior art keywords
code
test
difference information
update
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110313760.8A
Other languages
Chinese (zh)
Inventor
顾况
张钊晋
吴涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110313760.8A priority Critical patent/CN115129574A/en
Publication of CN115129574A publication Critical patent/CN115129574A/en
Pending legal-status Critical Current

Links

Images

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/3676Test management for coverage analysis
    • 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/368Test management for test version control, e.g. updating test cases to a new software version
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Abstract

The embodiment of the application discloses a code testing method and device, and relates to the technical field of communication. By receiving a test instruction, acquiring a pre-stored first code and a second code from a local according to the test instruction, comparing the difference between the first code and the second code to obtain difference information between the first code and the second code, uploading the difference information to a target storage position, and finally sending a test request to a test server to trigger the test server to acquire the difference information from the target storage position indicated by a target storage address through the test request, acquire the second code from a remote database indicated by the storage address, and test the first code according to the second code, the difference information and test configuration information, the local code can be tested without submitting the local code to the remote database, and the efficiency of testing the code is improved.

Description

Code testing method and device
Technical Field
The present application relates to the field of communications technologies, and in particular, to a code testing method and apparatus.
Background
The continuous integration refers to a series of processes such as testing, building and the like before the locally submitted codes are combined into the main branch after the codes are submitted to the remote warehouse, generally, the remote warehouse is monitored, and when the codes are submitted in the remote warehouse, the submitted codes are tested; or a timed trigger to test code updated in the remote repository.
The inventor of the application finds that monitoring the remote warehouse triggering test or the timing triggering test can trigger the automatic testing process only by submitting the codes to the remote warehouse, the codes submitted to the remote warehouse are not tested, the correctness of the codes stored in the remote warehouse cannot be guaranteed, and the testing efficiency is low.
Disclosure of Invention
The embodiment of the application provides a code testing method and device, which can test a local code without submitting the local code to a remote warehouse under the condition that a local testing environment is not required to be configured, and the efficiency of testing the code is improved.
The code testing method provided by the embodiment of the application comprises the following steps:
receiving a test instruction, and acquiring a pre-stored first code and a second code from the local according to the test instruction, wherein the first code is a new version code obtained by updating the second code, and the test instruction carries a target address;
comparing the difference between the first code and the second code to obtain difference information between the first code and the second code, and uploading the difference information to a target storage position indicated by the target address;
sending a test request to the test server, where the test request carries a storage address of the second code, the target address, and test configuration information, and the test request is used to trigger the test server to obtain the difference information from a target storage location indicated by the target address, obtain the second code from a remote database indicated by the storage address, and test the first code according to the second code, the difference information, and the test configuration information.
The code testing method provided by the embodiment of the application is applied to a testing server and comprises the following steps:
receiving a test request for testing a first code, wherein the test request carries a storage address of a second code in a remote database, a target address of difference information and test configuration information, the first code is a new version code obtained by updating the second code, the remote database is used for managing codes, and the difference information is the difference information between the first code and the second code;
acquiring the difference information from a target storage position indicated by the target address according to the test request, and acquiring the second code from the remote database indicated by the storage address;
generating the first code according to the second code and the difference information;
and constructing a test environment according to the test configuration information, and testing the first code in the test environment.
Correspondingly, an embodiment of the present application further provides a code testing apparatus, including:
a receiving unit: the system comprises a first code and a second code, wherein the first code is a new version code obtained by updating the second code, and the test instruction carries a target address;
a comparison unit: the device comprises a first code, a second code and a storage location, wherein the first code is used for storing a first address and a second address, the second code is used for storing a second code, and the first code and the second code are used for comparing the difference between the first code and the second code to obtain difference information between the first code and the second code and uploading the difference information to a target storage location indicated by the target address;
a transmission unit: the test request is used for triggering the test server to acquire the difference information from a target storage position indicated by the target address, acquire the second code from a remote database indicated by the storage address, and test the first code according to the second code, the difference information and the test configuration information.
Correspondingly, an embodiment of the present application further provides a code testing apparatus, which is applied to a testing server, and includes:
an instruction receiving unit: the system comprises a remote database and a test module, wherein the remote database is used for receiving a test request for testing a first code, the test request carries a storage address of a second code in the remote database, a target address of difference information and test configuration information, the first code is a new version code obtained based on updating the second code, the remote database is used for managing codes, and the difference information is difference information between the first code and the second code;
an acquisition unit: the second code is used for acquiring the difference information from a target storage position indicated by the target address according to the test request and acquiring the second code from the remote database indicated by the storage address;
a generation unit: for generating the first code from the second code and the difference information;
a test unit: and the test configuration information is used for constructing a test environment according to the test configuration information and testing the first code in the test environment.
Correspondingly, the embodiment of the application also provides computer equipment, which comprises a memory and a processor; the memory stores a computer program, and the processor is used for operating the computer program in the memory to execute any code testing method provided by the embodiment of the application.
Correspondingly, the embodiment of the present application further provides a storage medium, where the storage medium is used to store a computer program, and the computer program is loaded by a processor to execute any one of the code testing methods provided by the embodiment of the present application.
As can be seen from the above, in the embodiment of the application, by receiving a test instruction, a pre-stored first code and a pre-stored second code are obtained from a local area according to the test instruction, then differences between the first code and the second code are compared to obtain difference information between the first code and the second code, the difference information is uploaded to a target storage location indicated by a target address, and finally, a test request is sent to a test server to trigger the test server to obtain the difference information from the target storage location indicated by the target storage address through the test request, and obtain the second code from a remote database indicated by the storage address, and the first code is tested according to the second code, the difference information, and test configuration information. According to the scheme, the difference information between the first code and the second code is obtained through comparison, so that the remote server can obtain the first code according to the difference information and the second code in the remote database and test the first code, the local code (namely the first code) can be tested without being submitted to a remote warehouse, and the efficiency of testing the code is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of a scenario of a code testing method provided in an embodiment of the present application;
FIG. 2 is a flowchart of a code testing method provided by an embodiment of the present application;
FIG. 3 is another flowchart of a code testing method provided by an embodiment of the present application;
FIG. 4 is a flowchart of a code testing method provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of a code testing apparatus provided in an embodiment of the present application;
FIG. 6 is a block diagram of a code test framework provided in an embodiment of the present application;
FIG. 7 is another schematic diagram of a code testing apparatus provided in an embodiment of the present application;
fig. 8 is a schematic structural diagram of a computer device provided in an embodiment of the present application.
Detailed Description
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 obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
The embodiment of the application provides a case ratio query method and device based on a block chain, computer equipment and a storage medium. The case ratio query device may be integrated into a computer device, and the computer device may be a server or a terminal. The terminal can comprise a mobile phone, a wearable intelligent device, a tablet Computer, a notebook Computer, a Personal Computer (PC), a vehicle-mounted Computer and the like; the server can be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and can also be a cloud server for providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, big data and artificial intelligence platform and the like.
For example, as shown in fig. 1, a computer device obtains a pre-stored first code and a pre-stored second code from a local according to a test instruction, compares a difference between the first code and the second code to obtain difference information between the first code and the second code, uploads the difference information to a target storage location, and finally sends a test request to a test server to trigger the test server to obtain the difference information from the target storage location indicated by a target storage address through the test request, and obtains the second code from a remote database indicated by the storage address, and tests the first code according to the second code, the difference information, and test configuration information. According to the scheme, the difference information between the first code and the second code is obtained through comparison, so that the remote server can obtain the first code according to the difference information and the second code in the remote database, the first code is tested, the local code can be tested without submitting the local code to a remote warehouse, and the efficiency of testing the code is improved.
The following are detailed below. It should be noted that the following description of the embodiments is not intended to limit the preferred order of the embodiments.
The embodiment will be described from the perspective of an image processing apparatus, which may be specifically integrated in a computer device, and the computer device may be a server, or may be a terminal or other devices.
In an embodiment of the present application, a code testing method may be executed by a processor of a computer device, as shown in fig. 2, a specific process of the code testing method may be as follows:
101. and receiving a test instruction, and acquiring a pre-stored first code and a second code from the local according to the test instruction, wherein the first code is a new version code obtained by updating the second code, and the test instruction carries a target address.
The test instruction may be a code which is input by a user through the terminal and instructs the computer device to execute a specific operation, or may be a code which is generated by the terminal in response to an operation behavior of the user on a display page displayed by the terminal.
The second code may be an application program written in a programming language to implement a function or provide a service, and the second code may be pulled from a remote database to a local database by a user.
The remote database may refer to a database running on another computer in the same network, for example, a Git repository of a code hosting platform gitubb, or a SVN repository of a version control system SVN, and a user may clone content in the remote database from gitubb or SVN to a local place completely, or the remote database may be referred to as a remote repository.
The first code may be a new version code obtained by creating a branch at the terminal and modifying the second code, the first code may be a new code obtained by repairing a code bug and a code error existing in the second code, or a new code obtained by adding some functions and services on the basis of the second code. The first code may be stored in a storage medium of a computer device, such as a storage medium of a terminal, or a database of a server, or may be stored in a database (which may also be referred to as a third-party database) provided by a third party (which may not be a remote party).
For example, the first code and the second code may be obtained from a storage medium of the terminal after receiving a test instruction input by a user through the terminal.
In an embodiment, the test instruction may carry a first storage address of the first code and a second storage address of the second code, and after receiving the test instruction input by the user, the first code is obtained according to the first storage address, for example, the first storage address indicates a storage medium of the terminal, the first code is obtained from the storage medium, and if the first storage address indicates a database of a third party, the first code is obtained from the database of the third party; acquiring a second code according to a second storage address, for example, if the second storage address is a remote database address, pulling the second code from the remote database, and if the second storage address is a storage medium of the terminal, acquiring the second code from the storage medium; other storage cases are obtained by referring to the above manner of obtaining the code.
Optionally, the first storage address and the second storage address may be preset by a user, and when the user inputs a test instruction, the terminal acquires the preset first storage address and the preset second storage address, acquires the first code according to the first storage address, and acquires the second code according to the second storage address. Or after the middle terminal acquires the first storage address and the second storage address, the first storage address, the second storage address and the test instruction are sent to the server, and the server acquires the first code and the second code according to the first storage address and the second storage address respectively.
The first storage address and the second storage address may also be included in the test instruction input by the user, that is, the test instruction input by the user includes the first storage address and the second storage address.
In addition, the target address may be preset by the user or included in the test instruction input by the user.
102. And comparing the difference between the first code and the second code to obtain difference information between the first code and the second code, and uploading the difference information to a target storage position indicated by the target address.
Wherein the difference information may comprise code updated by the first code on the basis of the second code.
The target address may indicate a storage location where the difference information is stored, for example, the target address may be an address of a terminal storage medium, or may be a database address provided by a third party (which may not be a remote party), and the user may set the target address according to the actual location where the difference information is stored.
For example, each line of codes of the first code and the second code may be compared, the modifications made by the developer to the second code, such as the deleted code and the newly added code, that is, the updated content of the first code, is determined, the difference information between the first code and the second code is obtained, and the difference information is sent to the target storage location indicated by the target address carried by the test instruction.
Specifically, the first code and the second code may be compared, and the code of the first code that is updated compared with the second code, the update type of the code, and the corresponding position of the code in the second code are determined, that is, in an embodiment, the step "compare the difference between the first code and the second code to obtain the difference information between the first code and the second code" may specifically be:
comparing the first code with the second code to obtain an update code updated by the first code relative to the second code, an update type of the update code and an update position corresponding to the update code in the second code;
and determining difference information between the first code and the second code according to the update code, the update type and the corresponding update position of the update code in the second code.
The update code may be a code that is updated based on a change made to the first code by the second code.
The update type may be a type of code update for the first code compared with the second code, for example, the update type may be an operation type of adding, deleting, modifying, and the like on the basis of the second code.
Wherein the corresponding location may indicate that the update code of the first code is a location on the second code where the operation indicated by the update type was performed.
For example, specifically, the code of the first code and the code of the second code are compared, it is determined that the first code is obtained by performing an operation of indicating an update type on the update code at the update position of the second code, for example, the first code is obtained by adding 3 lines of update code a after the k line of the second code, deleting the m line to the x line of the second code, and modifying the e line of the second code into the update code C.
The updated code A can be obtained, the updating type is newly increased, and the updating position is the kth line of the second code; the m line to x line codes of the second code are updating codes B, the updating type is deletion, and the updating positions are the m line to x line; and updating the code C, wherein the updating type is modification, and the changing position is the e-th line.
And generating difference information according to the update code, the update type and the update position, wherein the difference information can comprise the update code of which the first code is updated compared with the second code, the update type of the update code and the corresponding update position of the update code in the second code.
Optionally, the difference information may further include a code that updates the first code at the location, and a code that updates the second code at the location.
The update type of the update code may be determined based on a difference between the first code and the second code at the update location.
When the first code and the second code are compared, the code file of the second code corresponding to the code file in the first code needs to be determined first, and the codes of the two corresponding code files are compared, that is, in an embodiment, the step "compare the first code with the second code to obtain an update code for updating the first code relative to the second code, an update type of the update code, and an update position of the update code corresponding to the second code" may specifically be:
traversing the code files of the first code and the second code, and determining the corresponding relation between the code file in the first code and the code file in the second code;
and comparing the difference between the code file in the first code and the corresponding code file in the second code based on the corresponding relation, and determining the updating code for updating the first code relative to the second code, the updating type of the updating code and the corresponding position of the updating code in the second code.
The code file may be a file comprising part of the code in the first code, i.e. the first code comprises a code file.
For example, the method may specifically be to traverse code files of the first code and the second code, and query a code file with the same file name of the first code and the second code, where two code files with the same file name are code files with a corresponding relationship.
And comparing the codes of the two code files, and determining an updating code for updating the code file in the first code compared with the code file of the code file in the second code, the updating type and the updating position of the updating code.
Optionally, if the code file in the first code is a code file in the second code, the two files are code files having a corresponding relationship although the file names of the two files are different, and the file name of the code file in the second code is modified into the file name of the code file in the first code in the process of obtaining the first code according to the difference information and the second code.
If the code file of the first code file is a newly added code file, the second code file does not have a corresponding code file or the corresponding code file is a blank code file, and the update code can be determined to be the code file without comparison, and the update type is newly added; the comparison process of the deleted code file can refer to the newly added code file.
By comparing the codes of the first code and the second code, obtaining a difference between the first code and the second code, that is, determining difference information between the first code and the second code, and uploading the difference information to a target storage location, in order to increase an uploading speed and improve a testing efficiency of the first code, the difference information may be compressed before being uploaded to the target storage location, that is, in an embodiment, the step "determining the difference information between the first code and the second code according to an update code, an update type, and an update location of the update code corresponding to the second code" may specifically be:
determining initial difference information between the first code and the second code according to the update code, the update type and the corresponding update position of the update code in the second code;
and compressing the initial difference information to obtain difference information.
The initial difference information is difference information that is not compressed.
For example, the initial difference information between the first code and the second code may be determined according to the update code, the update type, and the corresponding update location of the update code in the second code, and the obtained initial difference information may be compressed by using a compression tool, such as jszip and adm-zip, or may be another compression tool, such as WinRAR, to obtain the difference information.
103. And sending a test request to a test server, wherein the test request carries a storage address, a target address and test configuration information of the second code, and the test request is used for triggering the test server to acquire the difference information from the target storage position indicated by the target address and acquire the second code from a remote database indicated by the storage address, and testing the first code according to the second code, the difference information and the test configuration information.
The test server may be an automation test server, and may be used to automate various tasks, such as building, testing (e.g., integration, unit, and functional testing), deploying software, and the like, such as Jenkins, Circle CI, Travis CI, or GitLab CI.
The test request may be a request message that carries a storage address, a target address, and test configuration information of the second code and indicates the test server to test the first code.
The storage address is a storage position of the second code in a remote database, and the remote database may be a Git warehouse of a code hosting platform gitubs, and the remote database may also be a SVN warehouse of the version control system SVN.
The test configuration information may include information, such as codes, related parameters, and dependency packages, required by the test server to construct the test environment for performing the code test.
For example, after storing the difference information to the target storage location indicated by the target address, sending a test request to the test server to trigger the test server to obtain the difference information from the target storage location indicated by the target address, and obtain the second code from the remote database indicated by the storage address, and test the first code according to the second code, the difference information, and the test configuration information.
The test configuration information may be specified by a user through a test instruction, for example, may specify a location where the test configuration information is stored, that is, in an embodiment, before the step "sending a test request to a test server", the method includes:
if the first identification information carried by the test instruction is first target identification information, acquiring target test configuration information corresponding to the first target identification information, and taking the target test configuration information as test configuration information;
and if the first identification information carried by the test instruction is not the first target identification information, acquiring preset test configuration information, and taking the preset test configuration information as the test configuration information.
The first identification information may indicate whether the user specifies the test configuration information, and the first identification information may be in the form of a parameter or a storage address of the test configuration information.
The first target identification information may be a parameter indicating that the user specifies the test configuration information, or may be a storage address of the test configuration information specified by the user.
For example, if the parameter 0 indicates that the user does not specify the test configuration information, and the parameter 1 indicates that the user specifies the test configuration information, the first target identification information is 1.
If the first identification information is blank, the user does not specify the test configuration information, the first identification information is a storage address, the user specifies the test configuration information, and the first target identification information is the storage address.
For example, the test request may specifically carry first identification information, and by determining whether the first identification information is target first identification information, if the first identification information is first target identification information, that is, user-specified test configuration information, the target test configuration information is obtained from a storage address of the target test configuration information according to the first target identification information, and if the first identification information is not the first target identification information, the preset test configuration information is obtained.
The preset configuration information may be preset by a user, for example, the user configures a storage address of the preset configuration information in advance, if the first identification information is not the first target identification information, that is, the user does not specify the test configuration information, the preset configuration information is obtained by obtaining the storage address configured in advance by the user, or the preset configuration information is preset in a computer program of the computer device, for example, in the computer program in which the storage address of the preset configuration information is preset, if the first identification information is not the first target identification information, the preset test configuration information indicated by the storage address preset in the computer program is obtained, or the preset test configuration information in the computer program is directly obtained.
And taking the obtained target test configuration information (or preset test configuration information) as test configuration information.
As can be seen from the above, in the embodiment of the application, by receiving a test instruction, a pre-stored first code and a pre-stored second code are obtained from a local area according to the test instruction, then differences between the first code and the second code are compared to obtain difference information between the first code and the second code, the difference information is uploaded to a target storage location indicated by a target address, and finally, a test request is sent to a test server to trigger the test server to obtain the difference information from the target storage location indicated by the target storage address through the test request, and obtain the second code from a remote database indicated by the storage address, and the first code is tested according to the second code, the difference information, and test configuration information. According to the scheme, the difference information between the first code and the second code is obtained through comparison, so that the remote server can obtain the first code according to the difference information and the second code in the remote database, the first code is tested, the local code can be tested without submitting the local code to a remote warehouse, and the efficiency of testing the code is improved.
On the basis of the above-described embodiments, further details will be given below by way of example.
The present embodiment will be described from the perspective of a code testing apparatus, which may be specifically integrated in a server, and the server may be a testing server, such as Jenkins, Circle CI, Travis CI, or GitLab CI.
In an embodiment of the present application, a code testing method may be executed by a processor of a server, as shown in fig. 3, a specific flow of the code testing method may be as follows:
201. receiving a test request for testing a first code, wherein the test request carries a storage address of a second code in a remote database, a target address of difference information and test configuration information, the first code is a new version code obtained based on updating the second code, the remote database is used for managing the codes, and the difference information is the difference information between the first code and the second code.
The test configuration information may include information, such as codes and related parameters, required by the test server to construct the test environment for performing the code test.
For example, the specific method may be to receive a test request sent through a network or in other manners.
202. And acquiring the difference information from the target storage position indicated by the target address according to the test request, and acquiring the second code from a remote database indicated by the storage address.
For example, the test server may specifically receive the test request, obtain the difference information from the target storage location indicated by the target address according to the target address carried in the test request, and obtain the second code from the remote database.
In one embodiment, the test server may construct a test by obtaining the second code from the remote database, downloading the difference information, and obtaining the first code from the second code and the difference information to test the first code.
The test pipeline can realize the processes of automatic construction, automatic deployment, automatic test, automatic output of test reports and the like.
The test server can determine whether to directly test the second code of the remote database or obtain the first code by acquiring the difference information and the second code of the remote database through the second identification information, and test the first code. That is, in one embodiment, the step of "obtaining difference information from the target storage location indicated by the target address and obtaining the second code from the remote database indicated by the storage address according to the test request" may be specifically to obtain the difference information from the target storage location indicated by the target address and obtain the second code from the remote database indicated by the storage address
And if the second identification information is second target identification information, acquiring the difference information from the target storage position indicated by the target address according to the test request, and acquiring a second code from a remote database indicated by the storage address.
The second identification information may be used to indicate whether the user wants to test the local first code, and the first identification information may be in the form of a parameter or the like.
The second target identification information may be a first code indicating that the user requests to test the local, for example, if a parameter 0 indicates that the user requests the first code to be local, and a parameter 1 indicates that the user requests the second code in the remote database, the first target identification information is 0. For example, if the second identification information is second target identification information, the difference information is obtained from the target storage location indicated by the target address according to the test request, the second code is obtained from the remote database, and the difference information is applied to the second code to obtain the first code.
In an embodiment, if the second identification information is not the second target identification information, the second code is obtained from the remote database according to the storage address of the second code, and the second code is used as the first code.
For example, if the code that the user wants to test is a code newly developed according to the requirement (i.e., not a new version code obtained on the basis of the original version), the code is difference information, so that the code pushed into the remote database can be directly tested without obtaining the corresponding code according to the difference information, that is, the second code in the database is used as the first code, and the first code is tested.
203. A first code is generated based on the second code and the difference information.
For example, the difference information may be specifically applied to the second code, for example, a part of the code of the second code is deleted according to the difference information, and a part of the code is added to the second code, and the added part of the code may be included in the difference information.
The difference information may further include an update code that is updated by the first code with respect to the second code, an update type of the update code, and an update location of the update code corresponding to the second code. That is, in an embodiment, the step "generating the first code according to the second code and the difference information" may specifically be:
when the difference information comprises the update code with the newly increased update type, adding the update code with the newly increased update type in the difference information to the update position corresponding to the second code;
when the difference information includes an update code whose update type is deleted, deleting, in the second code, a code corresponding to the update code whose update type is deleted in the difference information;
when the difference information includes an update code of which the update type is modified, modifying, in the second code, a code corresponding to the update code of which the update type is modified in the difference information to obtain a first code.
The update type is newly added, which can indicate that the update code does not exist in the second code and needs to be supplemented into the second code; the update type being delete may indicate that the same code as the update code in the second code is deleted; the update type being a modification may indicate that a code of the update location in the second code is modified to an update code.
For example, the update code whose update type is new may be added to the position in the second code indicated by the update position; deleting the code corresponding to the update code of which the update type is deleted in the second code; and modifying the code at the position corresponding to the updating position in the second code into an updating code with the updating type being modified, and applying all the updating codes in the difference information to the second code to obtain the first code.
204. And constructing a test environment according to the test configuration information, and testing the first code in the test environment.
Therein, a test environment may refer to a description of the software and hardware environment in which the first code is run under test, as well as any other software that interacts with the first code, including drivers and stubs. The test environment is a generic term for computer hardware, software, network devices, and historical data necessary to perform the first code test.
For example, the specific step may be to construct a test environment according to the test configuration information, and perform a test on the first code in the test environment, for example, a unit test, an integration test, an end-to-end test, and a software availability test.
In one embodiment, after the first code is compiled, the compiled first code is tested in a test environment.
Wherein the unit test may be a test of a function or a module for the first code; the integration test may be a test for a certain function of the first code, which is also called a functional test; the end-to-end test may be a full link test in the first code from the user interface directly to the database.
As can be seen from the above, the test server in the embodiment of the application obtains the difference information from the target storage location indicated by the target address according to the test request by receiving the test request for testing the first code, obtains the second code from the remote database indicated by the storage address, generates the first code according to the second code and the difference information, constructs the test environment according to the test configuration information, and tests the first code in the test environment. According to the scheme, the first code is obtained through the difference information between the first code and the second code in the remote database, the first code is tested, the local code can be tested without being submitted to a remote warehouse, and the efficiency of testing the code is improved.
On the basis of the above-described embodiments, further details will be given below by way of example.
The present embodiment will be described from the perspective of a code testing system, which may include a terminal and a testing server, where the terminal may be the terminal for executing the code testing method in the above embodiment, and the testing server may be the testing server for executing the code testing method in the above embodiment. The terminal may include a mobile phone, a wearable smart device, a tablet Computer, a notebook Computer, a Personal Computer (PC), and a vehicle-mounted Computer, etc.
The code testing method provided by the embodiment of the application can be executed by a processor of a terminal and a processor of a testing server. As shown in fig. 4, the specific flow of the code testing method may be as follows:
301. and the terminal receives the test instruction.
For example, the test instruction input by the user on the console on the terminal may be received, where the console may be a work area where the user writes a code on the terminal, the user may create a branch by inputting the code instruction on the console, modify the second code to obtain a first code based on the second code, and after the user finishes modifying the second code, input the test instruction, and trigger the terminal to execute a subsequent step in response to the test instruction.
302. The terminal acquires initial difference information between the first code and the second code.
For example, after the terminal receives the test instruction, the instruction instructs the relevant application program on the terminal to compare the difference between the first code and the second code to obtain the difference between the first code and the second code, and determine the initial difference information between the first code and the second code. For example, it may be that initial difference information between the first code and the second code returned by the version management Git by comparing the difference between the first code and the second code is acquired by sending a gitdiff instruction to the version management system Git.
The first code is stored in a storage medium of the terminal, and the second code may be stored in a storage medium of the terminal, and specifically may be stored in a database that the user may clone from gitubb to the local, so the first code and the second code may be obtained locally, the first code may also be obtained locally, the second code may be obtained from a remote database, and the comparison is performed, which is not limited herein.
303. And the terminal compresses the initial difference information to obtain difference information.
For example, the obtained initial difference information may be compressed by a compression tool jszip or adm-zip to obtain the difference information, and the branch ID of the branch where the second code is located is used as the file name of the difference information obtained by the compression, where the ID may be in the form of a hash value.
In an embodiment, the initial difference information may be used as the difference information without performing compression processing on the initial difference information.
304. And the terminal uploads the difference information to a target database.
For example, the difference information may be specifically sent to the target database. Where the target database may be the target storage location indicated by the target address.
305. The terminal triggers the test server to start the pipeline to test the first code.
For example, the terminal may specifically determine whether a test instruction input by a user has a storage path specifying target test configuration information, if the test instruction includes the storage path specifying the target test configuration information, the terminal acquires the target test configuration information under the storage path and uses the test configuration information as the test configuration information, and if the test instruction does not specify the storage path specifying the target configuration information, the terminal acquires preset test configuration information as the test configuration information.
And after the terminal obtains the test configuration information, the terminal triggers the test server to start the pipeline through the interface so as to test the first code.
The test configuration information may include information, such as codes, related parameters, and dependency packages, required by the test server to construct the test environment for performing the code test. The preset test configuration information may be test configuration information required by a default test mode such as unit test, end-to-end test, and the like, for example, the preset test configuration information may be test configuration information required by a default unit test through jest, and then the preset test configuration information may include information such as a dependent packet required by the operation of jest.
The test configuration information may also include plug-ins and the like that are required by the test server to execute the script file.
306. The test server obtains a second code in the remote database.
For example, the remote repository may be pulled according to an address of the remote database carried by the test request, for example, the git repository may be pulled from the remote database by a git instruction, and the git repository includes the second code and a branch where the second code is located.
307. The test server determines whether there is a code change.
For example, the test server may specifically determine whether a code is changed according to a test request sent by the terminal, that is, determine whether to test the first code or the second code, and if the second identification information is the second target identification information, it indicates that the code is changed; and if the second identification information is not the second target identification information, indicating that no code is changed.
The terminal determines, according to the test instruction input by the user, whether a code that the user needs to test is a local first code or a second code in a remote database, that is, the user does not update the second code, and then generates the test request according to the second identification information.
The test request may carry the second identification information, or may carry other forms of information that may indicate the second identification information.
Wherein, the second identification information may be in the form of parameters and the like.
308. If the code is changed, the test server acquires difference information; if there is no code change, the test server performs step 310.
For example, if the code is not changed, that is, the second identification information carried in the test request is not the second target identification information, the test server executes step 310 to perform an automated test on the second code in the remote database.
If the code is changed, that is, the second identification information is the second target identification information, the test server obtains the difference information from the target storage location indicated by the target address, and then step 309 is executed.
309. The test server generates a first code based on the difference information and the second code.
The difference information may further include an update code that is updated by the first code with respect to the second code, an update type of the update code, and an update location of the update code corresponding to the second code.
For example, the method may specifically include, after obtaining the target difference information from the target storage address indicated by the target address, decompressing the target difference information, extracting a compressed file name of the difference information, determining a branch where the second code is located according to the address of the remote database carried in the test request and the extracted compressed file name, and applying the difference information to the second code on the branch.
The applying the difference information to the second code may specifically be adding an update code of which the update type is new in the difference information to a position in the second code indicated by the update position; deleting the code corresponding to the update code with the update type of deletion in the difference information in the second code; and modifying the code of the position corresponding to the updated position in the second code into the updated code of which the updating type is modified in the difference information.
And applying all the updated codes in the difference information to the second codes to obtain the first codes.
310. And the test server performs automatic test.
For example, a test environment may be specifically constructed according to the test configuration information, and the first code is tested in the test environment through a pipeline, for example, a unit test, an integration test, an end-to-end test, a software availability test, and the like.
In one embodiment, after the first code is compiled, the compiled first code is tested through a pipeline in a test environment.
311. And the test server sends a test report to the terminal.
The test report may include result information obtained by the test server testing the first code/the second code.
For example, the code quality of the first code/the second code may be detected through an automated test, test result information such as a test passing rate and a code coverage rate may be obtained, and the functional availability at the module level may be verified.
And sending a test report comprising test result information such as test passing rate, code coverage rate, functional availability and the like to the terminal. The terminal may display the test report to the user at the console.
In an embodiment, the above flow of testing code can also be implemented by the framework shown in fig. 5, and as shown in fig. 5, the remote driver layer may use Git as a code hosting repository, i.e. a remote database, Axios provides Http capability support, and Adm-zip provides compression capability support.
The integration layer can be realized by a development test tool, the development test tool integrates three functions included by a remote drive layer, so that the command layer can acquire difference information through a Git version management system installed locally after receiving a test instruction, send a test request to a test server through Axios, and compress the difference information through Adm-zip.
The configuration layer may generate test environment configurations (e.g., information such as dependency packages required for testing) and remotely execute configurations (e.g., information such as plug-ins required for testing the server) based on the test configuration information.
The command layer can receive the first test code, execute and obtain the difference information, upload the difference information and trigger the test server to perform automatic test and the like.
The pipeline layer may enable pulling of the second code from the remote repository and automated testing by the test server.
The above operations can be implemented in detail in the foregoing embodiments.
As can be seen from the above, in the embodiment of the application, the terminal acquires the test instruction input by the console, the terminal acquires the initial difference information between the first code and the second code, the terminal compresses the initial difference information to obtain the difference information, the terminal uploads the difference information to the target database, the terminal triggers the test server to start the pipeline to test the first code, and the test server acquires the second code in the remote database; the test server judges whether a code is changed or not, and if the code is changed, the test server acquires difference information; if the code is not changed, the test server carries out automatic test, the test server generates a first code according to the difference information and the second code, the test server carries out automatic test, and the test server returns a test report to the terminal. According to the scheme, the difference information between the first code and the second code is obtained through comparison, so that the remote server can obtain the first code according to the difference information and the second code in the remote database, and test the first code, the local code can be obtained without submitting the local code (the first code) to a remote warehouse, the local code can be tested, and the efficiency of testing the code is improved.
In order to better implement the code testing method provided by the embodiment of the application, a code testing device is further provided in an embodiment. The terms have the same meanings as those in the code testing method, and specific implementation details may refer to the descriptions in the method embodiments, and the code testing apparatus may be specifically integrated in a computer device, as shown in fig. 6, and the code testing apparatus may include: the receiving unit 401, the comparing unit 402, and the sending unit 403 are as follows:
(1) the receiving unit 401: the device comprises a first code and a second code, and is used for receiving a test instruction, locally acquiring a pre-stored first code and a second code according to the test instruction, wherein the first code is a new version code obtained by updating the second code, and the test instruction carries a target address.
For example, the first code and the second code may be obtained from a storage medium of the terminal after receiving a test instruction input by a user through the terminal.
In an embodiment, the test instruction may carry a first storage address of the first code and a second storage address of the second code, and after receiving the test instruction input by the user, the first code is obtained according to the first storage address, for example, the first storage address indicates a storage medium of the terminal, the first code is obtained from the storage medium, and if the first storage address indicates a database of a third party, the first code is obtained from the database of the third party; acquiring a second code according to a second storage address, for example, if the second storage address is a remote database address, pulling the second code from the remote database, and if the second storage address is a storage medium of the terminal, acquiring the second code from the storage medium; other storage cases are obtained by referring to the above manner of obtaining the code.
Optionally, the first storage address and the second storage address may be preset by a user, and when the user inputs a test instruction, the terminal acquires the preset first storage address and the preset second storage address, acquires the first code according to the first storage address, and acquires the second code according to the second storage address. Or after the middle terminal acquires the first storage address and the second storage address, the first storage address, the second storage address and the test instruction are sent to the server, and the server acquires the first code and the second code according to the first storage address and the second storage address respectively.
The first storage address and the second storage address may also be included in the test instruction input by the user, that is, the test instruction input by the user includes the first storage address and the second storage address.
In addition, the target address may be preset by the user or included in the test instruction input by the user.
(2) The comparison unit 402: the device is used for comparing the difference between the first code and the second code to obtain the difference information between the first code and the second code, and uploading the difference information to the target storage position indicated by the target address.
For example, each line of codes of the first code and the second code may be compared, the modification of the second code by the developer is determined, that is, the updated content of the first code is determined, the difference information between the first code and the second code is obtained, and the difference information is sent to the target storage location indicated by the target address carried by the test instruction.
Optionally, the comparing unit 402 may further include a first comparing subunit, where the first comparing subunit may be configured to compare the codes of the first code and the second code, and determine a code updated by the first code compared to the second code, an update type of the code, and a corresponding position of the code in the second code, and specifically, the first comparing subunit may be configured to:
comparing the first code with the second code to obtain an update code updated by the first code relative to the second code, an update type of the update code and an update position corresponding to the update code in the second code;
and determining difference information between the first code and the second code according to the update code, the update type and the corresponding update position of the update code in the second code.
For example, specifically, the code of the first code and the code of the second code are compared, it is determined that the first code is obtained by performing an operation of indicating an update type on the update code at the update position of the second code, for example, the first code is obtained by adding 3 lines of update code a after the k line of the second code, deleting the m line to the x line of the second code, and modifying the e line of the second code into the update code C.
The updated code A can be obtained, the updating type is newly increased, and the updating position is the kth line of the second code; the m line to x line codes of the second code are updating codes B, the updating type is deletion, and the updating positions are the m line to x line; and updating the code C, wherein the updating type is modification, and the changing position is the e-th line.
And generating difference information according to the update code, the update type and the update position, wherein the difference information can comprise the update code of which the first code is updated compared with the second code, the update type of the update code and the corresponding update position of the update code in the second code.
Optionally, the difference information may further include a code that updates the first code at the location, and a code that updates the second code at the location.
The update type of the update code may be determined based on a difference between the first code and the second code at the update location.
In an embodiment, there may be a plurality of code files in the first code and the second code, the first comparing subunit may include a code file comparing module, and the code file comparing module is configured to, when the first code and the second code perform code comparison, determine a code file of the second code corresponding to the code file in the first code, and compare codes of the two corresponding code files, specifically, the first comparing subunit may be configured to:
traversing the code files of the first code and the second code, and determining the corresponding relation between the code file in the first code and the code file in the second code;
and comparing the difference between the code file in the first code and the corresponding code file in the second code based on the corresponding relation, and determining the updating code for updating the first code relative to the second code, the updating type of the updating code and the corresponding position of the updating code in the second code.
For example, the method may specifically be to traverse code files of the first code and the second code, and query a code file with the same file name of the first code and the second code, where two code files with the same file name are code files with a corresponding relationship.
And comparing the codes of the two code files, and determining an updating code for updating the code file in the first code compared with the code file of the code file in the second code, the updating type and the updating position of the updating code.
Optionally, if the code file in the first code is a code file in the second code, the two files are code files having a corresponding relationship although the file names of the two files are different, and the file name of the code file in the second code is modified into the file name of the code file in the first code in the process of obtaining the first code according to the difference information and the second code.
If the code file of the first code file is a newly added code file, the second code file does not have a corresponding code file or the corresponding code file is a blank code file, and the update code can be determined to be the code file without comparison, and the update type is newly added; the comparison process of the deleted code file can refer to the newly added code file.
In order to increase the uploading speed and improve the testing efficiency of the first code, the first comparing subunit may include a code compressing module, and the code compressing module may be configured to perform a compressing operation on the difference information before uploading to the target storage location, and specifically, the code compressing module may be configured to:
determining initial difference information between the first code and the second code according to the update code, the update type and the corresponding update position of the update code in the second code;
and compressing the initial difference information to obtain difference information.
For example, the initial difference information between the first code and the second code may be determined according to the update code, the update type, and the corresponding update location of the update code in the second code, and the obtained initial difference information may be compressed by using a compression tool, such as jszip and adm-zip, or may be another compression tool, such as WinRAR, to obtain the difference information.
(3) The transmission unit 403: the test request is used for triggering the test server to obtain the difference information from the target storage position indicated by the target storage address, obtain the second code from the remote database indicated by the storage address, and test the first code according to the second code, the difference information and the test configuration information.
For example, the difference information may be stored in a target storage location indicated by the target address, and then a test request is sent to the test server to trigger the test server to test the first code.
Optionally, the test configuration information may be specified by a user through a test instruction, for example, may be a location where the test configuration information is specified to be stored, so that the sending unit 403 further includes an obtaining subunit, where the obtaining subunit is configured to obtain the test configuration information, and specifically, the obtaining subunit is configured to:
if the first identification information carried by the test instruction is first target identification information, acquiring target test configuration information corresponding to the first target identification information, and taking the target test configuration information as test configuration information;
and if the first identification information carried by the test instruction is not the first target identification information, acquiring preset test configuration information, and taking the preset test configuration information as the test configuration information.
For example, the test request may specifically carry identification information, and by determining whether the first identification information is first target identification information, if the first identification information is the first target identification information, that is, the user specifies test configuration information, the target test configuration information is obtained from a storage address of the target test configuration information according to the first target identification information, and if the first identification information is not the first target identification information, the preset test configuration information is obtained.
The preset configuration information may be preset by a user, for example, a storage address of the preset configuration information is configured in advance by the user, if the first identification information is not the first target identification information, that is, the user does not specify the test configuration information, the preset configuration information is obtained by obtaining the storage address configured in advance by the user, or the preset configuration information is preset in a computer program of the computer device, for example, in a computer program in which the storage address of the preset configuration information is preset, if the first identification information is not the first target identification information, the preset test configuration information indicated by the storage address preset in the computer program is obtained, or the preset test configuration information in the computer program is directly obtained.
And taking the obtained target test configuration information (or preset test configuration information) as the test configuration information.
As can be seen from the above, in the embodiment of the present application, the receiving unit 401 receives a test instruction, acquires a pre-stored first code and a second code from a local area according to the test instruction, the comparing unit 402 compares a difference between the first code and the second code to obtain difference information between the first code and the second code, uploads the difference information to a target storage location indicated by a target address, sends a test request to the test server through the sending unit 403, triggers the test server to acquire the difference information from the target storage location indicated by the target storage address through the test request, acquires the second code from a remote database indicated by the storage address, and tests the first code according to the second code, the difference information, and test configuration information. According to the scheme, the difference information between the first code and the second code is obtained through comparison, so that the remote server can obtain the first code according to the difference information and the second code in the remote database, and test the first code, the local code (the first code) can be tested without submitting the local code to a remote warehouse, and the efficiency of testing the code is improved.
In order to better implement the code testing method provided by the embodiment of the application, another code testing device is further provided in an embodiment. The terms have the same meanings as those in the code testing method, and the specific implementation details may refer to the descriptions in the method embodiments, and the code testing apparatus may be specifically integrated in a computer device, as shown in fig. 7, and the code testing apparatus may include: the instruction receiving unit 501, the obtaining unit 502, the generating unit 503, and the testing unit 504 are specifically as follows:
the instruction receiving unit 501: the remote database is used for managing the codes, and the difference information is the difference information between the first codes and the second codes.
For example, the specific method may be to receive a test request sent through a network or in other manners.
The acquisition unit 502: the method comprises the steps of obtaining difference information from a target storage position indicated by a target address according to a test request, and obtaining a second code from a remote database indicated by a storage address.
For example, the test server may specifically receive the test request, obtain the difference information from the target storage location indicated by the target address according to the target address carried in the test request, and obtain the second code from the remote database.
Optionally, the obtaining unit 502 may include a first obtaining subunit, where the first obtaining subunit may be configured to determine, through the second identification information, to directly test the second code of the remote database, or to obtain the difference information and the second code of the remote database to obtain the first code, and test the first code. Specifically, the first obtaining subunit may be configured to:
if the second identification information is second target identification information, acquiring difference information from a target storage position indicated by a target address according to the test request, and acquiring a second code from a remote database indicated by the storage address;
the generation unit 503: for generating the first code based on the second code and the difference information.
For example, the difference information may be specifically applied to the second code, for example, a part of the code of the second code is deleted according to the difference information, and a part of the code is added to the second code, and the added part of the code may be included in the difference information.
In an embodiment, the generating unit 503 may include an application subunit, and the application subunit may be configured to apply the difference information to the second code, and specifically, the application subunit may be configured to:
when the difference information comprises a newly added update code of which the update type is new, adding the update code of which the update type is new in the difference information to an update position corresponding to the second code;
when the difference information includes an update code whose update type is deleted, deleting, in the second code, a code corresponding to the update code whose update type is deleted in the difference information;
when the difference information includes an update code of which the update type is modified, modifying, in the second code, a code corresponding to the update code of which the update type is modified in the difference information to obtain a first code.
For example, the update type may be specifically a position in the second code indicated by the update position where the new update code is added; deleting the code corresponding to the update code with the update type of deletion in the second code; and modifying the code at the position corresponding to the updating position in the second code into an updating code with the updating type being modified, and applying all the updating codes in the difference information to the second code to obtain the first code.
Optionally, the generating unit 503 may include a code generating subunit, and the code generating subunit may be configured to generate the first code according to the second identification information, specifically, the code generating subunit may be configured to:
if the second identification information is second target identification information, generating a first code according to the second code and the difference information;
and if the second identification information is not the second target identification information, taking the second code as the first code.
For example, if the second identification information is second target identification information, the difference information may be obtained from a target storage location indicated by the target address, the second code may be obtained from a remote database, and the difference information may be applied to the second code to obtain the first code.
And if the second identification information is not the second target identification information, directly acquiring the second code from the remote database according to the storage address of the second code, and taking the second code as the first code.
The test unit 504: and the test configuration module is used for constructing a test environment according to the test configuration information and testing the first code in the test environment.
For example, a test environment may be specifically constructed according to the test configuration information, and the first code is tested in the test environment, for example, unit test, integration test, end-to-end test, and software availability test.
In one embodiment, after the first code is compiled, the compiled first code is tested in a test environment.
Wherein the unit test may be a test for a function or module of the first code; the integration test may be a test for a certain function of the first code, which is also called a functional test; the end-to-end test may be a full link test of the first code from the user interface directly to the database.
As can be seen from the above, in the embodiment of the present application, the instruction receiving unit 501 receives a test request for testing a first code, the obtaining unit 502 obtains difference information from a target storage location indicated by a target address according to the test request, and obtains a second code from a remote database indicated by a storage address, the generating unit 503 generates the first code according to the second code and the difference information, the testing unit 504 constructs a testing environment according to testing configuration information, and the first code is tested in the testing environment. According to the scheme, the first code is obtained through the difference information between the first code and the second code in the remote database, the first code is tested, the local code can be tested without being submitted to a remote warehouse, and the efficiency of testing the code is improved.
An embodiment of the present application further provides a computer device, where the computer device may be a terminal or a server, as shown in fig. 8, which shows a schematic structural diagram of the computer device according to the embodiment of the present application, and specifically:
the computer device may include components such as a processor 1001 of one or more processing cores, memory 1002 of one or more computer-readable storage media, a power supply 1003, and an input unit 1004. Those skilled in the art will appreciate that the computer device configuration illustrated in FIG. 8 does not constitute a limitation of computer devices, and may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. Wherein:
the processor 1001 is a control center of the computer device, connects various parts of the entire computer device using various interfaces and lines, and performs various functions of the computer device and processes data by running or executing software programs and/or modules stored in the memory 1002 and calling data stored in the memory 1002, thereby monitoring the computer device as a whole. Alternatively, processor 1001 may include one or more processing cores; preferably, the processor 1001 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It is understood that the modem processor may not be integrated into the processor 1001, the memory 1002 may be used to store software programs and modules, and the processor 1001 executes the software programs and modules stored in the memory 1002 to perform various functional applications and data processing. The memory 1002 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 1002 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Correspondingly, the memory 1002 may further include a memory controller to provide the processor 1001 with access to the memory 1002, and the computer device may further include a power supply 1003 to supply power to each component, and preferably, the power supply 1003 may be logically connected to the processor 1001 through a power management system, so as to implement functions of managing charging, discharging, and power consumption management through the power management system. The power source 1003 may further include one or more dc or ac power sources, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and any other components, and the computer device may further include an input unit 1004, wherein the input unit 1004 may be used for receiving input numeric or character information and generating keyboard, mouse, joystick, optical or trackball signal input related to user setting and function control, although not shown, the computer device may further include a display unit, and the like, which will not be described herein. Specifically, in this embodiment, the processor 1001 in the computer device loads the executable file corresponding to the process of one or more application programs into the memory 1002 according to the following instructions, and the processor 1001 runs the application programs stored in the memory 1002, so as to implement various functions as follows:
when the computer device is a terminal or a server, the processor 1001 runs an application program stored in the memory 1002, and may perform the following operations:
receiving a test instruction, acquiring a pre-stored first code and a second code from the local according to the test instruction, wherein the first code is a new version code obtained based on updating the second code, and the test instruction carries a target address;
comparing the difference between the first code and the second code to obtain difference information between the first code and the second code, and uploading the difference information to a target storage position indicated by a target address;
and sending a test request to a test server, wherein the test request carries a storage address, a target address and test configuration information of the second code, and the test request is used for triggering the test server to acquire the difference information from the target storage position indicated by the target storage address and acquire the second code from a remote database indicated by the storage address, and testing the first code according to the second code, the difference information and the test configuration information.
And when the computer device is a test server, the processor 1001 runs the application program stored in the memory 1002, and may perform the following operations:
receiving a test request for testing a first code, wherein the test request carries a storage address of a second code in a remote database, a target address of difference information and test configuration information, the first code is a new version code obtained based on updating the second code, the remote database is used for managing the code, and the difference information is the difference information between the first code and the second code;
acquiring difference information from a target storage position indicated by the target address according to the test request, and acquiring a second code from a remote database indicated by the storage address;
generating a first code according to the second code and the difference information;
and constructing a test environment according to the test configuration information, and testing the first code in the test environment.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein. The computer device receives a test instruction, acquires a pre-stored first code and a pre-stored second code from a local according to the test instruction, compares differences between the first code and the second code to obtain difference information between the first code and the second code, uploads the difference information to a target storage position indicated by a target address, and finally sends a test request to a test server to trigger the test server to acquire the difference information from the target storage position indicated by the target storage address through the test request, acquires the second code from a remote database indicated by the storage address, and tests the first code according to the second code, the difference information and test configuration information. According to the scheme, the difference information between the first code and the second code is obtained through comparison, so that the remote server can obtain the first code according to the difference information and the second code in the remote database, the first code is tested, the local code can be tested without submitting the local code to a remote warehouse, and the efficiency of testing the code is improved.
And the test server receives a test request for testing the first code, acquires difference information from a target storage position indicated by the target address according to the test request, acquires a second code from a remote database indicated by the storage address, generates the first code according to the second code and the difference information, constructs a test environment according to the test configuration information, tests the first code in the test environment, can test the local code without submitting the local code to a remote warehouse, and improves the efficiency of testing the code.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. A processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to make the computer device execute the methods provided in the various alternative implementations of the embodiments, and it will be understood by those skilled in the art that all or part of the steps of the methods of the embodiments may be implemented by a computer program, or by controlling related hardware by the computer program, and the computer program may be stored in a computer-readable storage medium and loaded and executed by the processor, for this purpose, the embodiments of the present application provide a storage medium in which a computer program is stored, and the computer program can be loaded by the processor to execute the steps of any one of the code testing methods provided by the embodiments of the present application, and the specific implementation of the above operations can be referred to the foregoing embodiments, it is not described herein, wherein the storage medium may include: a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, wherein a computer program stored in the storage medium can execute the steps of any one of the code testing methods provided in the embodiments of the present application, so that the beneficial effects that any one of the code testing methods provided in the embodiments of the present application can achieve can be achieved, for details, see the foregoing embodiments, which are not described herein again, the above code testing method, apparatus, computer device and storage medium provided in the embodiments of the present application are introduced in detail, and the specific embodiments are applied herein to explain the principles and embodiments of the present invention, and the description of the foregoing embodiments is Only used to help understanding the methods and core ideas of the present invention; meanwhile, for those skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for code testing, comprising:
receiving a test instruction, acquiring a pre-stored first code from the local according to the test instruction, and acquiring a second code, wherein the first code is a new version code obtained based on updating the second code, and the test instruction carries a target address;
comparing the difference between the first code and the second code to obtain difference information between the first code and the second code, and uploading the difference information to a target storage position indicated by the target address;
sending a test request to a test server, wherein the test request carries a storage address of the second code, the target address and test configuration information, and the test request is used for triggering the test server to acquire the difference information from a target storage position indicated by the target address, acquiring the second code from a remote database indicated by the storage address, and testing the first code according to the second code, the difference information and the test configuration information.
2. The method of claim 1, wherein comparing the difference between the first code and the second code to obtain difference information between the first code and the second code comprises:
comparing the first code with the second code to obtain an update code for updating the first code relative to the second code, an update type of the update code and an update position corresponding to the update code in the second code;
and determining difference information between the first code and the second code according to the updating code, the updating type and the corresponding updating position of the updating code in the second code.
3. The method of claim 2, wherein the code comparing the first code with the second code to obtain an update code for updating the first code with respect to the second code, an update type of the update code, and an update location corresponding to the update code in the second code, comprises:
traversing the code files of the first code and the second code, and determining the corresponding relation between the code file in the first code and the code file in the second code;
and comparing differences between the code files in the first code and the corresponding code files in the second code based on the corresponding relationship, and determining the updating code of the first code updated relative to the second code, the updating type of the updating code and the corresponding updating position of the updating code in the second code.
4. The method of claim 3, wherein determining the difference information between the first code and the second code according to the update code, the update type, and the corresponding update location of the update code in the second code comprises:
determining initial difference information between the first code and the second code according to the update code, the update type and the corresponding update position of the update code in the second code;
and compressing the initial difference information to obtain difference information between the first code and the second code.
5. The method according to any one of claims 1 to 4, wherein the test instruction carries first identification information, and before sending the test instruction to the test server, the method comprises:
if the first identification information carried by the test instruction is first target identification information, acquiring target test configuration information corresponding to the first target identification information, and using the target test configuration information as the test configuration information;
if the first identification information carried by the test instruction is not the first target identification information, acquiring preset test configuration information, and using the preset test configuration information as the test configuration information.
6. A code testing method is applied to a testing server, and comprises the following steps:
receiving a test request for testing a first code, wherein the test request carries a storage address of a second code in a remote database, a target address of difference information and test configuration information, the first code is a new version code obtained based on updating the second code, the remote database is used for managing codes, and the difference information is difference information between the first code and the second code;
acquiring the difference information from a target storage position indicated by the target address according to the test request, and acquiring the second code from the remote database indicated by the storage address;
generating the first code according to the second code and the difference information;
and constructing a test environment according to the test configuration information, and testing the first code in the test environment.
7. The method of claim 6, wherein the difference information comprises an update code, an update type of the update code, and a corresponding update location of the update code in the second code, wherein the update type comprises one or more of an addition, a deletion, and a modification, and wherein generating the first code according to the second code and the difference information comprises:
when the difference information comprises a newly added update code of which the update type is new, adding the update code of which the update type is new in the difference information to an update position corresponding to the second code;
when the difference information includes an update code of which the update type is deleted, deleting a code corresponding to the update code of which the update type is deleted in the difference information in the second code;
and when the difference information comprises an update code with a modified update type, modifying a code corresponding to the update code with the modified update type in the difference information in the second code to obtain the first code.
8. The method of claim 6, wherein the test request includes second identification information, wherein the obtaining the difference information from the target storage location indicated by the target address and the second code from the remote database indicated by the storage address according to the test request comprises:
and if the second identification information is second target identification information, acquiring the difference information from a target storage position indicated by the target address according to the test request, and acquiring the second code from the remote database indicated by the storage address.
9. A code testing apparatus, comprising:
a receiving unit: the system comprises a first code module, a second code module, a third code module and a fourth code module, wherein the first code module is used for receiving a test instruction, acquiring a pre-stored first code and a second code from the local according to the test instruction, the first code is a new version code obtained based on updating the second code, and the test instruction carries a target address;
a comparison unit: the device comprises a first code, a second code and a storage location, wherein the first code is used for storing a first address and a second address, the second code is used for storing a second code, and the first code and the second code are used for comparing the difference between the first code and the second code to obtain difference information between the first code and the second code and uploading the difference information to a target storage location indicated by the target address;
a transmission unit: the test request is used for triggering the test server to acquire the difference information from a target storage position indicated by the target address, acquire the second code from a remote database indicated by the storage address, and test the first code according to the second code, the difference information and the test configuration information.
10. A code testing apparatus, applied to a test server, the apparatus comprising:
an instruction receiving unit: the test system comprises a remote database, a test request and a test result generation module, wherein the remote database is used for receiving the test request for testing a first code, the test request carries a storage address of a second code in the remote database, a target address of difference information and test configuration information, the first code is a new version code obtained based on updating the second code, the remote database is used for managing the code, and the difference information is the difference information between the first code and the second code;
an acquisition unit: the second code is used for acquiring the difference information from a target storage position indicated by the target address according to the test request and acquiring the second code from the remote database indicated by the storage address;
a generation unit: for generating the first code from the second code and the difference information;
a test unit: and the test configuration information is used for constructing a test environment according to the test configuration information and testing the first code in the test environment.
CN202110313760.8A 2021-03-24 2021-03-24 Code testing method and device Pending CN115129574A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110313760.8A CN115129574A (en) 2021-03-24 2021-03-24 Code testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110313760.8A CN115129574A (en) 2021-03-24 2021-03-24 Code testing method and device

Publications (1)

Publication Number Publication Date
CN115129574A true CN115129574A (en) 2022-09-30

Family

ID=83374727

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110313760.8A Pending CN115129574A (en) 2021-03-24 2021-03-24 Code testing method and device

Country Status (1)

Country Link
CN (1) CN115129574A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230055215A1 (en) * 2021-08-19 2023-02-23 Bank Of America Corporation Systems and methods for identifying and determining third party compliance
US11893116B2 (en) 2021-08-19 2024-02-06 Bank Of America Corporation Assessment plug-in system for providing binary digitally signed results

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230055215A1 (en) * 2021-08-19 2023-02-23 Bank Of America Corporation Systems and methods for identifying and determining third party compliance
US11805017B2 (en) * 2021-08-19 2023-10-31 Bank Of America Corporation Systems and methods for identifying and determining third party compliance
US11893116B2 (en) 2021-08-19 2024-02-06 Bank Of America Corporation Assessment plug-in system for providing binary digitally signed results

Similar Documents

Publication Publication Date Title
CN109120678B (en) Method and apparatus for service hosting of distributed storage system
CN108563579B (en) White box testing method, device and system and storage medium
CN110162334B (en) Code management method, device and storage medium
JP2013517578A (en) Application operating method, apparatus and system
CN110659202A (en) Client automatic testing method and device
CN111580926A (en) Model publishing method, model deploying method, model publishing device, model deploying device, model publishing equipment and storage medium
CN113485918B (en) Test method, test device, electronic equipment and storage medium
CN108958843A (en) Plug-in unit construction method, system, equipment and medium based on lightweight script
CN115129574A (en) Code testing method and device
CN111651352B (en) Warehouse code merging method and device
CN116257438A (en) Updating method of interface test case and related equipment
CN114527996A (en) Multi-service deployment method and device, electronic equipment and storage medium
CN113778486A (en) Containerization processing method, device, medium and equipment for code pipeline
CN111782516A (en) Code testing method and device and storage medium
CN111324365A (en) Method and equipment for upgrading super-converged system
CN111176706A (en) Terminal upgrading method and device, electronic equipment and storage medium
CN104104701A (en) Online service configuration updating method and system
CN110244968B (en) Charging station management system and method
CN112685102B (en) Gateway plug-in hot loading method, device, equipment and medium
CN108989428A (en) Bluetooth terminal upgrade method, server, computer readable storage medium and system
CN105530140A (en) Cloud scheduling system, method and device for removing tight coupling of use case and environment
CN114610446A (en) Method, device and system for automatically injecting probe
RU2520942C2 (en) Method of computer-aided power system operation and computer-aided power system
CN112765038A (en) Distributed cluster software testing method, device, equipment and storage medium
CN112486511A (en) Method for generating operating system installation mirror image through web

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