WO2019090994A1 - Script testing automated execution method, apparatus, equipment and storage medium - Google Patents

Script testing automated execution method, apparatus, equipment and storage medium Download PDF

Info

Publication number
WO2019090994A1
WO2019090994A1 PCT/CN2018/074965 CN2018074965W WO2019090994A1 WO 2019090994 A1 WO2019090994 A1 WO 2019090994A1 CN 2018074965 W CN2018074965 W CN 2018074965W WO 2019090994 A1 WO2019090994 A1 WO 2019090994A1
Authority
WO
WIPO (PCT)
Prior art keywords
script
instance
test
variable
tested
Prior art date
Application number
PCT/CN2018/074965
Other languages
French (fr)
Chinese (zh)
Inventor
胡超
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019090994A1 publication Critical patent/WO2019090994A1/en

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/3688Test management for test execution, e.g. scheduling of test suites

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a test script automatic execution method, apparatus, device, and storage medium.
  • test work is more, if the software test development Every time a person needs to test each script, the test efficiency is very slow, and the existing software script test method can not test multiple scripts according to the minimum time test method. .
  • the embodiment of the present application provides a method, an apparatus, a device, and a storage medium for automatically executing a test script. By collecting all the scripts to be tested and testing, the test efficiency of the software test script can be improved.
  • an embodiment of the present application provides a method for automatically executing a test script, where the method includes:
  • test instance is executed in the instance container if an execution instruction is received.
  • an embodiment of the present application provides a test script automatic execution apparatus, where the apparatus includes:
  • a first acquiring unit configured to acquire a tested script that needs to be executed
  • a copy unit configured to copy the tested script to a preset target storage directory
  • a generating unit configured to generate a test instance corresponding to the tested script
  • a storage unit configured to store the test instance in an instance container
  • a first execution unit configured to execute the test instance in the instance container if an execution instruction is received.
  • test script automatic execution device including:
  • a memory for storing a program that implements an automated execution method of the test script
  • a processor for running a program for executing an automated execution method of the test script stored in the memory to perform the following operations:
  • test instance is executed in the instance container if an execution instruction is received.
  • an embodiment of the present application further provides a computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors Execute to implement the following steps:
  • test instance is executed in the instance container if an execution instruction is received.
  • the embodiment of the present application obtains the tested script that needs to be executed; copies the tested script to a preset target storage directory; generates a test instance corresponding to the tested script; and stores the test instance to the instance container. If the execution instruction is received, the test instance is executed in the instance container, thereby collecting and testing all the scripts to be tested, thereby improving the testing efficiency of the software test script.
  • FIG. 1 is a schematic flow chart of a method for automatically executing a test script according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application
  • FIG. 3 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application
  • FIG. 4 is a schematic flowchart of a method for automatically executing a test script according to another embodiment of the present application.
  • FIG. 5 is a schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application.
  • FIG. 6 is another schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application.
  • FIG. 7 is another schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application.
  • FIG. 8 is another schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a test script automatic execution device according to an embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application.
  • the method can be run on terminals such as smart phones (such as Android phones, IOS phones, etc.), tablets, laptops, and smart devices.
  • the test script automatic execution method described in the embodiment of the present application can improve the test efficiency of the software test script by concentrating all the scripts to be tested and testing.
  • FIG. 1 is a schematic flowchart of a method for automatically executing a test script provided by an embodiment of the present application. The method includes steps S101 to S105.
  • a test process is required to verify the availability of the script to prevent the script file from being developed during the software program development process. Unable to use and cause development to fail.
  • the so-called script that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
  • scripts can be written in the same scripting language.
  • the same script can be written in different scripting languages.
  • the execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts.
  • the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console.
  • each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script.
  • the directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
  • the target storage directory of the tested script is pre-established, so that the tested script is saved in the specified path.
  • the developer can define the specified path by itself. For example, create a file directory at the specified location as needed, and determine the file directory name by typing the file directory name, and target the file directory. The directory is stored, and the storage location of the target storage directory is used as a storage path of the script.
  • the test script is generated by using the JAVA reflection method to generate a corresponding test instance.
  • the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method.
  • the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined.
  • step S103 includes steps S201 to S205.
  • the archived implementation class may be a class in a reflection mechanism provided by Sun Microsystems, for example, the implementation class may be java.lang.Class or java.lang.reflect.Constructor It can also be java.lang.reflect.Field and so on.
  • the Class class is used to describe that an object needs to be created for the Class class, and an attribute corresponding to the object is obtained through the created object, because the object is created by the sealed Class class. So the object has attribute-related data.
  • an attribute refers to a characteristic of an object itself, and an attribute can be used to describe a feature of the object, for example, an object is regarded as an object, and then the shape of the object itself Or the name is the attribute of the object.
  • the attribute of the object is obtained, the attribute includes the first attribute and the second attribute, and the attribute of the object may include the public attribute and the private attribute.
  • the first attribute can point to an attribute that is public to the object, and the second attribute of the present application can point to a private attribute in the object.
  • a method refers to an action or an operation performed by an object, and a result can be returned by the method (for example, the method is a function function), and the object has a corresponding method when the object is created.
  • a method for acquiring an object includes a first method and a second method, and the method of the object may include a public method and a private method, wherein the first method of the present application may point to a method publicly owned by the object
  • the second method of the present application can point to a private method in the object.
  • the method publicly obtained by the object can use the get function getDeclaredMethods().
  • the method of obtaining the object private can use the get function getDeclaredMethod ("method name", parameter type, class , etc).
  • the first attribute, the second attribute, and the first method and the second method may be operated by using a reflection API to generate a test instance, specifically, by decompiling the obtained information and allowing
  • the first attribute, the second attribute, and the first method and the second method of the known name are obtained through the Java Reflection APIs.
  • the internal information of the class class that obtains the known name may be run.
  • the reflection mechanism determines the class to which any object belongs at runtime, constructs an object of any class at runtime, determines the member variables and methods of any class at runtime, and calls any object at runtime.
  • the method finally generates a dynamic proxy, and the generated dynamic proxy is the test instance described in this embodiment.
  • a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then in the selection menu.
  • the intruder's payloads menu after entering the payloads option, enter the Add Instance option in the add window, add the added instance to the left window, then click on the intruder option in the menu, then pop up the drop down menu Make an option to select start attack.
  • step S104 includes steps S301 to S303.
  • variable is a suite variable
  • the suite variable is a specific TestSuite type.
  • variable is used as the instance container.
  • variable is a suite variable, and the variable is used as the instance container, and the suite variable is used as a demo object instance container, wherein the suite variable is used to store the test instance, and the stored test instance can be It is one or more, and the specific quantity is not limited here.
  • all the test instances generated by the test script are stored in the variable, and the configuration file in the execution process only needs to be loaded once, which can improve the testing efficiency of the software test script.
  • the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
  • the test script to be executed is obtained, and the tested script is copied into a preset target storage directory, and a test instance corresponding to the tested script is generated, and the test instance is obtained.
  • the method is stored in the instance container, and if the execution instruction is received, the test instance is executed in the instance container, so that all the tested scripts are centralized and tested, thereby improving the testing efficiency of the software test script.
  • FIG. 4 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application.
  • the method can be run on terminals such as smart phones (such as Android phones, IOS phones, etc.), tablets, laptops, and smart devices.
  • terminals such as smart phones (such as Android phones, IOS phones, etc.), tablets, laptops, and smart devices.
  • the method includes steps S401 to S407.
  • the test process is required to verify the availability of the script to prevent the script file from being in the software program development process. Unable to use and cause development to fail.
  • the so-called script that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
  • scripts can be written in the same scripting language.
  • the same script can be written in different scripting languages.
  • the execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts.
  • the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console.
  • each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script.
  • the directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
  • the file directory may be created in the default folder, and the created file directory may be named.
  • the method of naming is not limited herein, and the naming method may be directly input through an external device (such as a keyboard). name.
  • the location where the file directory is stored is obtained as a storage path corresponding to the file directory, and the storage path is used as a storage path of the script in the following steps.
  • the file directory is used as the target storage directory
  • the storage location of the target storage directory is used as the storage path of the script
  • the test script is generated by using the JAVA reflection method to generate a corresponding test instance.
  • the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method.
  • the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined.
  • a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then in the selection menu.
  • the intruder's payloads menu after entering the payloads option, enter the Add Instance option in the add window, add the added instance to the left window, then click on the intruder option in the menu, then pop up the drop down menu Make an option to select start attack.
  • the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
  • the embodiment of the present application further provides a test script automatic execution device.
  • the device 100 includes: a first obtaining unit 101, a copy unit 102, a generating unit 103, and a storage unit. 104. First execution unit 105.
  • the first obtaining unit 101 is configured to acquire a tested script that needs to be executed.
  • a test process is required to verify the availability of the script to prevent the script file from being developed during the software program development process. Unable to use and cause development to fail.
  • the so-called script that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
  • scripts can be written in the same scripting language.
  • the same script can be written in different scripting languages.
  • the execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts.
  • the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console.
  • each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script.
  • the directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
  • the copy unit 102 is configured to copy the tested script into a preset target storage directory.
  • the target storage directory of the tested script is pre-established, so that the tested script is saved in the specified path.
  • the developer can define the specified path by itself. For example, create a file directory at the specified location as needed, and determine the file directory name by typing the file directory name, and target the file directory. The directory is stored, and the storage location of the target storage directory is used as a storage path of the script.
  • the generating unit 103 is configured to generate a test instance corresponding to the tested script.
  • the test script is generated by using the JAVA reflection method to generate a corresponding test instance.
  • the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method.
  • the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined. Used to store attributes, and through the append method, each attribute is spliced into the defined string. When getting the specified attribute, you need to get the class, id attribute, and instantiate the class, break the package, and finally Give the id attribute of the class a corresponding value.
  • the storage unit 104 is configured to store the test instance into an instance container.
  • a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then in the selection menu.
  • the first execution unit 105 is configured to execute the test instance in the instance container if an execution instruction is received.
  • the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
  • the test script to be executed is obtained, and the tested script is copied into a preset target storage directory, and a test instance corresponding to the tested script is generated, and the test instance is obtained.
  • the method is stored in the instance container, and if the execution instruction is received, the test instance is executed in the instance container, so that all the tested scripts are centralized and tested, thereby improving the testing efficiency of the software test script.
  • the generating unit 103 includes:
  • the calling unit 1031 is configured to invoke an implementation class that has been previously sealed in the tested script.
  • the archived implementation class may be a class in a reflection mechanism provided by Sun Microsystems, for example, the implementation class may be java.lang.Class or java.lang.reflect.Constructor It can also be java.lang.reflect.Field and so on.
  • the second creating unit 1032 is configured to create an object corresponding to the implementation class according to the pre-stored implementation class.
  • the Class class is used to describe that an object needs to be created for the Class class, and an attribute corresponding to the object is obtained through the created object, because the object is created by the sealed Class class. So the object has attribute-related data.
  • the third obtaining unit 1033 is configured to obtain the first attribute and the second attribute according to the created object.
  • an attribute refers to a characteristic of an object itself, and an attribute can be used to describe a feature of the object, for example, an object is regarded as an object, and then the shape of the object itself Or the name is the attribute of the object.
  • the attribute of the object is obtained, the attribute includes the first attribute and the second attribute, and the attribute of the object may include the public attribute and the private attribute.
  • the first attribute can point to an attribute that is public to the object, and the second attribute of the present application can point to a private attribute in the object.
  • the fourth obtaining unit 1034 is configured to obtain the first method and the second method according to the created object.
  • a method refers to an action or operation performed by an object.
  • a method can return a result (such as a function is a function), and an object has a corresponding method when the object is created.
  • the method obtains The method of the object, the method includes a first method and a second method, and the method of the object may include a public method and a private method, wherein the first method of the present application may point to a method publicly owned by the object, the second method of the present application You can point to a private method in the object.
  • the public method of getting the object can use the get function getDeclaredMethods().
  • the method to get the object private can use the get function getDeclaredMethod ("method name", parameter type, class, ... ).
  • the generating sub-unit 1035 is configured to generate the test instance according to the first attribute, the second attribute, and the first method and the second method.
  • the first attribute, the second attribute, and the first method and the second method may be operated by using a reflection API to generate a test instance, specifically, by decompiling the obtained information and allowing
  • the first attribute, the second attribute, and the first method and the second method of the known name are obtained through the Java Reflection APIs.
  • the internal information of the class class that obtains the known name may be run.
  • the reflection mechanism determines the class to which any object belongs at runtime, constructs an object of any class at runtime, determines the member variables and methods of any class at runtime, and calls any object at runtime.
  • the method finally generates a dynamic proxy, and the generated dynamic proxy is the test instance described in this embodiment.
  • the storage unit 104 includes:
  • a unit 1041 is defined for defining a variable of a specified data type.
  • the variable is a suite variable
  • the suite variable is a specific TestSuite type.
  • the third execution unit 1042 is configured to use the variable as the instance container.
  • the variable is a suite variable, and the variable is used as the instance container, and the suite variable is used as a demo object instance container, wherein the suite variable is used to store the test instance, and the stored test instance can be It is one or more, and the specific quantity is not limited here.
  • the storage subunit 1043 is configured to store the test instance into the variable.
  • all the test instances generated by the test script are stored in the variable, and the configuration file in the execution process only needs to be loaded once, which can improve the testing efficiency of the software test script.
  • the embodiment of the present application further provides a test script automatic execution device.
  • the device 200 includes: a first acquiring unit 201, a first creating unit 202, and a second acquiring unit. 203.
  • the first obtaining unit 201 is configured to acquire a tested script that needs to be executed.
  • a test process is required to verify the availability of the script to prevent the script file from being developed during the software program development process. Unable to use and cause development to fail.
  • the so-called script that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
  • scripts can be written in the same scripting language.
  • the same script can be written in different scripting languages.
  • the execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts.
  • the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console.
  • each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script.
  • the directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
  • the first creating unit 202 is configured to create a file directory and type a file directory name.
  • the file directory may be created in the default folder, and the created file directory may be named.
  • the method of naming is not limited herein, and the naming method may be directly input through an external device (such as a keyboard). name.
  • the second obtaining unit 203 is configured to acquire a storage path corresponding to the file directory, where the storage path is used to specify and store the tested script.
  • the location where the file directory is stored is obtained as a storage path corresponding to the file directory, and the storage path is used as a storage path of the script in the following steps.
  • the second executing unit 204 is configured to use the file directory as the preset target storage directory.
  • the generating unit 205 is configured to generate a test instance corresponding to the tested script.
  • the test script is generated by using the JAVA reflection method to generate a corresponding test instance.
  • the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method.
  • the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined. Used to store attributes, and through the append method, splicing each attribute into the defined string. When getting the specified attribute, you need to get the class and id attribute, and after instantiating the class, breaking the package, and finally Give the id attribute of the class a corresponding value.
  • the storage unit 206 is configured to store the test instance into an instance container.
  • a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the variable suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then select the menu.
  • the first execution unit 207 is configured to execute the test instance in the instance container if an execution instruction is received.
  • the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
  • first obtaining unit 101, copy unit 102, generating unit 103, storage unit 104, first executing unit 105, etc. may be embedded in hardware or in a device independent of data processing, or may be in software.
  • the form is stored in a memory of the data processing apparatus such that the processor invokes operations corresponding to the various units above.
  • the processor can be a central processing unit (CPU), a microprocessor, a microcontroller, or the like.
  • test script automated execution device described above can be implemented in the form of a computer program that can be run on a computer device as shown in FIG.
  • FIG. 9 is a schematic structural diagram of a test script automatic execution device according to the present application.
  • the device may be a terminal or a server, wherein the terminal may be a communication device such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device.
  • the server can be a standalone server or a server cluster consisting of multiple servers.
  • the computer device 500 includes a processor 502, a non-volatile storage medium 503, an internal memory 504, and a network interface 505 connected by a system bus 501.
  • the non-volatile storage medium 503 of the computer device 500 can store an operating system 5031 and a computer program 5032.
  • the processor 502 can be caused to execute a test script automation execution method.
  • the processor 502 of the computer device 500 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
  • the internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503, which when executed by the processor, causes the processor 502 to execute a test script automated execution method.
  • the network interface 505 of the computer device 500 is used to perform network communications, such as sending assigned tasks and the like. It will be understood by those skilled in the art that the structure shown in FIG. 9 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device to which the solution of the present application is applied.
  • the specific computer device may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
  • the processor 502 performs the following operations:
  • test instance is executed in the instance container if an execution instruction is received.
  • the copying the tested script to a preset target storage directory includes:
  • the file directory is stored as the preset target directory.
  • the generating a test instance corresponding to the tested script includes:
  • the test instance is generated according to the first attribute, the second attribute, and the first method and the second method.
  • the storing the test instance into an instance container includes:
  • variable as the instance container
  • the test instance is stored in the variable.
  • variable is a suite variable, and the stored instance is stored in the variable, including:
  • the tested instance is stored in the suite variable.
  • test script automation execution device shown in FIG. 9 does not constitute a limitation on the specific configuration of the test script automation execution device.
  • the test script automation execution device may include a comparison diagram. Show more or fewer parts, or combine some parts, or different parts.
  • the test script automatically executes the device to include only the memory and the processor. In such an embodiment, the structure and function of the memory and the processor are consistent with the embodiment shown in FIG. 9, and details are not described herein again. .
  • the application provides a computer readable storage medium having stored one or more programs, the one or more programs being executable by one or more processors to implement the following steps:
  • test instance is executed in the instance container if an execution instruction is received.
  • the copying the tested script to a preset target storage directory includes:
  • the file directory is stored as the preset target directory.
  • the generating a test instance corresponding to the tested script includes:
  • the test instance is generated according to the first attribute, the second attribute, and the first method and the second method.
  • the storing the test instance into an instance container includes:
  • variable as the instance container
  • the test instance is stored in the variable.
  • variable is a suite variable
  • stored instance is stored in the variable, including:
  • the tested instance is stored in the suite variable.
  • the foregoing storage medium of the present application includes: a magnetic disk, an optical disk, a read-only memory (ROM), and the like, which can store various program codes.
  • the units in all the embodiments of the present application may be implemented by a general-purpose integrated circuit, such as a CPU (Central Processing Unit), or by an ASIC (Application Specific Integrated Circuit).
  • a general-purpose integrated circuit such as a CPU (Central Processing Unit), or by an ASIC (Application Specific Integrated Circuit).
  • the steps in the method for automatically executing the test script in the embodiment of the present application may be sequentially adjusted, merged, and deleted according to actual needs.
  • test script automatic execution apparatus of the embodiment of the present application may be combined, divided, and deleted according to actual needs.

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)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A script testing automated execution method, an apparatus (100, 200), equipment and a storage medium, the method comprising: acquiring a script being tested which must be executed (S101, S401); copying the script being tested to a pre-determined target storage directory (S102); generating a testing instance corresponding to the script being tested (S103, S405); storing the testing instance in an instance container (S104, S406); if an execution command is received, executing the testing instance in the instance container (S105, S407). Thus, all scripts being tested are concentrated and tested, increasing testing efficiency of software script testing.

