CN110489341B - Test method and device, storage medium and electronic equipment - Google Patents

Test method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN110489341B
CN110489341B CN201910695533.9A CN201910695533A CN110489341B CN 110489341 B CN110489341 B CN 110489341B CN 201910695533 A CN201910695533 A CN 201910695533A CN 110489341 B CN110489341 B CN 110489341B
Authority
CN
China
Prior art keywords
environment
code
information
memory
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910695533.9A
Other languages
Chinese (zh)
Other versions
CN110489341A (en
Inventor
林泉韬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201910695533.9A priority Critical patent/CN110489341B/en
Publication of CN110489341A publication Critical patent/CN110489341A/en
Application granted granted Critical
Publication of CN110489341B publication Critical patent/CN110489341B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a testing method, a testing device, a storage medium and electronic equipment, wherein the testing method comprises the following steps: acquiring modification indication information; acquiring codes from a hard disk; detecting whether the current environment is a test environment; responding to the current environment being a test environment, and modifying the codes acquired from the hard disk according to the modification instruction information; loading the modified code into a memory; and running the modified code in memory; loading codes obtained from the hard disk into the memory in response to the current environment being a non-test environment; and running the code in memory. The embodiment of the disclosure modifies the code in the process of loading the code from the hard disk into the memory, rather than directly modifying the code in the hard disk, so that even if the code is modified in the test environment, the code is not saved to the hard disk, and thus the original code is uploaded when the code on the hard disk is uploaded to a remote library or a production environment. The method avoids the error transmission of codes in the test environment to the production environment.

Description

Test method and device, storage medium and electronic equipment
Technical Field
The disclosure relates to the field of data processing, and in particular relates to a testing method, a testing device, a storage medium and electronic equipment.
Background
In a test environment, a developer may temporarily modify the code in order to test the functionality, but sometimes forget to modify the code back when uploading the code into the production environment, resulting in the code for testing being uploaded into the production environment, which can lead to a series of problems. For example, in an internal test environment, a developer may temporarily mask the payment function in order to test certain functions, but may forget to unmask after the test is completed, resulting in failure to complete the payment function in the production environment.
Disclosure of Invention
In view of this, the embodiments of the present disclosure provide a testing method, a testing device, a storage medium, and an electronic device, so as to solve the following problems in the prior art: class files after the testers modify codes in the test environment are erroneously transmitted to the production environment, so that a series of application programs are used, and economic losses are caused for companies of the application programs in serious cases.
In one aspect, an embodiment of the present disclosure provides a test method, including: acquiring modification indication information; acquiring codes from a hard disk; detecting whether the current environment is a test environment; responding to the current environment being the test environment, and modifying the codes acquired from the hard disk according to the modification instruction information; loading the modified code into a memory; and running the modified code in the memory; responding to the current environment as a non-test environment, and loading codes acquired from a hard disk into a memory; and running the code in the memory.
In another aspect, an embodiment of the present disclosure provides a test apparatus, including: the first acquisition module is used for acquiring the modification indication information; the second acquisition module is used for acquiring codes from the hard disk; the detection module is used for detecting whether the current environment is a test environment or not; the first execution module is used for responding to the current environment which is the test environment and modifying codes obtained from the hard disk according to the modification indication information; loading the modified code into a memory; and running the modified code in the memory; the second execution module is used for loading codes acquired from the hard disk into the memory in response to the current environment being a non-test environment; and running the code in the memory.
In another aspect, an embodiment of the present disclosure proposes a storage medium storing a computer program that, when executed by a processor, implements a method provided by any embodiment of the present disclosure.
In another aspect, an embodiment of the present disclosure provides an electronic device, including at least a memory, and a processor, where the memory stores a computer program, and the processor implements a method provided by any embodiment of the present disclosure when executing the computer program on the memory.
The embodiment of the disclosure modifies the code in the process of loading the code from the hard disk into the memory, rather than directly modifying the code in the hard disk, so that even if the code is modified in the test environment, the code is not saved to the hard disk, and thus the original code is uploaded when the code on the hard disk is uploaded to a remote library or a production environment. The method avoids the error transmission of codes in the test environment to the production environment.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
FIG. 1 is a flow chart of a test method provided by a first embodiment of the present disclosure;
FIG. 2 is a flow chart of a test method provided by a second embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a testing device according to a third embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present disclosure;
fig. 5 is another schematic structural diagram of an electronic device according to a fifth embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
A first embodiment of the present disclosure provides a testing method, the flow of which is shown in fig. 1, including steps S101 to S105:
s101, acquiring modification instruction information.
After the developer has developed the code, the code is placed on the local hard disk and is typically retrieved from the local hard disk if modification is required. After the code development is finished, a tester is required to perform a post test to test whether various functions of the application program in the code running are normal or not, and whether the functions have certain problems, for example, whether the payment function can be normally executed or not is tested, and a corresponding payment result is given to a user after the payment is finished.
In order to enable a tester to acquire a code to be tested, the code developer can upload the code to be tested by the tester to a remote library, the tester can download the code to be tested from the remote library to a local hard disk, and because the testing process needs to test various functions of an application program corresponding to the code, the testing process is a testing environment, the operation in a real production environment is not needed, the corresponding code is modified to achieve the same effect as the production environment, and the specific content of the code is changed.
When the embodiment of the disclosure is implemented, the code needing to be modified can be confirmed when the modification instruction information is acquired, and the code does not need to be modified if the modification instruction information is not acquired, and of course, the modification instruction information can be acquired certainly, and whether the code needs to be modified is confirmed by the modification or non-modification information indicated in the modification instruction information. In general, if a tester needs to test a code, most of the cases need to modify the code, so the modification instruction information of this embodiment can be obtained only when the code needs to be modified.
S102, acquiring codes from a hard disk.
S103, detecting whether the current environment is a test environment. If yes, S104 is performed, otherwise S105 is performed.
The modification instruction information can be used as a detection condition of the process, that is, whether the current environment is a test environment is detected when the modification instruction information is acquired, and if the modification instruction information is not acquired, the instruction code does not need modification.
When determining whether the current environment is a test environment, the method can be implemented according to the following procedures: acquiring environment information of a current environment; acquiring preset environment information of a test environment; comparing the environment information of the current environment with the preset environment information of the test environment; determining the current environment as the test environment in response to the environment information of the current environment being identical to the predetermined environment information of the test environment; and determining that the current environment is a non-test environment in response to the environment information of the current environment being different from the predetermined environment information of the test environment. During the comparison, the context information may include a variety of information such as IP address, MAC address, context variable, etc.; in order to accurately detect whether the environmental information of the current environment is identical to the predetermined environmental information of the test environment, various kinds of environmental information may be used together.
For example, the execution environment MAC address of the current code is 07-16-76-00-02-XX, IP address 192.168.0.X, the predetermined test environment MAC address is 07-16-76-00-02-XX, IP address 192.168.0.X, and the two environment information are identical, no matter the MAC address or the IP address, the execution environment of the current code can be determined to be the test environment.
S104, responding to the current environment being a test environment, and modifying the codes acquired from the hard disk according to the modification instruction information; loading the modified code into a memory; and running the modified code in memory.
As described above, the modification instruction information of the present embodiment is acquired only when the code needs to be modified, and therefore, the modification instruction information of the embodiment of the present disclosure indicates which part of the code needs to be modified.
For example, when the modification instruction information indicates that the 15 th-30 th row codes in the X file need to be modified, the payment logic of the 15 th-30 th row codes is modified, the X file is directly searched in the class file obtained from the hard disk, and the 15 th-30 th row codes indicated in the X file are modified according to the new payment logic in the modification instruction information.
When the codes in the memory are modified, the codes stored in the class file are the codes needed by the test, and then the codes are loaded into the memory, and the modified codes are operated in the memory, so that the purpose of testing the application program is realized.
S105, responding to the current environment as a non-test environment, and loading codes acquired from a hard disk into a memory; and running the code in memory.
Since the modification indication information exists for the test environment, that is, the modification indication information indicates that the code used in the test environment is modified, if the modification indication information exists for the test environment, the code is not required to be modified even if the modification indication information exists for the non-test environment, and the code is directly loaded into the memory and is operated in the memory.
After the modification indication information and the code are obtained, the embodiment of the disclosure detects whether the current environment is a test environment, modifies the code obtained from the hard disk when the current environment is the test environment, loads the modified code into the memory, can run the modified code for testing in the memory, and directly loads the code into the memory and runs the code in the memory if the current environment is not the test environment.
The embodiment of the disclosure modifies the code in the process of loading the code from the hard disk into the memory, rather than directly modifying the code in the hard disk, so that even if the code is modified in the test environment, the code is not saved to the hard disk, and thus the original code is uploaded when the code on the hard disk is uploaded to a remote library or a production environment. The method avoids the error transmission of codes in the test environment to the production environment.
A second embodiment of the present disclosure provides a testing method, the flow of which is shown in fig. 2, including steps S201 to S208:
s201, detecting a configuration file.
After the developer develops the code, the code is put on a local hard disk, and if the code needs to be modified, the code is obtained from the local hard disk. After the development of the code is finished, a tester is required to perform a post test to test whether functions in the running of the code are normal or not, and whether the functions have certain problems, such as whether the payment can be normally executed or not, and a corresponding payment result is given to a user after the payment is finished.
In order to enable a tester to acquire a code to be tested, the code developer can upload the code to be tested by the tester to a remote library, the tester can download the code to be tested from the remote library to a local hard disk, and the specific content of the code is changed because the test process needs to test various functions of an application program corresponding to the code and is a test environment, so that the operation in a real production environment is not needed, the corresponding code is modified to achieve the same effect as that in the production environment.
When the embodiment of the disclosure is implemented, the modification indication information is determined by setting the configuration file, so that whether the code needing modification exists or not is indicated.
S202, analyzing the configuration file to obtain modification indication information, wherein the modification indication information at least comprises: the location of the code to be replaced and the replacement code.
When the configuration file exists, the configuration file can be parsed to know the content in the configuration file, and the position of the code to be replaced and the replacement code are recorded in the configuration file in general, so that the code can be modified through modification indication information obtained from the configuration file in the process of replacing the code later.
S203, acquiring codes from the hard disk.
S204, detecting whether the current environment is a test environment. If yes, S205 is performed, otherwise S208 is performed.
Even if there is code that needs to be modified, it is necessary to modify it in the test environment, and the non-test environment does not modify the code.
The above configuration file may be used as a detection condition in the process, that is, it is detected whether the execution environment of the current code is a test environment when the configuration file is acquired, and if the configuration file is not acquired, it is indicated that the code does not need to be modified.
When determining whether the current environment is a test environment, the method can be implemented according to the following procedures: acquiring environment information of a current environment; acquiring preset environment information of a test environment; comparing the environment information of the current environment with the preset environment information of the test environment; determining the current environment as the test environment in response to the environment information of the current environment being identical to the predetermined environment information of the test environment; and determining that the current environment is a non-test environment in response to the environment information of the current environment being different from the predetermined environment information of the test environment. During the comparison, the context information may include a variety of information such as IP address, MAC address, context variable, etc.; in order to accurately detect whether the environment information of the current code execution environment is identical to the predetermined environment information of the test environment, various kinds of environment information may be used together.
For example, the execution environment MAC address of the current code is 07-16-76-00-02-XX, IP address 192.168.0.X, the predetermined test environment MAC address is 07-16-76-00-02-XX, IP address 192.168.0.X, and the two environment information are identical, no matter the MAC address or the IP address, the execution environment of the current code can be determined to be the test environment.
And S205, determining the code to be replaced in the codes acquired from the hard disk according to the position of the code to be replaced in response to the current environment being the test environment.
Whether testing the functions of a new application or testing the update package of an application involves many codes, different codes being written in different class files. The location of the code to be replaced exists in the configuration file in this embodiment, and the corresponding class file can be found based on the location, so as to know which part of the code in the class file needs to be replaced.
S206, replacing the code to be replaced with the replacement code.
For example, when the modification instruction information indicates that the 15 th-30 th row codes in the X file in the class file need to be modified, the payment logic of the 15 th-30 th row codes is modified, the X file is directly searched in the class file obtained from the hard disk, and the 15 th-30 th row codes indicated in the X file are modified according to the new payment logic in the modification instruction information.
S207, loading the modified codes into a memory; and running the modified code in memory.
When the codes in the memory are modified, the codes stored in the class file are the codes needed by the test, and then the codes are loaded into the memory, and the modified codes are operated in the memory, so that the purpose of testing the application program is realized.
S208, in response to the current environment being a non-test environment, loading codes acquired from the hard disk into a memory; and running the code in memory.
Since the modification indication information exists for the test environment, that is, the modification indication information indicates that the code used in the test environment is modified, if the modification indication information exists for the test environment, the code is not required to be modified even if the modification indication information exists for the non-test environment, and the code is directly loaded into the memory and is operated in the memory.
After the modification indication information and the codes are obtained, the embodiment of the disclosure detects whether the current environment is a test environment, modifies the codes obtained from the hard disk when the current environment is the test environment, loads the modified codes into the memory, and can run the modified codes for testing in the memory.
The embodiment of the disclosure modifies the code in the process of loading the code from the hard disk into the memory, rather than directly modifying the code in the hard disk, so that even if the code is modified in the test environment, the code is not saved to the hard disk, and thus the original code is uploaded when the code on the hard disk is uploaded to a remote library or a production environment. The method avoids the error transmission of codes in the test environment to the production environment.
A third embodiment of the present disclosure provides a testing device, which may be presented in the form of an insert, the device having a structure schematically shown in fig. 3, comprising:
a first obtaining module 10, configured to obtain modification instruction information; a second acquisition module 20 coupled to the first acquisition module 10 for acquiring codes from the hard disk; a detection module 30, coupled to the second acquisition module 20, for detecting whether the current environment is a test environment; a first execution module 40 coupled to the detection module 30 for modifying the code obtained from the hard disk according to the modification instruction information in response to the current environment being a test environment; loading the modified code into a memory; and running the modified code in memory; the second execution module 50 is coupled with the detection module 30 and is used for loading the codes acquired from the hard disk into the memory in response to the current environment being a non-test environment; and running the code in memory.
After the developer develops the code, the code is put on a local hard disk, and if the code needs to be modified, the code is obtained from the local hard disk. After the development of the code is finished, a tester is required to perform a post test to test whether functions in the running of the code are normal or not, and whether the functions have certain problems, such as whether the payment can be normally executed or not, and a corresponding payment result is given to a user after the payment is finished.
In order to enable a tester to acquire a code to be tested, the code developer can upload the code to be tested by the tester to a remote library, the tester can download the code to be tested from the remote library to a local hard disk, and the specific content of the code is changed because the test process needs to test various functions of an application program corresponding to the code and is a test environment, so that the operation in a real production environment is not needed, the corresponding code is modified to achieve the same effect as that in the production environment.
When the embodiment of the disclosure is implemented, the code needing to be modified can be confirmed when the modification instruction information is acquired, and the code does not need to be modified if the modification instruction information is not acquired, and of course, the modification instruction information can be acquired certainly, and whether the code needs to be modified is confirmed by the modification or non-modification information indicated in the modification instruction information. In general, if a tester needs to test a code, most of the cases need to modify the code, so the modification instruction information of this embodiment can be obtained only when the code needs to be modified.
The modification instruction information can be used as a detection condition, namely whether the execution environment of the current code is a test environment is detected when the modification instruction information is acquired, if the modification instruction information is not acquired, the code is indicated to be not required to be modified, and the code in the hard disk is directly downloaded into the memory to run.
The first obtaining module is specifically configured to: detecting a configuration file; analyzing the configuration file to obtain modification indication information, wherein the modification indication information at least comprises: the location of the code to be replaced and the replacement code. When the embodiment of the disclosure is implemented, the modification indication information is determined by setting the configuration file, so that whether the code needing modification exists or not is indicated. When the configuration file exists, the configuration file can be parsed to know the content in the configuration file, and the position of the code to be replaced and the replacement code are recorded in the configuration file in general, so that the code can be modified through modification indication information obtained from the configuration file in the process of replacing the code later.
In determining whether the current environment is a test environment, the detection module may include: the acquisition unit is used for acquiring the environment information of the current environment; acquiring preset environment information of a test environment; a comparison unit for comparing the environmental information of the current environment with the predetermined environmental information of the test environment; the first determining unit is used for determining that the current environment is the test environment in response to the fact that the environment information of the current environment is identical to the preset environment information of the test environment; and a second determining unit configured to determine that the current environment is a non-test environment in response to the environment information of the current environment being different from the predetermined environment information of the test environment.
If the two context information are identical, it may be determined that the current context of code execution is the test context. During the comparison, the context information may include a variety of information such as IP address, MAC address, context variable, etc.; in order to accurately detect whether the environment information of the current code execution environment is identical to the predetermined environment information of the test environment, various kinds of environment information may be used together.
For example, the execution environment MAC address of the current code is 07-16-76-00-02-XX, IP address 192.168.0.X, the predetermined test environment MAC address is 07-16-76-00-02-XX, IP address 192.168.0.X, and the two environment information are identical, no matter the MAC address or the IP address, the execution environment of the current code can be determined to be the test environment.
As described above, the modification instruction information of the present embodiment is acquired only when the code needs to be modified, and therefore, the modification instruction information of the embodiment of the present disclosure indicates which part of the code needs to be modified. The first execution module may specifically be configured to: determining a code to be replaced in the codes obtained from the hard disk according to the position of the code to be replaced; the replacement code is used to replace the code to be replaced.
For example, when the modification instruction information indicates that the 15 th-30 th row codes in the X file in the class file need to be modified, the payment logic of the 15 th-30 th row codes is modified, the X file is directly searched in the class file obtained from the hard disk, and the 15 th-30 th row codes indicated in the X file are modified according to the new payment logic in the modification instruction information.
When the codes in the memory are modified, the codes stored in the class file are the codes needed by the test, and then the codes are loaded into the memory, and the modified codes are operated in the memory, so that the purpose of testing the application program is realized.
After the modification indication information and the codes are obtained, the embodiment of the disclosure detects whether the current environment is a test environment, modifies the codes obtained from the hard disk when the current environment is the test environment, loads the modified codes into the memory, and can run the modified codes for testing in the memory.
The embodiment of the disclosure modifies the code in the process of loading the code from the hard disk into the memory, rather than directly modifying the code in the hard disk, so that even if the code is modified in the test environment, the code is not saved to the hard disk, and thus the original code is uploaded when the code on the hard disk is uploaded to a remote library or a production environment. The method avoids the error transmission of codes in the test environment to the production environment.
A fourth embodiment of the present disclosure provides a storage medium, which is a computer-readable medium storing a computer program that, when executed by a processor, implements the method provided by any embodiment of the present disclosure, including steps S11 to S15 as follows:
s11, acquiring modification indication information;
s12, acquiring codes from a hard disk;
s13, detecting whether the current environment is a test environment;
s14, responding to the current environment being a test environment, and modifying the codes acquired from the hard disk according to the modification instruction information; loading the modified code into a memory; and running the modified code in memory;
s15, responding to the current environment as a non-test environment, and loading codes acquired from the hard disk into a memory; and running the code in memory.
When the computer program is executed by the processor to detect whether the current environment is a test environment, the following steps are executed by the processor specifically: acquiring environment information of a current environment; acquiring preset environment information of a test environment; comparing the environment information of the current environment with the preset environment information of the test environment; determining the current environment as the test environment in response to the environment information of the current environment being identical to the predetermined environment information of the test environment; and determining that the current environment is a non-test environment in response to the environment information of the current environment being different from the predetermined environment information of the test environment. Wherein the environmental information includes at least one of: IP address, MAC address, environment variable.
When the computer program is executed by the processor to obtain the modification instruction information, the processor specifically executes the following steps: detecting a configuration file; analyzing the configuration file to obtain modification indication information, wherein the modification indication information at least comprises: the location of the code to be replaced and the replacement code.
When the computer program is executed by the processor to modify the code obtained from the hard disk according to the modification instruction information, the processor specifically executes the following steps: determining a code to be replaced in the codes obtained from the hard disk according to the position of the code to be replaced; the replacement code is used to replace the code to be replaced.
After the modification indication information and the code are obtained, the embodiment of the disclosure detects whether the current environment is a test environment, modifies the code obtained from the hard disk when the current environment is the test environment, loads the modified code into the memory, can run the modified code for testing in the memory, and directly loads the code into the memory and runs the code in the memory if the current environment is not the test environment.
The embodiment of the disclosure modifies the code in the process of loading the code from the hard disk into the memory, rather than directly modifying the code in the hard disk, so that even if the code is modified in the test environment, the code is not saved to the hard disk, and thus the original code is uploaded when the code on the hard disk is uploaded to a remote library or a production environment. The method avoids the error transmission of codes in the test environment to the production environment.
The fifth embodiment of the present disclosure provides an electronic device, which may include at least a memory 901 and a processor 902, as shown in fig. 4, where the memory 901 stores a computer program, and the processor 902 implements the method provided by any embodiment of the present disclosure when executing the computer program on the memory 901. Exemplary, the electronic device computer program steps are as follows S21 to S25:
s21, acquiring modification instruction information;
s22, acquiring codes from a hard disk;
s23, detecting whether the current environment is a test environment;
s24, responding to the current environment being a test environment, and modifying the codes acquired from the hard disk according to the modification instruction information; loading the modified code into a memory; and running the modified code in memory;
s25, responding to the current environment as a non-test environment, and loading codes acquired from the hard disk into a memory; and running the code in memory.
When executing the computer program stored on the memory for detecting whether the current environment is the test environment, the processor specifically executes the following computer program: acquiring environment information of a current environment; acquiring preset environment information of a test environment; comparing the environment information of the current environment with the preset environment information of the test environment; determining the current environment as the test environment in response to the environment information of the current environment being identical to the predetermined environment information of the test environment; and determining that the current environment is a non-test environment in response to the environment information of the current environment being different from the predetermined environment information of the test environment. Wherein the environmental information includes at least one of: IP address, MAC address, environment variable.
The processor, when executing the computer program stored on the memory for obtaining the modification instruction information, specifically executes the computer program as follows: detecting a configuration file; analyzing the configuration file to obtain modification indication information, wherein the modification indication information at least comprises: the location of the code to be replaced and the replacement code.
When executing a computer program stored in the memory and modifying the code obtained from the hard disk according to the modification instruction information, the processor specifically executes the computer program as follows: determining a code to be replaced in the codes obtained from the hard disk according to the position of the code to be replaced; the replacement code is used to replace the code to be replaced.
After the modification indication information and the code are obtained, the embodiment of the disclosure detects whether the current environment is a test environment, modifies the code obtained from the hard disk when the current environment is the test environment, loads the modified code into the memory, can run the modified code for testing in the memory, and directly loads the code into the memory and runs the code in the memory if the current environment is not the test environment.
The embodiment of the disclosure modifies the code in the process of loading the code from the hard disk into the memory, rather than directly modifying the code in the hard disk, so that even if the code is modified in the test environment, the code is not saved to the hard disk, and thus the original code is uploaded when the code on the hard disk is uploaded to a remote library or a production environment. The method avoids the error transmission of codes in the test environment to the production environment.
Referring now to fig. 5, there is shown a schematic structural diagram of another electronic device suitable for use in implementing embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 5, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 606 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 606 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory storage medium, the computer program comprising program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 606, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 601.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a Local Area Network (LAN), a Wide Area Network (WAN), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The storage medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The storage medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: acquiring at least two internet protocol addresses; sending a node evaluation request comprising at least two internet protocol addresses to node evaluation equipment, wherein the node evaluation equipment selects an internet protocol address from the at least two internet protocol addresses and returns the internet protocol address; receiving an Internet protocol address returned by node evaluation equipment; wherein the acquired internet protocol address indicates an edge node in the content distribution network.
Alternatively, the storage medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: receiving a node evaluation request comprising at least two internet protocol addresses; selecting an internet protocol address from at least two internet protocol addresses; returning the selected internet protocol address; wherein the received internet protocol address indicates an edge node in the content distribution network.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
It should be noted that the storage medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any storage medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a storage medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.
While various embodiments of the present disclosure have been described in detail, the present disclosure is not limited to these specific embodiments, and various modifications and embodiments can be made by those skilled in the art on the basis of the concepts of the present disclosure, and these modifications and modifications should be within the scope of the present disclosure as claimed.

Claims (8)

1. A method of testing, comprising:
acquiring modification indication information;
acquiring codes from a hard disk;
detecting whether the current environment is a test environment;
responding to the current environment being the test environment, and modifying the codes acquired from the hard disk according to the modification instruction information; loading the modified code into a memory; and running the modified code in the memory;
responding to the current environment as a non-test environment, and loading codes acquired from a hard disk into a memory; and running the code in the memory;
The obtaining modification indication information includes:
detecting a configuration file;
analyzing the configuration file to obtain modification indication information, wherein the modification indication information at least comprises: the location of the code to be replaced and the replacement code.
2. The method of claim 1, wherein the detecting whether the current environment is a test environment comprises:
acquiring environment information of the current environment;
acquiring preset environment information of the test environment;
comparing the environment information of the current environment with the preset environment information of the test environment;
determining that the current environment is the test environment in response to the environment information of the current environment being the same as the predetermined environment information of the test environment;
and determining that the current environment is a non-test environment in response to the environment information of the current environment being different from the predetermined environment information of the test environment.
3. The method of claim 2, wherein the environmental information includes at least one of: IP address, MAC address, environment variable.
4. The method of claim 1, wherein modifying the code obtained from the hard disk according to the modification instruction information comprises:
Determining a code to be replaced in the codes obtained from the hard disk according to the position of the code to be replaced;
and replacing the code to be replaced by using the replacing code.
5. A test device, comprising:
the first acquisition module is used for acquiring the modification indication information;
the second acquisition module is used for acquiring codes from the hard disk;
the detection module is used for detecting whether the current environment is a test environment or not;
the first execution module is used for responding to the current environment which is the test environment and modifying codes obtained from the hard disk according to the modification indication information; loading the modified code into a memory; and running the modified code in the memory;
the second execution module is used for loading codes acquired from the hard disk into the memory in response to the current environment being a non-test environment; and running the code in the memory;
the first obtaining module is specifically configured to: detecting a configuration file; analyzing the configuration file to obtain modification indication information, wherein the modification indication information at least comprises: the location of the code to be replaced and the replacement code.
6. The apparatus of claim 5, wherein the detection module comprises:
An obtaining unit, configured to obtain environmental information of the current environment; acquiring preset environment information of the test environment;
a comparison unit for comparing the environment information of the current environment with the predetermined environment information of the test environment;
a first determining unit configured to determine that the current environment is the test environment in response to the environment information of the current environment being the same as predetermined environment information of the test environment;
and the second determining unit is used for determining that the current environment is a non-test environment in response to the fact that the environment information of the current environment is different from the preset environment information of the test environment.
7. A storage medium storing a computer program, characterized in that the computer program when executed implements the method of any one of claims 1 to 4.
8. An electronic device comprising at least a memory, a processor, the memory having stored thereon a computer program, characterized in that the processor, when executing the computer program on the memory, implements the method of any of claims 1 to 4.
CN201910695533.9A 2019-07-30 2019-07-30 Test method and device, storage medium and electronic equipment Active CN110489341B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910695533.9A CN110489341B (en) 2019-07-30 2019-07-30 Test method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910695533.9A CN110489341B (en) 2019-07-30 2019-07-30 Test method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN110489341A CN110489341A (en) 2019-11-22
CN110489341B true CN110489341B (en) 2023-08-11

Family

ID=68548694

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910695533.9A Active CN110489341B (en) 2019-07-30 2019-07-30 Test method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN110489341B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112099805A (en) * 2020-08-11 2020-12-18 欧拉信息服务有限公司 Method and device for issuing application, electronic equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6490721B1 (en) * 1998-07-14 2002-12-03 Oc Systems Incorporated Software debugging method and apparatus
US7610523B1 (en) * 2006-02-09 2009-10-27 Sun Microsystems, Inc. Method and template for physical-memory allocation for implementing an in-system memory test
CN107305528B (en) * 2016-04-25 2020-09-01 北京京东尚科信息技术有限公司 Application testing method and device
CN106201878B (en) * 2016-07-08 2018-11-30 百度在线网络技术(北京)有限公司 The execution method and apparatus of test program
CN109032927A (en) * 2018-06-26 2018-12-18 腾讯科技(深圳)有限公司 A kind of bug excavation method and device

Also Published As

Publication number Publication date
CN110489341A (en) 2019-11-22

Similar Documents

Publication Publication Date Title
CN111679990B (en) Test data generation method and device, readable medium and electronic equipment
CN111897740B (en) User interface testing method and device, electronic equipment and computer readable medium
CN110851139B (en) Method and device for checking codes and electronic equipment
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN112965761B (en) Data processing method, system, electronic equipment and storage medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN112596738B (en) Method and device for determining front-end page to be tested, storage medium and electronic equipment
CN112084024B (en) Memory monitoring method, device, medium and electronic equipment
CN110489341B (en) Test method and device, storage medium and electronic equipment
CN110888773B (en) Method, device, medium and electronic equipment for acquiring thread identification
CN116450511A (en) Information updating method, device, electronic equipment and computer readable medium
CN114296986B (en) Memory leakage positioning method, device, medium and electronic equipment
CN112379967B (en) Simulator detection method, device, equipment and medium
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN116263824A (en) Resource access method and device, storage medium and electronic equipment
CN111538717B (en) Data processing method, device, electronic equipment and computer readable medium
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN112487416A (en) Business process verification method and device and electronic equipment
CN111797009A (en) Method and device for detecting code compatibility and electronic equipment
CN116467178B (en) Database detection method, apparatus, electronic device and computer readable medium
CN111274150B (en) Service instance access method and device and electronic equipment
CN111367555B (en) Assertion method, assertion device, electronic equipment and computer readable medium
CN116545729A (en) Multi-application security test method, device, electronic equipment and computer readable medium
CN116414683A (en) Regression testing method, device, equipment and medium
CN116401173A (en) Test case generation method and device, medium and electronic equipment

Legal Events

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