Description

测试脚本自动化执行方法、装置、设备以及存储介质Test script automated execution method, device, device, and storage medium
本申请要求于2017年11月8日提交中国专利局、申请号为CN 201711108258.3、申请名称为“测试脚本自动化执行方法、装置、设备以及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on November 8, 2017, the Chinese Patent Office, the application number is CN 201711108258.3, and the application name is “Test script automation execution method, device, device and storage medium”. The citations are incorporated herein by reference.
技术领域Technical field
本申请涉及计算机技术领域,尤其涉及一种测试脚本自动化执行方法、装置、设备以及存储介质。The present application relates to the field of computer technologies, and in particular, to a test script automatic execution method, apparatus, device, and storage medium.
背景技术Background technique
目前,对于软件测试开发人员来说,每次的软件测试工作都要进行测试脚本和测试脚本对应的测试实例的测试,而对于绝大多数软件开发公司的测试工作又比较多,如果软件测试开发人员每次的测试工作都需要对每个脚本一一进行测试,那么其测试效率是非常慢的,而且现有的软件脚本测试方法中并不能将多个脚本按照最少时间的测试方法进行脚本测试。At present, for software test developers, each time the software test work must test the test script corresponding to the test script and the test script, and for most software development companies, the test work is more, if the software test development Every time a person needs to test each script, the test efficiency is very slow, and the existing software script test method can not test multiple scripts according to the minimum time test method. .
发明内容Summary of the invention
有鉴于此,本申请实施例提供一种测试脚本自动化执行方法、装置、设备以及存储介质,通过集中所有待测试脚本并进行测试,能够提高软件测试脚本的测试效率。In view of this, the embodiment of the present application provides a method, an apparatus, a device, and a storage medium for automatically executing a test script. By collecting all the scripts to be tested and testing, the test efficiency of the software test script can be improved.
第一方面,本申请实施例提供了一种测试脚本自动化执行方法,该方法包括:In a first aspect, an embodiment of the present application provides a method for automatically executing a test script, where the method includes:
获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
另一方面,本申请实施例提供了一种测试脚本自动化执行装置,所述装置 包括:On the other hand, an embodiment of the present application provides a test script automatic execution apparatus, where the apparatus includes:
第一获取单元,用于获取需要执行的被测脚本;a first acquiring unit, configured to acquire a tested script that needs to be executed;
拷贝单元,用于将所述被测脚本拷贝至预设目标存放目录中;a copy unit, configured to copy the tested script to a preset target storage directory;
生成单元,用于生成与所述被测脚本相对应的测试实例;a generating unit, configured to generate a test instance corresponding to the tested script;
存储单元,用于将所述测试实例存储至实例容器中;a storage unit, configured to store the test instance in an instance container;
第一执行单元,用于若接收到执行指令,在所述实例容器中执行所述测试实例。a first execution unit, configured to execute the test instance in the instance container if an execution instruction is received.
又一方面,本申请实施例还提供了一种测试脚本自动化执行设备,包括:In another aspect, the embodiment of the present application further provides a test script automatic execution device, including:
存储器,用于存储实现测试脚本的自动化执行方法的程序;以及a memory for storing a program that implements an automated execution method of the test script;
处理器,用于运行所述存储器中存储的实现测试脚本的自动化执行方法的程序,以执行以下操作:a processor for running a program for executing an automated execution method of the test script stored in the memory to perform the following operations:
获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
再一方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有一个或者一个以上程序,所述一个或者一个以上程序可被一个或者一个以上的处理器执行,以实现以下步骤:In still another aspect, an embodiment of the present application further provides a computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors Execute to implement the following steps:
获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
本申请实施例通过获取需要执行的被测脚本;将所述被测脚本拷贝至预设目标存放目录中;生成与所述被测脚本相对应的测试实例;将所述测试实例存储至实例容器中;若接收到执行指令,在所述实例容器中执行所述测试实例,从而将所有待测试脚本进行集中并进行测试,提高了软件测试脚本的测试效率。The embodiment of the present application obtains the tested script that needs to be executed; copies the tested script to a preset target storage directory; generates a test instance corresponding to the tested script; and stores the test instance to the instance container. If the execution instruction is received, the test instance is executed in the instance container, thereby collecting and testing all the scripts to be tested, thereby improving the testing efficiency of the software test script.
附图说明DRAWINGS
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings used in the description of the embodiments will be briefly described below. Obviously, the drawings in the following description are some embodiments of the present application, For the ordinary technicians, other drawings can be obtained based on these drawings without any creative work.
图1是本申请实施例提供的一种测试脚本自动化执行方法的示意流程图;1 is a schematic flow chart of a method for automatically executing a test script according to an embodiment of the present application;
图2是本申请实施例提供的一种测试脚本自动化执行方法的示意流程图;2 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application;
图3是本申请实施例提供的一种测试脚本自动化执行方法的示意流程图;3 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application;
图4是本申请另一实施例提供的一种测试脚本自动化执行方法的示意流程图;4 is a schematic flowchart of a method for automatically executing a test script according to another embodiment of the present application;
图5是本申请实施例提供的一种测试脚本自动化执行装置的示意性框图;FIG. 5 is a schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application; FIG.
图6是本申请实施例提供的一种测试脚本自动化执行装置的另一示意性框图;FIG. 6 is another schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application; FIG.
图7是本申请实施例提供的一种测试脚本自动化执行装置的另一示意性框图;FIG. 7 is another schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application; FIG.
图8是本申请实施例提供的一种测试脚本自动化执行装置的另一示意性框图;FIG. 8 is another schematic block diagram of a test script automatic execution apparatus according to an embodiment of the present application; FIG.
图9是本申请实施例提供的一种测试脚本自动化执行设备的结构组成示意图。FIG. 9 is a schematic structural diagram of a test script automatic execution device according to an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the drawings in the embodiments of the present application. It is obvious that the described embodiments are a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope are the scope of the present application.
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。The use of the terms "comprising", "comprising", "","," The presence or addition of a plurality of other features, integers, steps, operations, elements, components, and/or collections thereof.
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使 用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。The terminology used herein is for the purpose of describing particular embodiments and is not intended to be limiting. The singular forms "a," ",",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
请参阅图1,图1为本申请实施例提供的一种测试脚本自动化执行方法的示意流程图。该方法可以运行在智能手机(如Android手机、IOS手机等)、平板电脑、笔记本电脑以及智能设备等终端中。本申请实施例所述的测试脚本自动化执行方法,通过集中所有待测试脚本并进行测试,能够提高软件测试脚本的测试效率。图1是本申请实施例提供的测试脚本自动化执行方法的示意流程图。该方法包括步骤S101~S105。Please refer to FIG. 1. FIG. 1 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application. The method can be run on terminals such as smart phones (such as Android phones, IOS phones, etc.), tablets, laptops, and smart devices. The test script automatic execution method described in the embodiment of the present application can improve the test efficiency of the software test script by concentrating all the scripts to be tested and testing. FIG. 1 is a schematic flowchart of a method for automatically executing a test script provided by an embodiment of the present application. The method includes steps S101 to S105.
S101,获取需要执行的被测脚本。S101. Acquire a tested script that needs to be executed.
在本申请实施例中,在计算机程序应用中,不管是开发者自行开发的脚本,还是系统默认的脚本,均需要经过测试过程以便验证脚本的可用性,以防止在软件程序开发过程中因为脚本文件的无法使用而导致开发失败。所谓脚本,即一条条的文字命令,每个脚本文件均可以使用如记事本打开、查看或者编辑,脚本一般可以由应用程序临时调用并执行,例如脚本应用于网页设计以丰富网页的展示,并减少网页的规模和提高网页浏览速度,如动画、声音等。In the embodiment of the present application, in the computer program application, whether it is a script developed by the developer or a default script of the system, a test process is required to verify the availability of the script to prevent the script file from being developed during the software program development process. Unable to use and cause development to fail. The so-called script, that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
需要说明的是,不同的脚本可以使用相同的脚本语言进行编写,相同的脚本可以使用不同的脚本语言进行编写,脚本的执行与编写的脚本语言的类型无关,只与具体的解释执行器有关,因为,不同的脚本语言所编写的脚本可以通过解释器(即解释程序)进行执行即可实现跨平台的使用脚本。关于脚本的文件格式,脚本可以是后缀名为.cfg的文件并放在cstrike文件夹下,执行时在控制台输入:exec(脚本文件名).cfg即可,例如:将一个脚本存为buys.cfg文件,则在控制台中输入:execbuys.cfg则可以实现该脚本的执行。可选的,每个脚本均有自身的脚本存储目录、动态库存储目录、日志存放目录和动态库存储文件等,获取需要执行的被测脚本,即将每个脚本的脚本存储目录、动态库存储目录、日志存储目录和动态库配置文件配置成文件表,然后根据文件表中的脚本存储目录获取全部的脚本。It should be noted that different scripts can be written in the same scripting language. The same script can be written in different scripting languages. The execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts. Regarding the file format of the script, the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console. Optionally, each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script. The directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
S102,将所述被测脚本拷贝至预设目标存放目录中。S102. Copy the tested script to a preset target storage directory.
在本申请实施例中,预先建立被测脚本的目标存放目录,以便指定路径下保存被测脚本。对于建立被测脚本的目标存放目录,可以由开发者自行定义指定路径,例如,根据需要在指定位置创建一个文件目录,通过键入文件目录名 称,确定该文件目录名,并将该文件目录作为目标存放目录,将该目标存放目录的存储位置作为脚本的存放路径,通过以下代码规定保存路径:DIR=″$(cd″$(dirname″${BASH_SOURCE[0]}″)″&&pwd)″。In the embodiment of the present application, the target storage directory of the tested script is pre-established, so that the tested script is saved in the specified path. For the target storage directory of the test script, the developer can define the specified path by itself. For example, create a file directory at the specified location as needed, and determine the file directory name by typing the file directory name, and target the file directory. The directory is stored, and the storage location of the target storage directory is used as a storage path of the script. The save path is specified by the following code: DIR = "$(cd"$(dirname"${BASH_SOURCE[0]}")"&&pwd)".
S103,生成与所述被测脚本相对应的测试实例。S103. Generate a test instance corresponding to the tested script.
在本申请实施例中,利用JAVA反射的方式将被测脚本生成对应的测试实例,具体的,可以通过以下步骤完成:1,获取指定类型的类方法,2,获取类方法后创建对象,3,根据所创建的对象获取属性,该属性分为普通属性和指定属性,4,通过属性构造方法,5,通过构造的方法生成测试实例。例如,获取Employee类型的方法,其执行逻辑如下:首先利用newInstance创建方法的Class对象,通过所创建的Class对象获取普通属性和指定属性,其中获取普通属性时,需要定义可变长的字符串,用来存储属性,并通过追加的方法,将每个属性拼接到所定义的字符串中,在获取指定属性时,需要获取类、id属性,并经过对该类进行实例化,打破封装,最后给该类的id属性赋予相对应的值。In the embodiment of the present application, the test script is generated by using the JAVA reflection method to generate a corresponding test instance. Specifically, the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method. For example, the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined. Used to store attributes, and through the append method, splicing each attribute into the defined string. When getting the specified attribute, you need to get the class and id attribute, and after instantiating the class, breaking the package, and finally Give the id attribute of the class a corresponding value.
进一步地,如图2所示,步骤S103包括步骤S201~S205。Further, as shown in FIG. 2, step S103 includes steps S201 to S205.
S201,调用所述被测脚本中预先已封存的实现类。S201. Call an implementation class that has been previously sealed in the tested script.
在本申请实施例中,已封存的实现类可以是Sun Microsystems公司为我们提供的反射机制中的类,例如,该实现类可以是java.lang.Class,也可以是java.lang.reflect.Constructor,还可以是java.lang.reflect.Field等等。In the embodiment of the present application, the archived implementation class may be a class in a reflection mechanism provided by Sun Microsystems, for example, the implementation class may be java.lang.Class or java.lang.reflect.Constructor It can also be java.lang.reflect.Field and so on.
S202,根据所述预先已封存的实现类,创建与所述实现类相对应的对象。S202. Create an object corresponding to the implementation class according to the pre-stored implementation class.
在本申请实施例中,以Class类进行说明,需要为Class类创建一个对象,并通过所创建的对象获得与该对象相对应的属性,因为该对象是通过已封存的Class类创建而成,所以该对象拥有属性相关的数据。其中,根据预先已封存的实现类创建相对应的对象,例如,Class c=Class.forName(“Employee”),表示创建Class类的对象c,并且对象c所表示的是类的一个新实例。In the embodiment of the present application, the Class class is used to describe that an object needs to be created for the Class class, and an attribute corresponding to the object is obtained through the created object, because the object is created by the sealed Class class. So the object has attribute-related data. The corresponding object is created according to the pre-archived implementation class, for example, Class c=Class.forName("Employee"), which represents the object c that creates the Class class, and the object c represents a new instance of the class.
S203,根据所创建的对象获取到第一属性和第二属性。S203. Acquire a first attribute and a second attribute according to the created object.
在本申请实施例中,一般情况下,属性指的是对象本身所具有的特性,通过属性可以用来描述对象的特征,例如,将对象看作是某一物体,那么物体本身所具有的形状或者名称就作为这个对象的属性,在本实施例中,获取对象的属性,该属性包括第一属性和第二属性,而对象的属性可以包括公有的属性以及私有的属性,其中,本申请的第一属性可以指向对象公有的属性,本申请的 第二属性可以指向对象中私有的属性。In the embodiment of the present application, in general, an attribute refers to a characteristic of an object itself, and an attribute can be used to describe a feature of the object, for example, an object is regarded as an object, and then the shape of the object itself Or the name is the attribute of the object. In this embodiment, the attribute of the object is obtained, the attribute includes the first attribute and the second attribute, and the attribute of the object may include the public attribute and the private attribute. The first attribute can point to an attribute that is public to the object, and the second attribute of the present application can point to a private attribute in the object.
S204,根据所创建的对象获取到第一方法和第二方法。S204. Acquire a first method and a second method according to the created object.
在本申请实施例中,一般情况下,方法指的是对象所作的动作或者操作,通过方法可以返回结果(如方法为功能函数),并且自对象被创建的时候对象就拥有相对应的方法,在本实施例中,获取对象的方法,该方法包括第一方法和第二方法,而对象的方法可以包括公有的方法以及私有的方法,其中,本申请的第一方法可以指向对象公有的方法,本申请的第二方法可以指向对象中私有的方法,例如,获取对象公有的方法可以使用获取函数getDeclaredMethods(),获取对象私有的方法可以使用获取函数getDeclaredMethod(″方法名″,参数类型,class,......)。In the embodiment of the present application, in general, a method refers to an action or an operation performed by an object, and a result can be returned by the method (for example, the method is a function function), and the object has a corresponding method when the object is created. In this embodiment, a method for acquiring an object includes a first method and a second method, and the method of the object may include a public method and a private method, wherein the first method of the present application may point to a method publicly owned by the object The second method of the present application can point to a private method in the object. For example, the method publicly obtained by the object can use the get function getDeclaredMethods(). The method of obtaining the object private can use the get function getDeclaredMethod ("method name", parameter type, class ,......).
S205,根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。S205. Generate the test instance according to the first attribute, the second attribute, and the first method and the second method.
在本申请实施例中,可以使用反射API来操作所述第一属性、第二属性和第一方法、第二方法以生成测试实例,具体的,通过对所获取的这些信息进行反编译并允许在运行时通过Java Reflection APIs来取得已知名字的第一属性、第二属性和第一方法、第二方法,同样地,也可以运行取得已知名字的class类的内部信息(包括其modifiers(诸如public,static等等)、superclass(例如Object)、实现interfaces(例如Serializable),也包括fields和methods的所有信息),动态地生成此类,并调用其方法或修改其域(甚至是本身声明为private的域或方法)。更具体的,反射机制在运行时判断任意一个对象所属的类,在运行时构造任意一个类的对象,在运行时判断任意一个类所具有的成员变量和方法,在运行时调用任意一个对象的方法,最后生成动态代理,并且所生成的动态代理即为本实施例所述的测试实例。In the embodiment of the present application, the first attribute, the second attribute, and the first method and the second method may be operated by using a reflection API to generate a test instance, specifically, by decompiling the obtained information and allowing At runtime, the first attribute, the second attribute, and the first method and the second method of the known name are obtained through the Java Reflection APIs. Similarly, the internal information of the class class that obtains the known name (including its modifiers) may be run. Such as public, static, etc.), superclass (such as Object), implementation of interfaces (such as Serializable), including all information about fields and methods), dynamically generate this class, and call its methods or modify its domain (even its own declaration) Is a private domain or method). More specifically, the reflection mechanism determines the class to which any object belongs at runtime, constructs an object of any class at runtime, determines the member variables and methods of any class at runtime, and calls any object at runtime. The method finally generates a dynamic proxy, and the generated dynamic proxy is the test instance described in this embodiment.
S104,将所述测试实例存储至实例容器中。S104. Store the test instance in an instance container.
在本申请实施例中,可以预先定义一个TestSuite类型的suite变量,并将该suite变量作为存储测试实例的实例容器,并将测试实例存放至suite变量中;操作方法可以是:在当前已经生成的测试实例中,选中需要测试的实例,例如当前选中的测试实例为1,然后在系统平台中点击“add”的选项,可以看到当前实例已经被选中,而且显示为红色,然后进行选择菜单中的intruder中的payloads菜单,进入到了payloads选项之后,在add窗口中进行输入添加实例选项,将 添加的实例添加到左边的窗口中,然后点击菜单中的intruder的选项,然后弹出的下拉的菜单中进行选择为start attack的选项。In the embodiment of the present application, a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then in the selection menu. In the intruder's payloads menu, after entering the payloads option, enter the Add Instance option in the add window, add the added instance to the left window, then click on the intruder option in the menu, then pop up the drop down menu Make an option to select start attack.
进一步地,如图3所示,步骤S104包括步骤S301~S303。Further, as shown in FIG. 3, step S104 includes steps S301 to S303.
S301,定义指定数据类型的变量。S301. Define a variable of a specified data type.
在本申请实施例中,所述变量即为suite变量,并且suite变量为特定的TestSuite类型。In the embodiment of the present application, the variable is a suite variable, and the suite variable is a specific TestSuite type.
S302,将所述变量作为所述实例容器。S302, the variable is used as the instance container.
在本申请实施例中,所述变量为suite变量,将所述变量作为所述实例容器即将所述suite变量作为所魔神实例容器,其中,suite变量用来存放测试实例,所存放的测试实例可以是一个或者多个,具体的数量在此不作限制。In the embodiment of the present application, the variable is a suite variable, and the variable is used as the instance container, and the suite variable is used as a demo object instance container, wherein the suite variable is used to store the test instance, and the stored test instance can be It is one or more, and the specific quantity is not limited here.
S303,将所述测试实例存储至所述变量中。S303. Store the test instance in the variable.
在本申请实施例中,将所有由测试脚本生成的测试实例都存放至所述变量中执行,执行过程中的配置文件只需进行一次加载,可以提高软件测试脚本的测试效率。In the embodiment of the present application, all the test instances generated by the test script are stored in the variable, and the configuration file in the execution process only needs to be loaded once, which can improve the testing efficiency of the software test script.
S105,若接收到执行指令,在所述实例容器中执行所述测试实例。S105. Execute the test instance in the instance container if an execution instruction is received.
在本申请实施例中,实例容器中实现加载每个测试实例需要的配置文件的最大集合,因所有测试脚本的测试实例都在一个实例容器中执行,配置文件只需一次加载,其中,执行过程可以为:1)加载配置文件,2)循环执行实例容器中的每一个测试实例,3)产出全量测试报告。In the embodiment of the present application, the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
由以上可见,本申请实施例通过获取需要执行的被测脚本,将所述被测脚本拷贝至预设目标存放目录中,生成与所述被测脚本相对应的测试实例,将所述测试实例存储至实例容器中,若接收到执行指令,在所述实例容器中执行所述测试实例,从而将所有待测试脚本进行集中并进行测试,提高了软件测试脚本的测试效率。It can be seen from the above that, in the embodiment of the present application, the test script to be executed is obtained, and the tested script is copied into a preset target storage directory, and a test instance corresponding to the tested script is generated, and the test instance is obtained. The method is stored in the instance container, and if the execution instruction is received, the test instance is executed in the instance container, so that all the tested scripts are centralized and tested, thereby improving the testing efficiency of the software test script.
请参阅图4,图4是本申请实施例提供的一种测试脚本自动化执行方法的示意流程图。该方法可以运行在智能手机(如Android手机、IOS手机等)、平板电脑、笔记本电脑以及智能设备等终端中。如图4所示,该方法包括步骤S401~S407。Please refer to FIG. 4. FIG. 4 is a schematic flowchart of a method for automatically executing a test script according to an embodiment of the present application. The method can be run on terminals such as smart phones (such as Android phones, IOS phones, etc.), tablets, laptops, and smart devices. As shown in FIG. 4, the method includes steps S401 to S407.
S401,获取需要执行的被测脚本。S401. Acquire a tested script that needs to be executed.
在本申请实施例中,在计算机程序应用中,不管是开发者自行开发的脚本, 还是系统默认的脚本,均需要经过测试过程以便验证脚本的可用性,以防止在软件程序开发过程中因为脚本文件的无法使用而导致开发失败。所谓脚本,即一条条的文字命令,每个脚本文件均可以使用如记事本打开、查看或者编辑,脚本一般可以由应用程序临时调用并执行,例如脚本应用于网页设计以丰富网页的展示,并减少网页的规模和提高网页浏览速度,如动画、声音等。In the embodiment of the present application, in the computer program application, whether the developer develops the script or the system default script, the test process is required to verify the availability of the script to prevent the script file from being in the software program development process. Unable to use and cause development to fail. The so-called script, that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
需要说明的是,不同的脚本可以使用相同的脚本语言进行编写,相同的脚本可以使用不同的脚本语言进行编写,脚本的执行与编写的脚本语言的类型无关,只与具体的解释执行器有关,因为,不同的脚本语言所编写的脚本可以通过解释器(即解释程序)进行执行即可实现跨平台的使用脚本。关于脚本的文件格式,脚本可以是后缀名为.cfg的文件并放在cstrike文件夹下,执行时在控制台输入:exec(脚本文件名).cfg即可,例如:将一个脚本存为buys.cfg文件,则在控制台中输入:execbuys.cfg则可以实现该脚本的执行。可选的,每个脚本均有自身的脚本存储目录、动态库存储目录、日志存放目录和动态库存储文件等,获取需要执行的被测脚本,即将每个脚本的脚本存储目录、动态库存储目录、日志存储目录和动态库配置文件配置成文件表,然后根据文件表中的脚本存储目录获取全部的脚本。It should be noted that different scripts can be written in the same scripting language. The same script can be written in different scripting languages. The execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts. Regarding the file format of the script, the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console. Optionally, each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script. The directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
S402,创建文件目录并键入文件目录名。S402, create a file directory and type a file directory name.
在本申请实施例中,可以是在默认文件夹下创建文件目录,并对所创建的文件目录进行命名,命名的方式在此不作限制,命名的方法可以是通过外部设备(如键盘)直接键入名称。In the embodiment of the present application, the file directory may be created in the default folder, and the created file directory may be named. The method of naming is not limited herein, and the naming method may be directly input through an external device (such as a keyboard). name.
S403,获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本。S403. Acquire a storage path corresponding to the file directory, where the storage path is used to specify and store a test script.
在本申请实施例中,在完成对所创建的文件目录的命名后,获取文件目录所存储的位置作为该文件目录对应的存储路径,该存储路径在以下步骤中将作为脚本的存放路径。In the embodiment of the present application, after the naming of the created file directory is completed, the location where the file directory is stored is obtained as a storage path corresponding to the file directory, and the storage path is used as a storage path of the script in the following steps.
S404,将所述文件目录作为所述预设目标存放目录。S404. Store the file directory as the preset target storage directory.
在本申请实施例中,将该文件目录作为目标存放目录,将该目标存放目录的存储位置作为脚本的存放路径,通过以下代码规定保存路径:DIR=″$(cd″$(dirname″${BASH_SOURCE[0]}″)″&&pwd)″。In the embodiment of the present application, the file directory is used as the target storage directory, and the storage location of the target storage directory is used as the storage path of the script, and the save path is specified by the following code: DIR=“$(cd′′$(dirname”${ BASH_SOURCE[0]}")"&&pwd)".
S405,生成与所述被测脚本相对应的测试实例。S405. Generate a test instance corresponding to the tested script.
在本申请实施例中,利用JAVA反射的方式将被测脚本生成对应的测试实例,具体的,可以通过以下步骤完成:1,获取指定类型的类方法,2,获取类方法后创建对象,3,根据所创建的对象获取属性,该属性分为普通属性和指定属性,4,通过属性构造方法,5,通过构造的方法生成测试实例。例如,获取Employee类型的方法,其执行逻辑如下:首先利用newInstance创建方法的Class对象,通过所创建的Class对象获取普通属性和指定属性,其中获取普通属性时,需要定义可变长的字符串,用来存储属性,并通过追加的方法,将每个属性拼接到所定义的字符串中,在获取指定属性时,需要获取类、id属性,并经过对该类进行实例化,打破封装,最后给该类的id属性赋予相对应的值。In the embodiment of the present application, the test script is generated by using the JAVA reflection method to generate a corresponding test instance. Specifically, the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method. For example, the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined. Used to store attributes, and through the append method, splicing each attribute into the defined string. When getting the specified attribute, you need to get the class and id attribute, and after instantiating the class, breaking the package, and finally Give the id attribute of the class a corresponding value.
S406,将所述测试实例存储至实例容器中。S406. Store the test instance in an instance container.
在本申请实施例中,可以预先定义一个TestSuite类型的suite变量,并将该suite变量作为存储测试实例的实例容器,并将测试实例存放至suite变量中;操作方法可以是:在当前已经生成的测试实例中,选中需要测试的实例,例如当前选中的测试实例为1,然后在系统平台中点击“add”的选项,可以看到当前实例已经被选中,而且显示为红色,然后进行选择菜单中的intruder中的payloads菜单,进入到了payloads选项之后,在add窗口中进行输入添加实例选项,将添加的实例添加到左边的窗口中,然后点击菜单中的intruder的选项,然后弹出的下拉的菜单中进行选择为start attack的选项。In the embodiment of the present application, a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then in the selection menu. In the intruder's payloads menu, after entering the payloads option, enter the Add Instance option in the add window, add the added instance to the left window, then click on the intruder option in the menu, then pop up the drop down menu Make an option to select start attack.
S407,若接收到执行指令,在所述实例容器中执行所述测试实例。S407. Execute the test instance in the instance container if an execution instruction is received.
在本申请实施例中,实例容器中实现加载每个测试实例需要的配置文件的最大集合,因所有测试脚本的测试实例都在一个实例容器中执行,配置文件只需一次加载,其中,执行过程可以为:1)加载配置文件,2)循环执行实例容器中的每一个测试实例,3)产出全量测试报告。In the embodiment of the present application, the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
请参阅图5,对应上述一种测试脚本自动化执行方法,本申请实施例还提出一种测试脚本自动化执行装置,该装置100包括:第一获取单元101、拷贝单元102、生成单元103、存储单元104、第一执行单元105。Please refer to FIG. 5 , which corresponds to the above-mentioned method for automatically executing test scripts. The embodiment of the present application further provides a test script automatic execution device. The device 100 includes: a first obtaining unit 101, a copy unit 102, a generating unit 103, and a storage unit. 104. First execution unit 105.
其中,所述第一获取单元101,用于获取需要执行的被测脚本。在本申请实施例中,在计算机程序应用中,不管是开发者自行开发的脚本,还是系统默认的脚本,均需要经过测试过程以便验证脚本的可用性,以防止在软件程序开发过程中因为脚本文件的无法使用而导致开发失败。所谓脚本,即一条条的文字 命令,每个脚本文件均可以使用如记事本打开、查看或者编辑,脚本一般可以由应用程序临时调用并执行,例如脚本应用于网页设计以丰富网页的展示,并减少网页的规模和提高网页浏览速度,如动画、声音等。The first obtaining unit 101 is configured to acquire a tested script that needs to be executed. In the embodiment of the present application, in the computer program application, whether it is a script developed by the developer or a default script of the system, a test process is required to verify the availability of the script to prevent the script file from being developed during the software program development process. Unable to use and cause development to fail. The so-called script, that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
需要说明的是,不同的脚本可以使用相同的脚本语言进行编写,相同的脚本可以使用不同的脚本语言进行编写,脚本的执行与编写的脚本语言的类型无关,只与具体的解释执行器有关,因为,不同的脚本语言所编写的脚本可以通过解释器(即解释程序)进行执行即可实现跨平台的使用脚本。关于脚本的文件格式,脚本可以是后缀名为.cfg的文件并放在cstrike文件夹下,执行时在控制台输入:exec(脚本文件名).cfg即可,例如:将一个脚本存为buys.cfg文件,则在控制台中输入:execbuys.cfg则可以实现该脚本的执行。可选的,每个脚本均有自身的脚本存储目录、动态库存储目录、日志存放目录和动态库存储文件等,获取需要执行的被测脚本,即将每个脚本的脚本存储目录、动态库存储目录、日志存储目录和动态库配置文件配置成文件表,然后根据文件表中的脚本存储目录获取全部的脚本。It should be noted that different scripts can be written in the same scripting language. The same script can be written in different scripting languages. The execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts. Regarding the file format of the script, the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console. Optionally, each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script. The directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
拷贝单元102,用于将所述被测脚本拷贝至预设目标存放目录中。在本申请实施例中,预先建立被测脚本的目标存放目录,以便指定路径下保存被测脚本。对于建立被测脚本的目标存放目录,可以由开发者自行定义指定路径,例如,根据需要在指定位置创建一个文件目录,通过键入文件目录名称,确定该文件目录名,并将该文件目录作为目标存放目录,将该目标存放目录的存储位置作为脚本的存放路径,通过以下代码规定保存路径:DIR=″$(cd″$(dirname″${BASH_SOURCE[0]}″)″&&pwd)″。The copy unit 102 is configured to copy the tested script into a preset target storage directory. In the embodiment of the present application, the target storage directory of the tested script is pre-established, so that the tested script is saved in the specified path. For the target storage directory of the test script, the developer can define the specified path by itself. For example, create a file directory at the specified location as needed, and determine the file directory name by typing the file directory name, and target the file directory. The directory is stored, and the storage location of the target storage directory is used as a storage path of the script. The save path is specified by the following code: DIR = "$(cd"$(dirname"${BASH_SOURCE[0]}")"&&pwd)".
生成单元103,用于生成与所述被测脚本相对应的测试实例。在本申请实施例中,利用JAVA反射的方式将被测脚本生成对应的测试实例,具体的,可以通过以下步骤完成:1,获取指定类型的类方法,2,获取类方法后创建对象,3,根据所创建的对象获取属性,该属性分为普通属性和指定属性,4,通过属性构造方法,5,通过构造的方法生成测试实例。例如,获取Employee类型的方法,其执行逻辑如下:首先利用newInstance创建方法的Class对象,通过所创建的Class对象获取普通属性和指定属性,其中获取普通属性时,需要定义可变长的字符串,用来存储属性,并通过追加的方法,将每个属性拼接到所定义的字符串中,在获取指定属性时,需要获取类、id属性,并经过对该类进行实例化, 打破封装,最后给该类的id属性赋予相对应的值。The generating unit 103 is configured to generate a test instance corresponding to the tested script. In the embodiment of the present application, the test script is generated by using the JAVA reflection method to generate a corresponding test instance. Specifically, the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method. For example, the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined. Used to store attributes, and through the append method, each attribute is spliced into the defined string. When getting the specified attribute, you need to get the class, id attribute, and instantiate the class, break the package, and finally Give the id attribute of the class a corresponding value.
存储单元104,用于将所述测试实例存储至实例容器中。在本申请实施例中,可以预先定义一个TestSuite类型的suite变量,并将该suite变量作为存储测试实例的实例容器,并将测试实例存放至suite变量中;操作方法可以是:在当前已经生成的测试实例中,选中需要测试的实例,例如当前选中的测试实例为1,然后在系统平台中点击“add”的选项,可以看到当前实例已经被选中,而且显示为红色,然后进行选择菜单中的intruder中的payloads菜单,进入到了payloads选项之后,在add窗口中进行输入添加实例选项,将添加的实例添加到左边的窗口中,然后点击菜单中的intruder的选项,然后弹出的下拉的菜单中进行选择为start attack的选项。The storage unit 104 is configured to store the test instance into an instance container. In the embodiment of the present application, a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then in the selection menu. In the intruder's payloads menu, after entering the payloads option, enter the Add Instance option in the add window, add the added instance to the left window, then click on the intruder option in the menu, then pop up the drop down menu Make an option to select start attack.
第一执行单元105,用于若接收到执行指令,在所述实例容器中执行所述测试实例。在本申请实施例中,实例容器中实现加载每个测试实例需要的配置文件的最大集合,因所有测试脚本的测试实例都在一个实例容器中执行,配置文件只需一次加载,其中,执行过程可以为:1)加载配置文件,2)循环执行实例容器中的每一个测试实例,3)产出全量测试报告。The first execution unit 105 is configured to execute the test instance in the instance container if an execution instruction is received. In the embodiment of the present application, the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
由以上可见,本申请实施例通过获取需要执行的被测脚本,将所述被测脚本拷贝至预设目标存放目录中,生成与所述被测脚本相对应的测试实例,将所述测试实例存储至实例容器中,若接收到执行指令,在所述实例容器中执行所述测试实例,从而将所有待测试脚本进行集中并进行测试,提高了软件测试脚本的测试效率。It can be seen from the above that, in the embodiment of the present application, the test script to be executed is obtained, and the tested script is copied into a preset target storage directory, and a test instance corresponding to the tested script is generated, and the test instance is obtained. The method is stored in the instance container, and if the execution instruction is received, the test instance is executed in the instance container, so that all the tested scripts are centralized and tested, thereby improving the testing efficiency of the software test script.
如图6所示,所述生成单元103,包括:As shown in FIG. 6, the generating unit 103 includes:
调用单元1031,用于调用所述被测脚本中预先已封存的实现类。在本申请实施例中,已封存的实现类可以是Sun Microsystems公司为我们提供的反射机制中的类,例如,该实现类可以是java.lang.Class,也可以是java.lang.reflect.Constructor,还可以是java.lang.reflect.Field等等。The calling unit 1031 is configured to invoke an implementation class that has been previously sealed in the tested script. In the embodiment of the present application, the archived implementation class may be a class in a reflection mechanism provided by Sun Microsystems, for example, the implementation class may be java.lang.Class or java.lang.reflect.Constructor It can also be java.lang.reflect.Field and so on.
第二创建单元1032,用于根据所述预先已封存的实现类,创建与所述实现类相对应的对象。在本申请实施例中,以Class类进行说明,需要为Class类创建一个对象,并通过所创建的对象获得与该对象相对应的属性,因为该对象是通过已封存的Class类创建而成,所以该对象拥有属性相关的数据。其中,根据预先已封存的实现类创建相对应的对象,例如,Class c =Class.forName(“Employee”),表示创建Class类的对象c,并且对象c所表示的是类的一个新实例。The second creating unit 1032 is configured to create an object corresponding to the implementation class according to the pre-stored implementation class. In the embodiment of the present application, the Class class is used to describe that an object needs to be created for the Class class, and an attribute corresponding to the object is obtained through the created object, because the object is created by the sealed Class class. So the object has attribute-related data. Among them, the corresponding object is created according to the pre-archived implementation class, for example, Class c = Class.forName ("Employee"), which represents the object c that creates the Class class, and the object c represents a new instance of the class.
第三获取单元1033,用于根据所创建的对象获取到第一属性和第二属性。在本申请实施例中,一般情况下,属性指的是对象本身所具有的特性,通过属性可以用来描述对象的特征,例如,将对象看作是某一物体,那么物体本身所具有的形状或者名称就作为这个对象的属性,在本实施例中,获取对象的属性,该属性包括第一属性和第二属性,而对象的属性可以包括公有的属性以及私有的属性,其中,本申请的第一属性可以指向对象公有的属性,本申请的第二属性可以指向对象中私有的属性。The third obtaining unit 1033 is configured to obtain the first attribute and the second attribute according to the created object. In the embodiment of the present application, in general, an attribute refers to a characteristic of an object itself, and an attribute can be used to describe a feature of the object, for example, an object is regarded as an object, and then the shape of the object itself Or the name is the attribute of the object. In this embodiment, the attribute of the object is obtained, the attribute includes the first attribute and the second attribute, and the attribute of the object may include the public attribute and the private attribute. The first attribute can point to an attribute that is public to the object, and the second attribute of the present application can point to a private attribute in the object.
第四获取单元1034,用于根据所创建的对象获取到第一方法和第二方法。一般情况下,方法指的是对象所作的动作或者操作,通过方法可以返回结果(如方法为功能函数),并且自对象被创建的时候对象就拥有相对应的方法,在本实施例中,获取对象的方法,该方法包括第一方法和第二方法,而对象的方法可以包括公有的方法以及私有的方法,其中,本申请的第一方法可以指向对象公有的方法,本申请的第二方法可以指向对象中私有的方法,例如,获取对象公有的方法可以使用获取函数getDeclaredMethods(),获取对象私有的方法可以使用获取函数getDeclaredMethod(″方法名″,参数类型,class,......)。The fourth obtaining unit 1034 is configured to obtain the first method and the second method according to the created object. In general, a method refers to an action or operation performed by an object. A method can return a result (such as a function is a function), and an object has a corresponding method when the object is created. In this embodiment, the method obtains The method of the object, the method includes a first method and a second method, and the method of the object may include a public method and a private method, wherein the first method of the present application may point to a method publicly owned by the object, the second method of the present application You can point to a private method in the object. For example, the public method of getting the object can use the get function getDeclaredMethods(). The method to get the object private can use the get function getDeclaredMethod ("method name", parameter type, class, ... ).
生成子单元1035,用于根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。在本申请实施例中,可以使用反射API来操作所述第一属性、第二属性和第一方法、第二方法以生成测试实例,具体的,通过对所获取的这些信息进行反编译并允许在运行时通过Java Reflection APIs来取得已知名字的第一属性、第二属性和第一方法、第二方法,同样地,也可以运行取得已知名字的class类的内部信息(包括其modifiers(诸如public,static等等)、superclass(例如Object)、实现interfaces(例如Serializable),也包括fields和methods的所有信息),动态地生成此类,并调用其方法或修改其域(甚至是本身声明为private的域或方法)。更具体的,反射机制在运行时判断任意一个对象所属的类,在运行时构造任意一个类的对象,在运行时判断任意一个类所具有的成员变量和方法,在运行时调用任意一个对象的方法,最后生成动态代理,并且所生成的动态代理即为本实施例所述的测试实例。The generating sub-unit 1035 is configured to generate the test instance according to the first attribute, the second attribute, and the first method and the second method. In the embodiment of the present application, the first attribute, the second attribute, and the first method and the second method may be operated by using a reflection API to generate a test instance, specifically, by decompiling the obtained information and allowing At runtime, the first attribute, the second attribute, and the first method and the second method of the known name are obtained through the Java Reflection APIs. Similarly, the internal information of the class class that obtains the known name (including its modifiers) may be run. Such as public, static, etc.), superclass (such as Object), implementation of interfaces (such as Serializable), including all information about fields and methods), dynamically generate this class, and call its methods or modify its domain (even its own declaration) Is a private domain or method). More specifically, the reflection mechanism determines the class to which any object belongs at runtime, constructs an object of any class at runtime, determines the member variables and methods of any class at runtime, and calls any object at runtime. The method finally generates a dynamic proxy, and the generated dynamic proxy is the test instance described in this embodiment.
如图7所示,所述存储单元104,包括:As shown in FIG. 7, the storage unit 104 includes:
定义单元1041,用于定义指定数据类型的变量。在本申请实施例中,所述变量即为suite变量,并且suite变量为特定的TestSuite类型。A unit 1041 is defined for defining a variable of a specified data type. In the embodiment of the present application, the variable is a suite variable, and the suite variable is a specific TestSuite type.
第三执行单元1042,用于将所述变量作为所述实例容器。在本申请实施例中,所述变量为suite变量,将所述变量作为所述实例容器即将所述suite变量作为所魔神实例容器,其中,suite变量用来存放测试实例,所存放的测试实例可以是一个或者多个,具体的数量在此不作限制。The third execution unit 1042 is configured to use the variable as the instance container. In the embodiment of the present application, the variable is a suite variable, and the variable is used as the instance container, and the suite variable is used as a demo object instance container, wherein the suite variable is used to store the test instance, and the stored test instance can be It is one or more, and the specific quantity is not limited here.
存储子单元1043,用于将所述测试实例存储至所述变量中。在本申请实施例中,将所有由测试脚本生成的测试实例都存放至所述变量中执行,执行过程中的配置文件只需进行一次加载,可以提高软件测试脚本的测试效率。The storage subunit 1043 is configured to store the test instance into the variable. In the embodiment of the present application, all the test instances generated by the test script are stored in the variable, and the configuration file in the execution process only needs to be loaded once, which can improve the testing efficiency of the software test script.
请参阅图8,对应上述一种测试脚本自动化执行方法,本申请实施例还提出一种测试脚本自动化执行装置,该装置200包括:第一获取单元201、第一创建单元202、第二获取单元203、第二执行单元204、生成单元205、存储单元206、第一执行单元207。Please refer to FIG. 8 , which corresponds to a method for automatically executing a test script. The embodiment of the present application further provides a test script automatic execution device. The device 200 includes: a first acquiring unit 201, a first creating unit 202, and a second acquiring unit. 203. The second execution unit 204, the generation unit 205, the storage unit 206, and the first execution unit 207.
其中,所述第一获取单元201,用于获取需要执行的被测脚本。在本申请实施例中,在计算机程序应用中,不管是开发者自行开发的脚本,还是系统默认的脚本,均需要经过测试过程以便验证脚本的可用性,以防止在软件程序开发过程中因为脚本文件的无法使用而导致开发失败。所谓脚本,即一条条的文字命令,每个脚本文件均可以使用如记事本打开、查看或者编辑,脚本一般可以由应用程序临时调用并执行,例如脚本应用于网页设计以丰富网页的展示,并减少网页的规模和提高网页浏览速度,如动画、声音等。The first obtaining unit 201 is configured to acquire a tested script that needs to be executed. In the embodiment of the present application, in the computer program application, whether it is a script developed by the developer or a default script of the system, a test process is required to verify the availability of the script to prevent the script file from being developed during the software program development process. Unable to use and cause development to fail. The so-called script, that is, a series of text commands, each script file can be opened, viewed or edited using a notepad, the script can be temporarily called and executed by the application, for example, the script is applied to the webpage design to enrich the display of the webpage, and Reduce the size of web pages and increase the speed of web browsing, such as animation, sound, and more.
需要说明的是,不同的脚本可以使用相同的脚本语言进行编写,相同的脚本可以使用不同的脚本语言进行编写,脚本的执行与编写的脚本语言的类型无关,只与具体的解释执行器有关,因为,不同的脚本语言所编写的脚本可以通过解释器(即解释程序)进行执行即可实现跨平台的使用脚本。关于脚本的文件格式,脚本可以是后缀名为.cfg的文件并放在cstrike文件夹下,执行时在控制台输入:exec(脚本文件名).cfg即可,例如:将一个脚本存为buys.cfg文件,则在控制台中输入:execbuys.cfg则可以实现该脚本的执行。可选的,每个脚本均有自身的脚本存储目录、动态库存储目录、日志存放目录和动态库存储文件等,获取需要执行的被测脚本,即将每个脚本的脚本存储目录、动态库存储目录、日志存储目录和动态库配置文件配置成文件表,然后根据文件表中的脚本 存储目录获取全部的脚本。It should be noted that different scripts can be written in the same scripting language. The same script can be written in different scripting languages. The execution of the script is independent of the type of scripting language being written, and only related to the specific interpreter. Because scripts written by different scripting languages can be executed by an interpreter (ie, an interpreter) to achieve cross-platform use of scripts. Regarding the file format of the script, the script can be a file with a .cfg extension and placed in the cstrike folder. When executing, enter: exec (script file name).cfg in the console, for example: save a script as a buy The .cfg file can be executed by typing: execbuys.cfg in the console. Optionally, each script has its own script storage directory, dynamic library storage directory, log storage directory, and dynamic inventory storage file, etc., to obtain the tested scripts to be executed, that is, the script storage directory and dynamic library storage of each script. The directory, log storage directory, and dynamic library configuration files are configured into a file table, and then all scripts are obtained from the script storage directory in the file table.
第一创建单元202,用于创建文件目录并键入文件目录名。在本申请实施例中,可以是在默认文件夹下创建文件目录,并对所创建的文件目录进行命名,命名的方式在此不作限制,命名的方法可以是通过外部设备(如键盘)直接键入名称。The first creating unit 202 is configured to create a file directory and type a file directory name. In the embodiment of the present application, the file directory may be created in the default folder, and the created file directory may be named. The method of naming is not limited herein, and the naming method may be directly input through an external device (such as a keyboard). name.
第二获取单元203,用于获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本。在本申请实施例中,在完成对所创建的文件目录的命名后,获取文件目录所存储的位置作为该文件目录对应的存储路径,该存储路径在以下步骤中将作为脚本的存放路径。The second obtaining unit 203 is configured to acquire a storage path corresponding to the file directory, where the storage path is used to specify and store the tested script. In the embodiment of the present application, after the naming of the created file directory is completed, the location where the file directory is stored is obtained as a storage path corresponding to the file directory, and the storage path is used as a storage path of the script in the following steps.
第二执行单元204,用于将所述文件目录作为所述预设目标存放目录。在本申请实施例中,将该文件目录作为目标存放目录,将该目标存放目录的存储位置作为脚本的存放路径,通过以下代码规定保存路径:DIR=″$(cd″$(dirname″${BASH_SOURCE[0]}″)″&&pwd)″。The second executing unit 204 is configured to use the file directory as the preset target storage directory. In the embodiment of the present application, the file directory is used as the target storage directory, and the storage location of the target storage directory is used as the storage path of the script, and the save path is specified by the following code: DIR=“$(cd′′$(dirname”${ BASH_SOURCE[0]}")"&&pwd)".
生成单元205,用于生成与所述被测脚本相对应的测试实例。在本申请实施例中,利用JAVA反射的方式将被测脚本生成对应的测试实例,具体的,可以通过以下步骤完成:1,获取指定类型的类方法,2,获取类方法后创建对象,3,根据所创建的对象获取属性,该属性分为普通属性和指定属性,4,通过属性构造方法,5,通过构造的方法生成测试实例。例如,获取Employee类型的方法,其执行逻辑如下:首先利用newInstance创建方法的Class对象,通过所创建的Class对象获取普通属性和指定属性,其中获取普通属性时,需要定义可变长的字符串,用来存储属性,并通过追加的方法,将每个属性拼接到所定义的字符串中,在获取指定属性时,需要获取类、id属性,并经过对该类进行实例化,打破封装,最后给该类的id属性赋予相对应的值。The generating unit 205 is configured to generate a test instance corresponding to the tested script. In the embodiment of the present application, the test script is generated by using the JAVA reflection method to generate a corresponding test instance. Specifically, the method can be completed by the following steps: 1. acquiring a class method of a specified type, and 2, acquiring an object after acquiring the class method, 3 According to the created object, the attribute is divided into a common attribute and a specified attribute. 4, through the attribute construction method, 5, the test instance is generated by the constructed method. For example, the method of obtaining the Employee type has the following execution logic: firstly, the Class object of the method is created by using newInstance, and the ordinary attribute and the specified attribute are obtained by the created Class object, and when the common attribute is obtained, a variable length string needs to be defined. Used to store attributes, and through the append method, splicing each attribute into the defined string. When getting the specified attribute, you need to get the class and id attribute, and after instantiating the class, breaking the package, and finally Give the id attribute of the class a corresponding value.
存储单元206,用于将所述测试实例存储至实例容器中。在本申请实施例中,可以预先定义一个TestSuite类型的suite变量,并将该suite变量作为存储测试实例的实例容器,并将测试实例存放至变量suite变量中;操作方法可以是:在当前已经生成的测试实例中,选中需要测试的实例,例如当前选中的测试实例为1,然后在系统平台中点击“add”的选项,可以看到当前实例已经被选中,而且显示为红色,然后进行选择菜单中的intruder中的payloads菜单,进入到了payloads选项之后,在add窗口中进行输入添加实例选项,将添加的实例添加到 左边的窗口中,然后点击菜单中的intruder的选项,然后弹出的下拉的菜单中进行选择为start attack的选项。The storage unit 206 is configured to store the test instance into an instance container. In the embodiment of the present application, a suite variable of the TestSuite type may be pre-defined, and the suite variable is used as an instance container for storing the test instance, and the test instance is stored in the variable suite variable; the operation method may be: currently generated In the test instance, select the instance to be tested, for example, the currently selected test instance is 1, and then click the "add" option in the system platform, you can see that the current instance has been selected, and it is displayed in red, and then select the menu. In the intruder's payloads menu, after entering the payloads option, enter the Add Instance option in the add window, add the added instance to the left window, then click on the intruder option in the menu, then the drop-down menu pops up Select the option to start attack.
第一执行单元207,用于若接收到执行指令,在所述实例容器中执行所述测试实例。在本申请实施例中,实例容器中实现加载每个测试实例需要的配置文件的最大集合,因所有测试脚本的测试实例都在一个实例容器中执行,配置文件只需一次加载,其中,执行过程可以为:1)加载配置文件,2)循环执行实例容器中的每一个测试实例,3)产出全量测试报告。The first execution unit 207 is configured to execute the test instance in the instance container if an execution instruction is received. In the embodiment of the present application, the instance container implements the largest set of configuration files required for loading each test instance, because the test instances of all the test scripts are executed in one instance container, and the configuration file only needs to be loaded once, wherein the execution process Can be: 1) load the configuration file, 2) loop through each test instance in the instance container, and 3) produce a full test report.
在硬件实现上,以上第一获取单元101、拷贝单元102、生成单元103、存储单元104、第一执行单元105等可以以硬件形式内嵌于或独立于数据处理的装置中,也可以以软件形式存储于数据处理装置的存储器中,以便处理器调用执行以上各个单元对应的操作。该处理器可以为中央处理单元(CPU)、微处理器、单片机等。In hardware implementation, the above first obtaining unit 101, copy unit 102, generating unit 103, storage unit 104, first executing unit 105, etc. may be embedded in hardware or in a device independent of data processing, or may be in software. The form is stored in a memory of the data processing apparatus such that the processor invokes operations corresponding to the various units above. The processor can be a central processing unit (CPU), a microprocessor, a microcontroller, or the like.
上述测试脚本自动化执行装置可以实现为一种计算机程序的形式,计算机程序可以在如图9所示的计算机设备上运行。The test script automated execution device described above can be implemented in the form of a computer program that can be run on a computer device as shown in FIG.
图9为本申请一种测试脚本自动化执行设备的结构组成示意图。该设备可以是终端,也可以是服务器,其中,终端可以是智能手机、平板电脑、笔记本电脑、台式电脑、个人数字助理和穿戴式装置等具有通信功能的电子装置。服务器可以是独立的服务器,也可以是多个服务器组成的服务器集群。参照图9,该计算机设备500包括通过系统总线501连接的处理器502、非易失性存储介质503、内存储器504和网络接口505。其中,该计算机设备500的非易失性存储介质503可存储操作系统5031和计算机程序5032,该计算机程序5032被执行时,可使得处理器502执行一种测试脚本自动化执行方法。该计算机设备500的处理器502用于提供计算和控制能力,支撑整个计算机设备500的运行。该内存储器504为非易失性存储介质503中的计算机程序5032的运行提供环境,该计算机程序被处理器执行时,可使得处理器502执行一种测试脚本自动化执行方法。计算机设备500的网络接口505用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图9中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。FIG. 9 is a schematic structural diagram of a test script automatic execution device according to the present application. The device may be a terminal or a server, wherein the terminal may be a communication device such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, and a wearable device. The server can be a standalone server or a server cluster consisting of multiple servers. Referring to FIG. 9, the computer device 500 includes a processor 502, a non-volatile storage medium 503, an internal memory 504, and a network interface 505 connected by a system bus 501. The non-volatile storage medium 503 of the computer device 500 can store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 can be caused to execute a test script automation execution method. The processor 502 of the computer device 500 is used to provide computing and control capabilities to support the operation of the entire computer device 500. The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503, which when executed by the processor, causes the processor 502 to execute a test script automated execution method. The network interface 505 of the computer device 500 is used to perform network communications, such as sending assigned tasks and the like. It will be understood by those skilled in the art that the structure shown in FIG. 9 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device to which the solution of the present application is applied. The specific computer device may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
其中,所述处理器502执行如下操作:The processor 502 performs the following operations:
获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
在一个实施例中,所述将所述被测脚本拷贝至预设目标存放目录中,包括:In one embodiment, the copying the tested script to a preset target storage directory includes:
创建文件目录并键入文件目录名;Create a file directory and type the file directory name;
获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本;Obtaining a storage path corresponding to the file directory, where the storage path is used to specify and store a test script;
将所述文件目录作为所述预设目标存放目录。The file directory is stored as the preset target directory.
在一个实施例中,所述生成与所述被测脚本相对应的测试实例,包括:In one embodiment, the generating a test instance corresponding to the tested script includes:
调用所述被测脚本中预先已封存的实现类;Calling an implementation class that has been previously sealed in the tested script;
根据所述预先已封存的实现类,创建与所述实现类相对应的对象;Creating an object corresponding to the implementation class according to the pre-stored implementation class;
根据所创建的对象获取到第一属性和第二属性;Obtaining the first attribute and the second attribute according to the created object;
根据所创建的对象获取到第一方法和第二方法;Obtaining the first method and the second method according to the created object;
根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。The test instance is generated according to the first attribute, the second attribute, and the first method and the second method.
在一个实施例中,所述将所述测试实例存储至实例容器中,包括:In one embodiment, the storing the test instance into an instance container includes:
定义指定数据类型的变量;Define variables for the specified data type;
将所述变量作为所述实例容器;Using the variable as the instance container;
将所述测试实例存储至所述变量中。The test instance is stored in the variable.
所述变量为suite变量,所述将所测试实例存储至所述变量中,包括:The variable is a suite variable, and the stored instance is stored in the variable, including:
将所测试实例存储至所述suite变量中。The tested instance is stored in the suite variable.
本领域技术人员可以理解,图9中示出的测试脚本自动化执行设备的实施例并不构成对测试脚本自动化执行设备具体构成的限定,在其他实施例中,测试脚本自动化执行设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。例如,在一些实施例中,测试脚本自动化执行设备以仅包括存储器及处理器,在这样的实施例中,存储器及处理器的结构及功能与图9所示实施例一致,在此不再赘述。It will be understood by those skilled in the art that the embodiment of the test script automation execution device shown in FIG. 9 does not constitute a limitation on the specific configuration of the test script automation execution device. In other embodiments, the test script automation execution device may include a comparison diagram. Show more or fewer parts, or combine some parts, or different parts. For example, in some embodiments, the test script automatically executes the device to include only the memory and the processor. In such an embodiment, the structure and function of the memory and the processor are consistent with the embodiment shown in FIG. 9, and details are not described herein again. .
本申请提供了一种计算机可读存储介质,计算机可读存储介质存储有一个 或者一个以上程序,所述一个或者一个以上程序可被一个或者一个以上的处理器执行,以实现以下步骤:The application provides a computer readable storage medium having stored one or more programs, the one or more programs being executable by one or more processors to implement the following steps:
获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
在一个实施例中,所述将所述被测脚本拷贝至预设目标存放目录中,包括:In one embodiment, the copying the tested script to a preset target storage directory includes:
创建文件目录并键入文件目录名;Create a file directory and type the file directory name;
获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本;Obtaining a storage path corresponding to the file directory, where the storage path is used to specify and store a test script;
将所述文件目录作为所述预设目标存放目录。The file directory is stored as the preset target directory.
在一个实施例中,所述生成与所述被测脚本相对应的测试实例,包括:In one embodiment, the generating a test instance corresponding to the tested script includes:
调用所述被测脚本中预先已封存的实现类;Calling an implementation class that has been previously sealed in the tested script;
根据所述预先已封存的实现类,创建与所述实现类相对应的对象;Creating an object corresponding to the implementation class according to the pre-stored implementation class;
根据所创建的对象获取到第一属性和第二属性;Obtaining the first attribute and the second attribute according to the created object;
根据所创建的对象获取到第一方法和第二方法;Obtaining the first method and the second method according to the created object;
根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。The test instance is generated according to the first attribute, the second attribute, and the first method and the second method.
在一个实施例中,所述将所述测试实例存储至实例容器中,包括:In one embodiment, the storing the test instance into an instance container includes:
定义指定数据类型的变量;Define variables for the specified data type;
将所述变量作为所述实例容器;Using the variable as the instance container;
将所述测试实例存储至所述变量中。The test instance is stored in the variable.
在一个实施例中,所述变量为suite变量,所述将所测试实例存储至所述变量中,包括:In one embodiment, the variable is a suite variable, and the stored instance is stored in the variable, including:
将所测试实例存储至所述suite变量中。The tested instance is stored in the suite variable.
本申请前述的存储介质包括:磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等各种可以存储程序代码的介质。The foregoing storage medium of the present application includes: a magnetic disk, an optical disk, a read-only memory (ROM), and the like, which can store various program codes.
本申请所有实施例中的单元可以通过通用集成电路,例如CPU(Central Processing Unit,中央处理器),或通过ASIC(Application Specific Integrated Circuit,专用集成电路)来实现。The units in all the embodiments of the present application may be implemented by a general-purpose integrated circuit, such as a CPU (Central Processing Unit), or by an ASIC (Application Specific Integrated Circuit).
本申请实施例测试脚本自动化执行方法中的步骤可以根据实际需要进行顺序调整、合并和删减。The steps in the method for automatically executing the test script in the embodiment of the present application may be sequentially adjusted, merged, and deleted according to actual needs.
本申请实施例测试脚本自动化执行装置中的单元可以根据实际需要进行合并、划分和删减。The units in the test script automatic execution apparatus of the embodiment of the present application may be combined, divided, and deleted according to actual needs.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The foregoing is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto, and any equivalents can be easily conceived by those skilled in the art within the technical scope disclosed in the present application. Modifications or substitutions are intended to be included within the scope of the present application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims.

Claims (20)

  1. 一种测试脚本自动化执行方法,其特征在于,所述方法包括:A test script automatic execution method, characterized in that the method comprises:
    获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
    将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
    生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
    将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
    若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
  2. 如权利要求1所述的方法,其特征在于,所述将所述被测脚本拷贝至预设目标存放目录中,包括:The method of claim 1, wherein the copying the tested script to a preset target storage directory comprises:
    创建文件目录并键入文件目录名;Create a file directory and type the file directory name;
    获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本;Obtaining a storage path corresponding to the file directory, where the storage path is used to specify and store a test script;
    将所述文件目录作为所述预设目标存放目录并将被测脚本拷贝至该预设目标存放目录中。The file directory is used as the preset target storage directory and the tested script is copied into the preset target storage directory.
  3. 如权利要求1所述的方法,其特征在于,所述生成与所述被测脚本相对应的测试实例,包括:The method of claim 1, wherein the generating a test instance corresponding to the tested script comprises:
    调用所述被测脚本中预先已封存的实现类;Calling an implementation class that has been previously sealed in the tested script;
    根据所述预先已封存的实现类,创建与所述实现类相对应的对象;Creating an object corresponding to the implementation class according to the pre-stored implementation class;
    根据所创建的对象获取到第一属性和第二属性;Obtaining the first attribute and the second attribute according to the created object;
    根据所创建的对象获取到第一方法和第二方法;Obtaining the first method and the second method according to the created object;
    根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。The test instance is generated according to the first attribute, the second attribute, and the first method and the second method.
  4. 如权利要求1所述的方法,其特征在于,所述将所述测试实例存储至实例容器中,包括:The method of claim 1 wherein said storing said test instance in an instance container comprises:
    定义指定数据类型的变量;Define variables for the specified data type;
    将所述变量作为所述实例容器;Using the variable as the instance container;
    将所述测试实例存储至所述变量中。The test instance is stored in the variable.
  5. 如权利要求4所述的方法,其特征在于,所述变量为suite变量,所述将所述测试实例存储至所述变量中,包括:The method of claim 4, wherein the variable is a suite variable, and the storing the test instance to the variable comprises:
    将所测试实例存储至所述suite变量中。The tested instance is stored in the suite variable.
  6. 一种测试脚本自动化执行装置,其特征在于,所述装置包括:A test script automatic execution device, characterized in that the device comprises:
    第一获取单元,用于获取需要执行的被测脚本;a first acquiring unit, configured to acquire a tested script that needs to be executed;
    拷贝单元,用于将所述被测脚本拷贝至预设目标存放目录中;a copy unit, configured to copy the tested script to a preset target storage directory;
    生成单元,用于生成与所述被测脚本相对应的测试实例;a generating unit, configured to generate a test instance corresponding to the tested script;
    存储单元,用于将所述测试实例存储至实例容器中;a storage unit, configured to store the test instance in an instance container;
    第一执行单元,用于若接收到执行指令,在所述实例容器中执行所述测试实例。a first execution unit, configured to execute the test instance in the instance container if an execution instruction is received.
  7. 如权利要求6所述的装置,其特征在于,所述拷贝单元,包括:The device according to claim 6, wherein the copy unit comprises:
    第一创建单元,用于创建文件目录并键入文件目录名;The first creation unit is used to create a file directory and type a file directory name;
    第二获取单元,用于获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本;a second obtaining unit, configured to acquire a storage path corresponding to the file directory, where the storage path is used to specify and store the tested script;
    第二执行单元,用于将所述文件目录作为所述预设目标存放目录并将被测脚本拷贝至该预设目标存放目录中。And a second execution unit, configured to use the file directory as the preset target storage directory and copy the tested script into the preset target storage directory.
  8. 如权利要求6所述的装置,其特征在于,所述生成单元,包括:The device of claim 6, wherein the generating unit comprises:
    调用单元,用于调用所述被测脚本中预先已封存的实现类;a calling unit, configured to invoke a pre-stored implementation class in the tested script;
    第二创建单元,用于根据所述预先已封存的实现类,创建与所述实现类相对应的对象;a second creating unit, configured to create an object corresponding to the implementation class according to the pre-stored implementation class;
    第三获取单元,用于根据所创建的对象获取到第一属性和第二属性;a third acquiring unit, configured to acquire the first attribute and the second attribute according to the created object;
    第四获取单元,用于根据所创建的对象获取到第一方法和第二方法;a fourth obtaining unit, configured to acquire the first method and the second method according to the created object;
    生成子单元,用于根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。And generating a subunit, configured to generate the test instance according to the first attribute, the second attribute, and the first method and the second method.
  9. 如权利要求6所述的装置,其特征在于,所述存储单元,包括:The device of claim 6, wherein the storage unit comprises:
    定义单元,用于定义指定数据类型的变量。A unit that defines a variable that specifies a data type.
    第三执行单元,用于将所述变量作为所述实例容器。a third execution unit for using the variable as the instance container.
    存储子单元,用于将所述测试实例存储至所述变量中。a storage subunit for storing the test instance in the variable.
  10. 如权利要求9所述的装置,其特征在于,所述变量为suite变量,所述存储子单元还用于:将所测试实例存储至所述suite变量中。The apparatus according to claim 9, wherein the variable is a suite variable, and the storage subunit is further configured to: store the tested instance into the suite variable.
  11. 一种测试脚本自动化执行设备,其特征在于,包括:A test script automatic execution device, comprising:
    存储器,用于存储实现测试脚本的自动化执行方法的程序;以及a memory for storing a program that implements an automated execution method of the test script;
    处理器,用于运行所述存储器中存储的实现测试脚本的自动化执行方法的 程序,以执行以下操作:a processor for executing a program stored in the memory to implement an automated execution method of the test script to perform the following operations:
    获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
    将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
    生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
    将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
    若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
  12. 如权利要求11所述的设备,其特征在于,所述将所述被测脚本拷贝至预设目标存放目录中,包括:The device according to claim 11, wherein the copying the tested script to a preset target storage directory comprises:
    创建文件目录并键入文件目录名;Create a file directory and type the file directory name;
    获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本;Obtaining a storage path corresponding to the file directory, where the storage path is used to specify and store a test script;
    将所述文件目录作为所述预设目标存放目录并将被测脚本拷贝至该预设目标存放目录中。The file directory is used as the preset target storage directory and the tested script is copied into the preset target storage directory.
  13. 如权利要求11所述的设备,其特征在于,所述生成与所述被测脚本相对应的测试实例,包括:The device according to claim 11, wherein the generating a test instance corresponding to the tested script comprises:
    调用所述被测脚本中预先已封存的实现类;Calling an implementation class that has been previously sealed in the tested script;
    根据所述预先已封存的实现类,创建与所述实现类相对应的对象;Creating an object corresponding to the implementation class according to the pre-stored implementation class;
    根据所创建的对象获取到第一属性和第二属性;Obtaining the first attribute and the second attribute according to the created object;
    根据所创建的对象获取到第一方法和第二方法;Obtaining the first method and the second method according to the created object;
    根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。The test instance is generated according to the first attribute, the second attribute, and the first method and the second method.
  14. 如权利要求11所述的设备,其特征在于,所述将所述测试实例存储至实例容器中,包括:The device of claim 11, wherein the storing the test instance into an instance container comprises:
    定义指定数据类型的变量;Define variables for the specified data type;
    将所述变量作为所述实例容器;Using the variable as the instance container;
    将所述测试实例存储至所述变量中。The test instance is stored in the variable.
  15. 如权利要求14所述的设备,其特征在于,所述变量为suite变量,所述将所述测试实例存储至所述变量中,包括:The device according to claim 14, wherein the variable is a suite variable, and the storing the test instance into the variable comprises:
    将所测试实例存储至所述suite变量中。The tested instance is stored in the suite variable.
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有一个或者一个以上程序,所述一个或者一个以上程序可被一个或者一个以上 的处理器执行,以实现以下步骤:A computer readable storage medium, characterized in that the computer readable storage medium stores one or more programs, the one or more programs being executable by one or more processors to implement the steps of:
    获取需要执行的被测脚本;Get the script to be executed that needs to be executed;
    将所述被测脚本拷贝至预设目标存放目录中;Copying the tested script to a preset target storage directory;
    生成与所述被测脚本相对应的测试实例;Generating a test instance corresponding to the tested script;
    将所述测试实例存储至实例容器中;Storing the test instance in an instance container;
    若接收到执行指令,在所述实例容器中执行所述测试实例。The test instance is executed in the instance container if an execution instruction is received.
  17. 如权利要求16所述的计算机可读存储介质,其特征在于,所述将所述被测脚本拷贝至预设目标存放目录中,包括:The computer readable storage medium according to claim 16, wherein the copying the tested script to a preset target storage directory comprises:
    创建文件目录并键入文件目录名;Create a file directory and type the file directory name;
    获取所述文件目录对应的存储路径,其中所述存储路径用于指定并存放被测脚本;Obtaining a storage path corresponding to the file directory, where the storage path is used to specify and store a test script;
    将所述文件目录作为所述预设目标存放目录并将被测脚本拷贝至该预设目标存放目录中。The file directory is used as the preset target storage directory and the tested script is copied into the preset target storage directory.
  18. 如权利要求16所述的计算机可读存储介质,其特征在于,所述生成与所述被测脚本相对应的测试实例,包括:The computer readable storage medium of claim 16, wherein the generating a test instance corresponding to the tested script comprises:
    调用所述被测脚本中预先已封存的实现类;Calling an implementation class that has been previously sealed in the tested script;
    根据所述预先已封存的实现类,创建与所述实现类相对应的对象;Creating an object corresponding to the implementation class according to the pre-stored implementation class;
    根据所创建的对象获取到第一属性和第二属性;Obtaining the first attribute and the second attribute according to the created object;
    根据所创建的对象获取到第一方法和第二方法;Obtaining the first method and the second method according to the created object;
    根据所述第一属性、第二属性和第一方法、第二方法生成所述测试实例。The test instance is generated according to the first attribute, the second attribute, and the first method and the second method.
  19. 如权利要求16所述的计算机可读存储介质,其特征在于,所述将所述测试实例存储至实例容器中,包括:The computer readable storage medium of claim 16, wherein the storing the test instance into an instance container comprises:
    定义指定数据类型的变量;Define variables for the specified data type;
    将所述变量作为所述实例容器;Using the variable as the instance container;
    将所述测试实例存储至所述变量中。The test instance is stored in the variable.
  20. 如权利要求19所述的计算机可读存储介质,其特征在于,所述变量为suite变量,所述将所述测试实例存储至所述变量中,包括:The computer readable storage medium of claim 19, wherein the variable is a suite variable, and the storing the test instance into the variable comprises:
    将所测试实例存储至所述suite变量中。The tested instance is stored in the suite variable.
PCT/CN2018/074965 2017-11-08 2018-02-01 Script testing automated execution method, apparatus, equipment and storage medium WO2019090994A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201711108258.3A CN107766252A (en) 2017-11-08 2017-11-08 Test script automated execution method, apparatus, equipment and storage medium
CN201711108258.3 2017-11-08

Publications (1)

Publication Number Publication Date
WO2019090994A1 true WO2019090994A1 (en) 2019-05-16

Family

ID=61272917

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/074965 WO2019090994A1 (en) 2017-11-08 2018-02-01 Script testing automated execution method, apparatus, equipment and storage medium

Country Status (2)

Country Link
CN (1) CN107766252A (en)
WO (1) WO2019090994A1 (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108536596A (en) * 2018-04-09 2018-09-14 武汉斗鱼网络科技有限公司 Automated testing method, readable medium based on object formation data and equipment
CN110727575B (en) * 2018-07-17 2021-04-23 腾讯科技(深圳)有限公司 Information processing method, system, device and storage medium
CN108845950A (en) * 2018-08-03 2018-11-20 平安科技(深圳)有限公司 Test device, the method for test and storage medium
CN109800154B (en) * 2018-12-15 2022-04-05 深圳壹账通智能科技有限公司 Test data loading method and device, computer equipment and storage medium
CN110321289A (en) * 2019-06-24 2019-10-11 平安科技(深圳)有限公司 A kind of batch testing method and device of DTO class
CN110377520B (en) * 2019-07-22 2024-03-15 中国工商银行股份有限公司 Transaction scenario testing method and device, electronic equipment and readable storage medium
CN111949543B (en) * 2020-08-13 2023-09-08 中国工商银行股份有限公司 Test method and device based on distributed platform, electronic equipment and storage medium
CN113742316A (en) * 2021-09-08 2021-12-03 辽宁振兴银行股份有限公司 Device and method for synchronizing Mysql database by executing sql sentences in batches

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1949186A (en) * 2006-11-17 2007-04-18 深圳市领测科技有限公司 Program testing system and mapping method for said program testing system
CN101017457A (en) * 2007-02-09 2007-08-15 山东浪潮齐鲁软件产业股份有限公司 Automatically testing method of computer software
CN101042673A (en) * 2007-04-20 2007-09-26 北京航空航天大学 Software testing system and testing method
US20080244524A1 (en) * 2007-03-27 2008-10-02 Tim Kelso Program Test System
CN106547689A (en) * 2016-10-20 2017-03-29 金航数码科技有限责任公司 A kind of automatic test cases development system and method based on web

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100472473C (en) * 2007-06-22 2009-03-25 中兴通讯股份有限公司 Method and device for implementing test script management and distribution
CN104750606B (en) * 2015-03-03 2017-11-07 北京空间飞行器总体设计部 A kind of automated testing method based on reflection
CN106326102A (en) * 2015-07-06 2017-01-11 阿里巴巴集团控股有限公司 Test method and apparatus
US9501389B1 (en) * 2015-08-20 2016-11-22 International Business Machines Corporation Test machine management
CN106021098A (en) * 2016-05-10 2016-10-12 上海斐讯数据通信技术有限公司 Test system for running scripts in batches

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1949186A (en) * 2006-11-17 2007-04-18 深圳市领测科技有限公司 Program testing system and mapping method for said program testing system
CN101017457A (en) * 2007-02-09 2007-08-15 山东浪潮齐鲁软件产业股份有限公司 Automatically testing method of computer software
US20080244524A1 (en) * 2007-03-27 2008-10-02 Tim Kelso Program Test System
CN101042673A (en) * 2007-04-20 2007-09-26 北京航空航天大学 Software testing system and testing method
CN106547689A (en) * 2016-10-20 2017-03-29 金航数码科技有限责任公司 A kind of automatic test cases development system and method based on web

Also Published As

Publication number Publication date
CN107766252A (en) 2018-03-06

Similar Documents

Publication Publication Date Title
WO2019090994A1 (en) Script testing automated execution method, apparatus, equipment and storage medium
US11010283B2 (en) Mock-based unit test(s) for an end-to-end test of a code snippet
US9946525B2 (en) Extracting source code
WO2016155388A1 (en) Method and device for installing and running application
US10019298B2 (en) Middleware interface and middleware interface generator
RU2601198C2 (en) Runtime system
US10048960B2 (en) Identifying source code used to build executable files
US10684846B2 (en) Using semantic annotations to control compatibility behaviors
US9792198B2 (en) Debugger with method restart capability
US10747510B1 (en) Application runtime modification
US11474810B2 (en) Run-time application modification
US8141042B2 (en) Extending portability of java code through the use of AOP
CN112506854B (en) Page template file storage and page generation methods, devices, equipment and media
Farooq et al. Runtimedroid: Restarting-free runtime change handling for android apps
CN110716720A (en) Method and device for realizing application hot deployment
US10409567B2 (en) Trimming unused dependencies using package graph and module graph
US11403074B1 (en) Systems and methods for generating interfaces for callback functions in object-oriented classes
US8516455B2 (en) Dynamic loading of kernel extensions
EP2511820A1 (en) Bypassing user mode redirection
CN114217789A (en) Function component expansion method, device, equipment, storage medium and program product
WO2021097683A1 (en) Android system starting method and apparatus, device, and storage medium
US20230169138A1 (en) Rendering primitive child elements corresponding to child components of a user interface without instantiating the child components
CN114911541A (en) Configuration information processing method and device, electronic equipment and storage medium
US8850399B2 (en) Software development using code retraction and background warm up
CN112068814A (en) Method, device, system and medium for generating executable file

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18875870

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 02.10.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18875870

Country of ref document: EP

Kind code of ref document: A1