CN111881041A - Front-end application testing method and device, terminal equipment and storage medium - Google Patents

Front-end application testing method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN111881041A
CN111881041A CN202010727853.0A CN202010727853A CN111881041A CN 111881041 A CN111881041 A CN 111881041A CN 202010727853 A CN202010727853 A CN 202010727853A CN 111881041 A CN111881041 A CN 111881041A
Authority
CN
China
Prior art keywords
test
end application
file
node
application file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010727853.0A
Other languages
Chinese (zh)
Inventor
樊丰春
沈瑶
刘志伟
李亚军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Pingan Payment Technology Service Co Ltd
Original Assignee
Pingan Payment Technology Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Pingan Payment Technology Service Co Ltd filed Critical Pingan Payment Technology Service Co Ltd
Priority to CN202010727853.0A priority Critical patent/CN111881041A/en
Publication of CN111881041A publication Critical patent/CN111881041A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/349Performance evaluation by tracing or monitoring for interfaces, buses
    • 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

Abstract

The application is applicable to the technical field of research and development management, and provides a front-end application testing method, a device, terminal equipment and a storage medium, wherein the front-end application testing method is characterized in that the component information of each front-end component in a front-end application file is identified, the component information comprises the position information of the front-end component and a script file, and the position information is a storage path of the front-end component stored in the front-end application file; generating a test node corresponding to each front-end component according to the position information of each front-end component, and configuring the script file to the test node; injecting abnormal information into the script file on each test node to obtain a test front-end application file; and when the test front-end application file is operated, obtaining a test result generated by the test front-end application file. The user can conveniently acquire the application file of the test front end by injecting the abnormal information into the test node, and can quickly acquire the test result generated by the application file of the test front end when the abnormality occurs.

Description

Front-end application testing method and device, terminal equipment and storage medium
Technical Field
The present application relates to the field of research and development management technologies, and in particular, to a front-end application testing method and apparatus, a terminal device, and a storage medium.
Background
Nowadays, a rear-end chaotic engineering tool is injected into a rear-end distributed system at random by simulating a series of system, service call or network and other abnormalities, and the reaction of the system is observed. However, as a functional entry directly faced by a user, that is, a front-end page formed by a series of front-end components is not tested by using any tool, the user may suffer from various problems during using the front-end application, so that the front-end page during using the front-end application is white and even the application crashes. Therefore, in the prior art, when only a back-end system of the front-end application is tested, a test scheme for the front-end application is not available, and the problem of abnormal conditions which may occur in the use process of the front-end application cannot be tested in advance.
Disclosure of Invention
In view of this, embodiments of the present application provide a front-end application testing method, apparatus, terminal device and computer-readable storage medium, so as to solve the problem that there is no testing scheme for front-end application in the prior art, and an abnormal condition that may occur in a using process of the front-end application cannot be tested in advance.
A first aspect of an embodiment of the present application provides a front-end application testing method, including:
identifying component information for each front-end component in the front-end application file; the component information comprises position information of the front-end component and a script file, and the position information is a storage path stored by the front-end component under the front-end application file;
generating a test node corresponding to each front-end component according to the position information of each front-end component, and configuring the script file to the test node;
injecting abnormal information into the script file on each test node to obtain a test front-end application file;
and when the test front-end application file is operated, obtaining a test result generated by the test front-end application file.
In an embodiment, before generating a test node corresponding to each front-end component according to the location information of each front-end component, the method further includes:
acquiring a chaos tool and storing the chaos tool into an installation directory of the front-end application file;
and operating the chaotic tool, identifying each front-end component of the front-end application file under the installation catalog, and correspondingly generating each test node.
In an embodiment, after the generating a test node corresponding to each front-end component according to the location information of each front-end component, the method further includes:
acquiring the dependency relationship between each test node generated in sequence according to the position information of each front-end component;
and correspondingly generating a test node tree for each test node according to the dependency relationship among the test nodes.
In one embodiment, the chaos tool comprises a plurality of anomaly information, each anomaly information having a corresponding initial weight value;
the injecting abnormal information into the script file on each test node to obtain a test front-end application file includes:
correspondingly identifying target nodes in the test node tree, wherein the target nodes are nodes correspondingly generated by a plurality of front end components under the same installation directory identified by the chaotic tool;
randomly acquiring the abnormal information according to the initial weight value in the plurality of abnormal information;
and injecting the abnormal information into a script file corresponding to the target node to obtain the test front-end application file.
In an embodiment, after obtaining a test result generated by the test front-end application file when the test front-end application file is run, the method further includes:
receiving a modification instruction issued by a tester according to the test result;
correspondingly modifying the initial weight value of the abnormal information according to the modification instruction;
in the plurality of abnormal information, randomly injecting the abnormal information into the script file corresponding to the target node for a plurality of times according to the modified initial weight value;
and acquiring a test result generated by the front-end application when the abnormity occurs for multiple times, and modifying the script file corresponding to the target node according to the test result.
In one embodiment, the exception information includes an exception, an exception capture function, and an exception injection function;
before the obtaining of the test result generated by the test front-end application file when the test front-end application file is run, the method further includes:
receiving an injection instruction, wherein the injection instruction is used for injecting the abnormity and the abnormity capture function into a script file corresponding to the target node according to an abnormity injection function in the abnormity information to generate the test front-end application file;
and running the test front-end application file, and capturing the script file corresponding to the abnormity according to the abnormity capturing function when the abnormity occurs.
In an embodiment, after obtaining a test result generated by the test front-end application file when the test front-end application file is run, the method includes:
stopping running the test front-end application file;
acquiring a preset processing scheme, and solving the test result according to the processing scheme;
and after the test result is solved, uploading the test result to a block chain, and continuously running the test front-end application file.
A second aspect of the embodiments of the present application provides a front-end application testing apparatus, including:
the identification module is used for identifying the component information of each front-end component in the front-end application file; the component information comprises position information of the front-end component and a script file, and the position information is a storage path stored by the front-end component under the front-end application file;
the first generation module is used for generating a test node corresponding to each front-end component according to the position information of each front-end component and configuring the script file to the test node;
the first injection module is used for injecting abnormal information into the script file on each test node to obtain a test front-end application file;
the first obtaining module is used for obtaining a test result generated by the test front-end application file when the test front-end application file is operated.
A fourth aspect of the embodiments of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the terminal device, where the processor implements the steps of the front-end application testing method provided in the first aspect when executing the computer program.
A fifth aspect of embodiments of the present application provides a computer-readable storage medium, which stores a computer program that, when executed by a processor, implements the steps of the front-end application testing method provided by the first aspect.
The implementation of the front-end application testing method, the front-end application testing device, the terminal equipment and the computer readable storage medium provided by the embodiment of the application has the following beneficial effects:
according to the front-end application testing method provided by the embodiment of the application, the testing node of each front-end component is generated by identifying the component information of the front-end application file, and the script file is configured in the testing node, so that a testing user can visually and visually observe each front-end component. And the user can conveniently acquire the application file of the test front end by injecting the abnormal information into the test node, the efficiency of injecting the abnormal information by the test user is improved, and the test result generated by the application file of the test front end when the abnormality occurs is further quickly acquired.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating an implementation of a front-end application testing method according to an embodiment of the present disclosure;
fig. 2 is a flowchart illustrating an implementation of a front-end application testing method according to another embodiment of the present application;
FIG. 3 is a flowchart illustrating an implementation of a method for testing a front-end application according to yet another embodiment of the present application;
FIG. 4 is a flowchart illustrating an implementation of a method for testing a front-end application according to another embodiment of the present application;
fig. 5 is a block diagram illustrating a front-end application testing apparatus according to an embodiment of the present disclosure;
fig. 6 is a block diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The front-end application test method according to the embodiment of the present application may be executed by a control device or a terminal (hereinafter referred to as a "mobile terminal").
Referring to fig. 1, fig. 1 is a flowchart illustrating an implementation of a front-end application testing method according to an embodiment of the present disclosure.
S101, identifying component information of each front-end component in a front-end application file; the component information comprises position information of the front-end component and a script file, and the position information is a storage path stored by the front-end component under the front-end application file.
In application, the front-end application file is used for generating a front-end application, and the correspondingly generated front-end application may be web page application software or application software on the mobile terminal. It has function buttons that can be operated by the test user, i.e. the front-end application has a function entry (front-end page) that faces directly towards the test user. Illustratively, a desktop (computer desktop) on the mobile terminal has a front-end application software, and by clicking the front-end application software, the mobile terminal can load a web front-end application interface and load a required front-end application interface, i.e., a front-end page, on the web front-end application interface. Currently, the front-end page of web applications is basically implemented by Vue (progressive framework building user interface) or reach framework (framework creating interactive user interface), however, the basis of the front-end page implemented by Vue or reach framework is to use a series of nested components. It is understood that the front-end page is composed of a plurality of executable front-end components in the front-end application file, and when the front-end application interface is loaded, the executable operation function buttons and the display page are generated according to the executable front-end components. The language file can be generated by a JavaScript language, is a client-side script language which is driven by an object and an event and has relative safety, is a script language which is widely used for webpage application, is usually used for adding a dynamic function to html webpage application and responding various operations of a test user.
In application, the front-end application file downloaded by the mobile terminal is generally stored in a database (a storage hard disk of the computer device) of the mobile terminal. The script file can be regarded as a file containing code information, and the file displayed on the desktop of the mobile terminal can be understood as a convenient use mode of the front-end application file on the mobile terminal.
S102, generating a test node corresponding to each front-end component according to the position information of each front-end component, and configuring the script file to the test node.
In application, after generating the test node corresponding to each front-end component, the generation tool may obtain a storage path (location information) stored by each front-end component under a front-end application file, where the storage paths corresponding to each front-end component have corresponding relations and have a hierarchical relationship with each other. The generation tool can be internally pre-stored with a recursive program, and can establish a node and add a node object (corresponding script file) into the node after reading the correspondingly stored position information. If there are remaining front-end components under the storage path, the program can again build nodes one by one. In an actual situation, the test user does not know whether a next test node is still provided under a certain test node, the recursion procedure circularly calls the test user during operation, and the test nodes are gradually added in a recursion mode.
Illustratively, for a hypertext markup language document (front-end application component), which can be a document node (root test node), each hypertext markup language tag contained within the document can be considered a tag node (next test node), and the front-end components contained in the hypertext markup language tags are text nodes (next test node) until each hypertext markup language attribute is an attribute node (bottom test node). Because each front-end component in the front-end application file is stored in the same or different levels of installation locations, the test node generated by the front-end application file can be regarded as a set of multiple test nodes with a hierarchical relationship. The generated test nodes can be used for configuring corresponding script files and are visually displayed on an operation interface of the mobile terminal, and a test user can search the script files corresponding to the configuration by clicking the test nodes.
S103, injecting abnormal information into the script file on each test node to obtain a test front-end application file.
In an application, the exception information is used for enabling the corresponding script file to generate an exception in a running process. The exception information includes an exception, which may be a preset section of code, and the code may be set according to actual needs. The exception information may be internally predefined with a new script file containing an exception, which contains a code corresponding to the exception, a logical process (capture process, response process) for the exception, and a parameter value capable of pointing to the original script file returned to the test node. And the new script file can obtain the parameter values during the operation, and points to the original script file according to the parameter values to execute, so that all corresponding functions of the original script file and the functions which correspondingly occur when the execution is abnormal are realized. And then, injecting abnormal information into the script file, and packaging the script file to generate a test front-end application component. For example, a null pointer exception, which may cause a crash of the front-end application file runtime, may be denoted by "NULLPOLLUTEREXCEPTION". After the code is injected into the script file in the test node, the corresponding script file can be modified, and a test front-end application file containing the modified script file is generated. In the application, the number of the test nodes is plural, the number of the corresponding script files is plural, the same or different exception information may be injected into all the nodes at the same time to test the application file at the test front end, the same or different exception information may be injected into a plurality of designated script files, or a plurality of different exception information may be injected into a designated script file at the same time, which is not limited herein.
And S104, when the test front-end application file is operated, obtaining a test result generated by the test front-end application file.
In the application, after the test front-end application file is run, the script file containing the abnormal information can execute the code information corresponding to the injected abnormality when being called and executed, so that the front-end application file generates a corresponding abnormal result, namely the test result of the test front-end application file.
In the application, when the abnormity needs to be observed, the test result generated by the front-end application is tested. However, when the front-end application file is subjected to simultaneous injection of a plurality of pieces of abnormal information, the workload of the testing user is increased if each implementation scenario is manually operated because the specific implementation scenarios of the front-end application file are various. And if the implementation scenes are too many, the test user may have the situation of missing the test. Therefore, the tester can preset the instruction of the front-end application software automatic simulation implementation scene, and the operation steps of the test user are reduced. For the front-end application file with less injection abnormal information, the corresponding specific implementation scenarios of the front-end application file are less and simple, and the front-end application file can be directly tested by a tester through manual operation on the front-end page without limitation.
As can be seen from the above, in the front-end application testing method provided in this embodiment, the testing node of each front-end component is generated by identifying the component information of the front-end application file, and the script file is configured in the testing node, so that the testing user can visually observe each front-end component. And the user can conveniently acquire the application file of the test front end by injecting the abnormal information into the test node, the efficiency of injecting the abnormal information by the test user is improved, and the test result generated by the application file of the test front end when the abnormality occurs is further quickly acquired.
Referring to fig. 2, fig. 2 is a flowchart illustrating an implementation of a front-end application testing method according to another embodiment of the present application. With respect to the embodiment corresponding to fig. 1, the front-end application testing method provided in this embodiment further includes steps S201 to S202 before step S102, where step S101 and steps S201 to S202 are executed in no order. The details are as follows:
s201, acquiring a chaos tool, and storing the chaos tool in an installation directory of the front-end application file.
In application, the chaos engineering observes how a software system reacts by a random fault injection method, so that the fragile side of the software system is known, and a series of measures are taken to improve the toughness of the software system to resist unknown risks before the test user is not influenced. And the tool for executing the chaos engineering experiment is the chaos tool. The installation directory is a storage path of the front-end application file stored in the mobile terminal. The mobile terminal can download the chaos tool to the installation directory in an npm install mode and run through the command of npm run chaos XXX. Wherein the "npm install" command includes: npm install model # install module under item directory (install directory); npm install-gmoduleName # -g means that the module is mounted globally, specifically to which location of the disk, looking at the location of npm configprefix; npm install-save module name # -save means to install the module under the project directory and write the dependency in the dependency node of the package file; npm install-save-devmoduleName # -save-dev means that the module is installed under the project directory and the dependency is written in the devdependences node of the package file.
S202, operating the chaos tool, identifying each front-end component of the front-end application files under the installation catalog, and correspondingly generating each test node.
In application, the chaos tool has a function of traversing a front-end application file, and each front-end component is acquired according to the traversing front-end application file, so that a test node can be generated. The chaos tool is provided with an operation instruction generated by an npm run chaos XXX code, the operation instruction is input into a control interface of an application to be tested, an operating system in the terminal device can automatically call the installed chaos tool to execute an executable file configured in a package.
In this embodiment, the test nodes of each front-end component in the front-end application file are generated by downloading the chaotic tool, and the test is performed, compared with the existing system test corresponding to the front-end application file, the test is only embodied at the server of the front-end application system, and this embodiment has higher purposiveness and higher test efficiency, and can obtain a stable system corresponding to the front-end application file for the test user more quickly.
In an embodiment, after S102, the method further includes:
and acquiring the dependency relationship between each test node generated in sequence according to the position information of each front-end component.
And correspondingly generating a test node tree for each test node according to the dependency relationship among the test nodes.
In an application, the dependency relationship may be a parallel dependency relationship when a plurality of front end components save the same folder, and a parent-child dependency relationship when one front end component corresponds to a folder that includes the other front end components, and the like, which is not limited herein.
For example, for the B front-end component, the C front-end component, and the D front-end component of the front-end application component under the a installation directory, if the B1 folder under the a installation directory contains the B front-end component and the C1 folder contains the C front-end component, the D front-end component is at the same installation node as the B1 folder and the C1 folder. The chaotic tool identifies the installation nodes corresponding to the front-end components and generates a test node tree, namely the root node of the test node tree is an A installation directory, the next-layer test nodes are B1 test nodes formed by all front-end components contained in a B1 folder, C1 test nodes formed by all front-end components contained in a C folder and D nodes formed by D front-end components, the next layer of the B1 test nodes is B test nodes corresponding to the B front-end components, and the next layer of the C1 test nodes is C test nodes corresponding to the C front-end components. And script files corresponding to the test nodes can be used for injecting script information.
In application, the chaos tool can also identify all front-end components and interdependencies in each folder by scanning all folders containing front-end components under the A installation directory through keyword matching and semantic analysis. And then, assembling all front-end components back and forth according to the dependency relationship to form a complete test node tree. If a suspected front-end component row containing a certain keyword is found in an A installation directory by matching the keyword, such as an import or community keyword, then a participle according to terms is input to the front-end component row, such as an I love applet, which can be divided into 3 words, then a specific B front-end component is calculated according to keyword matching and semantic analysis, and finally if a real B front-end component is found in the front-end component directory or other related paths, a dependency relationship exists between the A test node and the B test node corresponding to the B front-end component, and so on, and the A is taken as a test node tree of a root node.
In application, after the chaos tool identifies the front-end application file to generate the test node tree, the generated test node tree can be displayed on an operation interface of the mobile terminal, so that a test user can clearly see the association among the front-end components, the front-end components can be integrally and clearly known, and which front-end component is selected for chaos at the back can be laid.
In the embodiment, the test node tree is generated by the test nodes with the dependency relationship through the position information of each front-end component recognized by the chaos tool, so that a test user can visually distinguish the interrelation among each front-end component, and the test user can conveniently inject an exception into each front-end component.
Referring to fig. 3, fig. 3 is a flowchart illustrating an implementation of a front-end application testing method according to another embodiment of the present application. With respect to the embodiment corresponding to fig. 1, the front-end application testing method provided in this embodiment further includes steps S301 to S303 in step S103. The details are as follows: the chaos tool comprises a plurality of abnormal information, and each abnormal information has a corresponding initial weight value; s103 includes:
s301, correspondingly identifying target nodes in the test node tree, wherein the target nodes are nodes correspondingly generated by a plurality of front end components under the same installation directory identified by the chaotic tool.
In application, when the test node tree is generated, the test nodes generated by a plurality of front-end components under the same folder are identified as target nodes. Specifically, referring to the B front-end component, C front-end component, and D front-end component of the front-end application component under the a installation directory in the above example, if the B1 folder under the a installation directory contains the B front-end component and the C1 folder contains the C front-end component, the D front-end component is at the same installation node as the B1 folder and the C1 folder. The test node A is used as a root node, and the B1 test node, the C1 test node and the D test node which are connected below the root node A can be considered as siblings at the second level, namely a target node. However, for the B test node and the C test node at the third level, since the previous test node is not the same, the B test node and the C test node do not belong to siblings.
S302, randomly acquiring the abnormal information according to the initial weight value in the plurality of abnormal information.
In application, the chaos tool further comprises an exception library, wherein the exception library is used for storing the exception information. The abnormal information in the abnormal library can be set by the chaos tool, or written by the test user according to the actual situation, and the written abnormal information is stored in the abnormal library so as to be called and injected into the test node at any time. The influence of each abnormal information on the front-end application corresponding to the front-end application component is different, and a test user can set an initial weight value by himself or use the initial weight value preset by the abnormal information. For the abnormal information corresponding to the initial weight value, if the initial weight value is larger, when the chaotic tool randomly selects the abnormal information to inject, the probability of the selected abnormal information is higher than that of the abnormal information with the small initial weight value. In application, the initial weight value is adopted to carry out random injection of the abnormal information, so that the subjectivity of manually injecting the abnormal information can be reduced, the front-end application component can be tested more conveniently, and a stable front-end application system used by a user can be obtained.
In other applications, the test user may also actively select or randomly select the injected test node or the front-end component corresponding to the target node according to the active selection of the abnormal information, which is not limited herein.
S303, injecting the abnormal information into a script file corresponding to the target node to obtain the test front-end application file.
In application, the target node is a parallel brother node in all the test nodes, and for the target node, when a chaos tool is used for identifying all front-end components to generate a test node tree, the target node can be subjected to special display processing. For example, the target node is highlighted, and the highlighted target node may be the target node in the same folder displayed in the same color on the web interface, and the highlighted colors corresponding to the target nodes in different folders may be different, so that the test user can observe the dependency relationship between the front-end components conveniently. For an application to be tested, if an application has 4 front-end components, the nodes are respectively an A test node, a B test node, a C test node and a D test node, wherein the B test node and the C test node are lower nodes of the A test node, the B test node and the C test node are target nodes, and the D test node is a lower node of the B test node. When injecting the abnormal information, compared with injecting the abnormal information into four test nodes to obtain four corresponding fault results, the user needs to examine 4 test nodes to determine which test node corresponds to the abnormal condition caused by the front-end component. If starting from the target node, only abnormal information needs to be injected into the test node B and the test node C, when a fault result is obtained, the abnormal information can be determined to be caused by the front-end component corresponding to the target node according to different expression forms of the abnormal information, and the test efficiency of the front-end component in the front-end application file is improved.
In this embodiment, by identifying the corresponding target node and randomly injecting the abnormal information into the target node according to the initial weight value corresponding to each piece of abnormal information, the subjectivity of manually injecting the abnormal information is reduced, and the testing of the front-end application component is facilitated.
Referring to fig. 4, fig. 4 is a flowchart illustrating an implementation of a front-end application testing method according to another embodiment of the present application. With respect to the embodiment corresponding to fig. 1, the front-end application test method provided in this embodiment further includes S401 to S404 after S104. The details are as follows:
s401, receiving a modification instruction issued by a tester according to the test result.
S402, correspondingly modifying the initial weight value of the abnormal information according to the modification instruction.
In application, the modification instruction is used for modifying the initial weight value corresponding to the abnormal information. Specifically, each piece of abnormality information in the abnormality library has a corresponding initial weight value, that is, each piece of abnormality in the abnormality information has a corresponding initial weight value. For example, the initial weight value corresponding to each anomaly may be a random number from 1 to 10, and may be a custom input for the test user. For example, the initial weight value corresponding to each anomaly is set to be 1, and when the chaos tool randomly selects the anomaly information in the anomaly library and injects the anomaly information into the test node, the probability that each anomaly information is randomly selected is consistent. After a plurality of experiments are carried out to obtain test results, the influence of the abnormality in certain abnormal information on the functions of the front-end application is found to be larger, and then a test user can issue a modification instruction to increase the probability that the abnormal information is randomly selected and injected into the test node in the subsequent experiment process.
And S403, randomly injecting the abnormal information into the script file corresponding to the target node for multiple times according to the modified initial weight value in the abnormal information.
In the application, if an initial weight value corresponding to a certain abnormal information is increased, multiple tests are required to understand the functional influence of the abnormal information on the front-end application. The initial weight value corresponding to a certain abnormal information may be increased by modifying the initial weight value 1 to 10, so that the plurality of abnormal information randomly selected each time include the abnormal information. In addition, when injecting the selected abnormal information into the target node, each test node into which the abnormal information is injected may be randomly selected, or may be a test node designated by a test user, which is not limited to this.
In application, when different abnormal information is injected into different or the same test node, the influence degree of the respective fault results on the user to be tested may be different. For example, for the abnormal information that cannot completely display the picture in the front-end application, if the front-end application is an application of order type, when the abnormal information is injected into the front-end component included in the test node displaying the food commodity interface, the front-end application is correspondingly run according to the order implementation scenario. Under normal conditions, the operation interface in the front-end application can not completely display the pushed food commodity picture at this moment, and although the use influence can be caused to the test user, the test user can also order according to the food name of the corresponding food picture. However, if the abnormal information is that the payment is unavailable, after the front-end application performs the simulated ordering, when the front-end application enters the payment interface to perform the payment, the corresponding payment function is not responded, that is, the payment function is unavailable, and then the front-end application is unavailable. Compared with abnormal information with incomplete picture display, the abnormal information with unavailable payment has deeper influence on the user.
S404, obtaining a test result generated by the front-end application when the abnormity occurs for multiple times, and modifying the script file corresponding to the target node according to the test result.
In the application, in the experimental process of testing the front-end application, for the fault result correspondingly generated by each abnormal information, the test user may continuously adjust the corresponding method of the abnormality in the abnormal information, that is, add a new execution code to the script file corresponding to the original test node to solve the abnormality, or replace the original script file with a new front-end component, which is not limited herein. Further, the front-end application has less influence on the use of the test user when the exception occurs. After the abnormal coping method is adjusted every time, the multiple test results of the front-end application in the abnormal coping method can be compared, the optimal fault solution is selected, purposiveness is achieved, the efficiency is high, and the stable front-end application for the user to be detected can be obtained quickly.
In this embodiment, the initial weight value of the abnormal information is adjusted through multiple experiments, so that the abnormal information having the greatest influence on the front-end application can be selected multiple times, and is randomly injected into the test node, different influences of the abnormal information on the front-end application are observed, and then the script file corresponding to the test node is modified according to multiple test results, so as to obtain the stable front-end application.
In one embodiment, the exception information includes an exception, an exception capture function, and an exception injection function; before S104, the front-end application testing party provided by this embodiment further includes:
and receiving an injection instruction, wherein the injection instruction is used for injecting the abnormity and the abnormity capture function into a script file corresponding to the target node according to an abnormity injection function in the abnormity information, and generating the test front-end application file.
In application, the injection instruction is used for injecting the exception information into the target node. Specifically, the method for injecting the exception into the script file in the test node may be: and selecting a test node to be tested (or randomly selecting by a chaotic tool) in a front-end page of the visual test node. The chaos tool randomly selects an abnormal message (comprising an abnormality, an abnormal injection function and a corresponding abnormal capture response) from the abnormal library, and injects the abnormality and the abnormal capture function into the script file according to the abnormal injection function. The original script file, the code corresponding to the exception and the code corresponding to the exception capture function can be packaged into a new front-end component, and the front-end application file containing the new front-end component is the test front-end application file. For a C test node including a C front-end component, the C front-end component may be packaged, and a high-level component C is finally obtained through a series of processes (for example, adding additional code to the execution code of the original C front-end component). The high-order component C comprises the working capacity of the original front-end component C and the capacity of newly added execution codes, wherein the capacity of the newly added execution codes comprises an exception capture function.
And running the test front-end application file, and capturing the script file corresponding to the abnormity according to the abnormity capturing function when the abnormity occurs.
In an application, the exception capture function may be to capture a javaScript exception by using a try. Through the design of the code, when the injection exception is that the execution of the javaScript has an error, a test user can quickly locate the error code and the execution context. The exception information may also include an exception response mode. For example, for a running test front-end application file, when an injected exception occurs, the exception capture function may respond to and capture the currently injected exception, and then remind the test user XXX component that an X exception has occurred in an injected exception response mode. For example, each high-level component may have its own capture function (the try.. catch.. code block described above) that can locate which high-level component (test node that injected the exception) is specifically the exception.
In this embodiment, the exception and the exception capture function are injected into the corresponding test node through the exception injection function in the exception information, and when a plurality of exceptions are injected into different test nodes, a test user can conveniently and quickly determine the current fault result according to the exception capture function, which test node injected with the exception information generates the current fault result, and then the script file of the test node is processed.
In an embodiment, after S104, the front-end application testing method provided in this embodiment further includes:
and stopping running the test front-end application file.
In the application, when the test front-end application file is tested, the test front-end application file generates a fault result due to the injection of abnormal information, and in order to prevent the test front-end application file from being crashed due to the current fault result when the test front-end application file continues to run, the subsequent test step cannot be performed. The test front-end application file can be stopped from running when the fault result of the test front-end application file is obtained.
And acquiring a preset processing scheme, and solving the test result according to the processing scheme.
In application, the exception library may further include an exception handling function, and when an exception occurs, the exception handling function preset in the exception library may be obtained according to the exception to resolve the exception. Anomalies can be further classified as predictable anomalies and unpredictable, unknown anomalies. For example, for an exception of "incomplete picture display", after injecting exception information including the exception into the test node, when the test front-end application file runs, it should display that the picture is loaded unclear or loaded abnormally, and if the text display is unclear at the same time, it indicates that an unknown exception occurs. If unknown abnormity occurs, displaying 'unknown abnormity occurrence' on the front-end page so as to test the observation of the user.
In application, a test user not only sets an exception handling function aiming at the exception of a test front-end application file in an exception library in advance, but also can process unknown exceptions in advance through framework adjustment aiming at predictable or unpredictable exceptions; or, a series of degradation schemes can be preset, so that the test front-end application file can be degraded quickly when encountering an abnormality, the collapse rate of the test front-end application file is reduced, and the emergency capacity of the test front-end application file is improved. The application software corresponding to the test front-end application file has a plurality of mature frameworks when being developed, the realization of one service requirement can adopt a plurality of frameworks, and the problem found in the chaos experiment (front-end application test) can be avoided by changing the method of the application software framework. For example, for the goods presentation application, if the front-end application has a function of presenting the goods in a short video manner, but the front-end application cannot play the short video due to an abnormality (a network signal is poor, or a plug-in playing the video of the terminal device is damaged, or the plug-in playing the video is not updated), the application may adopt a preset degradation scheme, for example, a preset goods picture is presented, so that the emergency capability of the front-end application is improved, and further, the front-end experience and the user satisfaction of the user after the test are improved. Or, the picture in the front-end application often has loading abnormality, which causes the picture to be unable to be displayed, the reason for the picture loading abnormality is more prone to the picture pixel being too high, and the set abnormality handling function may be to upload the picture again after background compression.
And after the test result is solved, uploading the test result to a block chain, and continuously running the test front-end application file.
In application, after the abnormity is solved and the test front-end application file cannot crash during operation, the test front-end application file can be continuously operated, and the fault result generated when other abnormity occurs can be continuously obtained. In addition, in all embodiments of the present application, a corresponding front-end application test scheme is obtained based on the chaos tool, and specifically, the front-end application test scheme is obtained by processing with the chaos tool. Uploading the front-end application test scheme to the blockchain can ensure the safety and the fair transparency to the user. The user equipment may download the front-end application test scheme from the blockchain to verify whether the front-end application test scheme is tampered. The blockchain referred to in this example is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Referring to fig. 5, fig. 5 is a block diagram of a front-end application testing apparatus according to an embodiment of the present disclosure. The units included in the mobile terminal in this embodiment are configured to execute the steps in the embodiments corresponding to fig. 1 to 4. Please refer to fig. 1 to 4 and fig. 1 to 4 for the corresponding embodiments. For convenience of explanation, only the portions related to the present embodiment are shown. Referring to fig. 5, the front-end application test apparatus 100 includes: an identification module 10, a first generation module 20, a first injection module 30 and a first acquisition module 40, wherein:
the identification module 10 is used for identifying the component information of each front-end component in the front-end application file; the component information comprises position information of the front-end component and a script file, and the position information is a storage path stored by the front-end component under the front-end application file.
The first generating module 20 is configured to generate a test node corresponding to each front-end component according to the location information of each front-end component, and configure the script file to the test node.
The first injection module 30 is configured to inject exception information into the script file on each test node to obtain a test front-end application file.
The first obtaining module 40 is configured to obtain, when the test front-end application file is run and an exception occurs in the exception information, a test result generated by the test front-end application file.
As an embodiment of the present application, the front-end application testing apparatus 100 further includes:
and the second acquisition module is used for acquiring the chaotic tool and storing the chaotic tool into the installation catalog of the front-end application file.
The first operation module is used for operating the chaotic tool, identifying each front-end component of the front-end application file under the installation directory, and correspondingly generating each test node.
As an embodiment of the present application, the front-end application testing apparatus 100 further includes:
and the third acquisition module is used for acquiring the dependency relationship between each test node generated in sequence according to the position information of each front-end component.
And the second generation module is used for correspondingly generating a test node tree for each test node according to the dependency relationship among the test nodes.
According to an embodiment of the application, the chaos tool comprises a plurality of abnormal information, and each abnormal information has a corresponding initial weight value; the first injection module 30 is also configured to:
correspondingly identifying target nodes in the test node tree, wherein the target nodes are nodes correspondingly generated by a plurality of front end components under the same installation directory identified by the chaotic tool;
randomly acquiring the abnormal information according to the initial weight value in the plurality of abnormal information;
and injecting the abnormal information into a script file corresponding to the target node to obtain the test front-end application file.
As an embodiment of the present application, the front-end application testing apparatus 100 further includes:
and the first receiving module is used for receiving a modification instruction issued by a tester according to the test result.
And the modifying module is used for correspondingly modifying the initial weight value of the abnormal information according to the modifying instruction.
And the second injection module is used for injecting the abnormal information into the script file corresponding to the target node for multiple times according to the modified initial weight value in the plurality of abnormal information randomly.
And the fourth acquisition module is used for acquiring a test result generated by the front-end application when the abnormality occurs for multiple times, and modifying the script file corresponding to the target node according to the test result.
As an embodiment of the present application, the exception information includes an exception, an exception capture function, and an exception injection function; the front-end application test apparatus 100 further includes:
and the second receiving module is used for receiving an injection instruction, and the injection instruction is used for injecting the abnormity and the abnormity capturing function into a script file corresponding to the target node according to an abnormity injection function in the abnormity information to generate the test front-end application file.
And the second running module is used for running the test front-end application file and capturing the script file corresponding to the abnormity according to the abnormity capturing function when the abnormity occurs.
As an embodiment of the present application, the front-end application testing apparatus 100 further includes:
and the stopping module is used for stopping running the test front-end application file.
And the processing module is used for acquiring a preset processing scheme and solving the test result according to the processing scheme.
And the third running module is used for uploading the test result to the block chain after the test result is solved, and continuously running the test front-end application file.
It should be understood that, in the structural block diagram of the front-end application testing apparatus shown in fig. 5, each unit/module is used to execute each step in the embodiment corresponding to fig. 1 to 4, and each step in the embodiment corresponding to fig. 1 to 4 has been explained in detail in the above embodiment, specifically please refer to the relevant description in the embodiment corresponding to fig. 1 to 4 and fig. 1 to 4, which is not repeated herein.
Fig. 6 is a block diagram of a terminal device according to another embodiment of the present application. As shown in fig. 6, the terminal device 60 of this embodiment includes: a processor 61, a memory 62 and a computer program 63, such as a program of the … … method, stored in said memory 62 and executable on said processor 61. The processor 61 implements the steps in the various embodiments of the methods … … described above, such as S101 to S104 shown in fig. 1, or S201 to S202, S301 to S303, and S401 to S404 shown in fig. 2, 3, and 4, when executing the computer program 63. Alternatively, when the processor 61 executes the computer program 63, the functions of the modules/units in the embodiment corresponding to fig. 5, for example, the functions of the modules 10 to 40 shown in fig. 5, are implemented, for which reference is specifically made to the related description in the embodiment corresponding to fig. 5, which is not repeated herein.
Illustratively, the computer program 63 may be divided into one or more units, which are stored in the memory 62 and executed by the processor 61 to accomplish the present application. The one or more units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 63 in the terminal device 60. For example, the computer program 63 may be divided into a first acquisition unit, a first determination unit, a first adjustment unit, a second adjustment unit, and an execution unit, each unit functioning specifically as described above.
The turntable device may include, but is not limited to, a processor 61, a memory 62. Those skilled in the art will appreciate that fig. 6 is merely an example of a terminal device 60 and does not constitute a limitation of terminal device 60 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the turntable device may also include input-output devices, network access devices, buses, etc.
The Processor 61 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 62 may be an internal storage unit of the terminal device 60, such as a hard disk or a memory of the terminal device 60. The memory 62 may also be an external storage device of the terminal device 60, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 60. Further, the memory 62 may also include both an internal storage unit and an external storage device of the terminal device 60. The memory 62 is used for storing computer programs and other programs and data required by the turntable device. The memory 62 may also be used to temporarily store data that has been output or is to be output.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A front-end application testing method, the method comprising:
identifying component information for each front-end component in the front-end application file; the component information comprises position information of the front-end component and a script file, and the position information is a storage path stored by the front-end component under the front-end application file;
generating a test node corresponding to each front-end component according to the position information of each front-end component, and configuring the script file to the test node;
injecting abnormal information into the script file on each test node to obtain a test front-end application file;
and when the test front-end application file is operated, obtaining a test result generated by the test front-end application file.
2. The front-end application testing method according to claim 1, before generating the test node corresponding to each front-end component according to the location information of each front-end component, further comprising:
acquiring a chaos tool and storing the chaos tool into an installation directory of the front-end application file;
and operating the chaotic tool, identifying each front-end component of the front-end application file under the installation catalog, and correspondingly generating each test node.
3. The front-end application testing method according to claim 2, after generating the test node corresponding to each front-end component according to the location information of each front-end component, further comprising:
acquiring the dependency relationship between each test node generated in sequence according to the position information of each front-end component;
and correspondingly generating a test node tree for each test node according to the dependency relationship among the test nodes.
4. The front-end application testing method of claim 2 or 3, wherein the chaotic tool comprises a plurality of abnormal information, each abnormal information having a corresponding initial weight value;
the injecting abnormal information into the script file on each test node to obtain a test front-end application file includes:
correspondingly identifying target nodes in the test node tree, wherein the target nodes are nodes correspondingly generated by a plurality of front end components under the same installation directory identified by the chaotic tool;
randomly acquiring the abnormal information according to the initial weight value in the plurality of abnormal information;
and injecting the abnormal information into a script file corresponding to the target node to obtain the test front-end application file.
5. The front-end application testing method according to claim 4, after obtaining the test result generated by the test front-end application file when the test front-end application file is run, further comprising:
receiving a modification instruction issued by a tester according to the test result;
correspondingly modifying the initial weight value of the abnormal information according to the modification instruction;
in the plurality of abnormal information, randomly injecting the abnormal information into the script file corresponding to the target node for a plurality of times according to the modified initial weight value;
and acquiring a test result generated by the front-end application when the abnormity occurs for multiple times, and modifying the script file corresponding to the target node according to the test result.
6. The front-end application testing method of claim 4, wherein the exception information comprises an exception, an exception capture function, and an exception injection function;
before the obtaining of the test result generated by the test front-end application file when the test front-end application file is run, the method further includes:
receiving an injection instruction, wherein the injection instruction is used for injecting the abnormity and the abnormity capture function into a script file corresponding to the target node according to an abnormity injection function in the abnormity information to generate the test front-end application file;
and running the test front-end application file, and capturing the script file corresponding to the abnormity according to the abnormity capturing function when the abnormity occurs.
7. The front-end application testing method according to claim 6, after obtaining the test result generated by the test front-end application file when the test front-end application file is run, comprising:
stopping running the test front-end application file;
acquiring a preset processing scheme, and solving the test result according to the processing scheme;
and after the test result is solved, uploading the test result to a block chain, and continuously running the test front-end application file.
8. A front-end application testing apparatus, comprising:
the identification module is used for identifying the component information of each front-end component in the front-end application file; the component information comprises position information of the front-end component and a script file, and the position information is a storage path stored by the front-end component under the front-end application file;
the first generation module is used for generating a test node corresponding to each front-end component according to the position information of each front-end component and configuring the script file to the test node;
the first injection module is used for injecting abnormal information into the script file on each test node to obtain a test front-end application file;
the first obtaining module is used for obtaining a test result generated by the test front-end application file when the test front-end application file is operated.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202010727853.0A 2020-07-23 2020-07-23 Front-end application testing method and device, terminal equipment and storage medium Pending CN111881041A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010727853.0A CN111881041A (en) 2020-07-23 2020-07-23 Front-end application testing method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010727853.0A CN111881041A (en) 2020-07-23 2020-07-23 Front-end application testing method and device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111881041A true CN111881041A (en) 2020-11-03

Family

ID=73200658

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010727853.0A Pending CN111881041A (en) 2020-07-23 2020-07-23 Front-end application testing method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111881041A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113127345A (en) * 2021-04-06 2021-07-16 北京字跳网络技术有限公司 Application testing method and device, electronic equipment and storage medium
CN113703995A (en) * 2021-08-13 2021-11-26 深圳市中博科创信息技术有限公司 Front-end and back-end data interaction method and device, electronic equipment and storage medium
CN116339899A (en) * 2023-05-29 2023-06-27 内江师范学院 Desktop icon management method and device based on artificial intelligence

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113127345A (en) * 2021-04-06 2021-07-16 北京字跳网络技术有限公司 Application testing method and device, electronic equipment and storage medium
CN113703995A (en) * 2021-08-13 2021-11-26 深圳市中博科创信息技术有限公司 Front-end and back-end data interaction method and device, electronic equipment and storage medium
CN113703995B (en) * 2021-08-13 2024-04-16 深圳市中博科创信息技术有限公司 Front-end and back-end data interaction method and device, electronic equipment and storage medium
CN116339899A (en) * 2023-05-29 2023-06-27 内江师范学院 Desktop icon management method and device based on artificial intelligence
CN116339899B (en) * 2023-05-29 2023-08-01 内江师范学院 Desktop icon management method and device based on artificial intelligence

Similar Documents

Publication Publication Date Title
CN111881041A (en) Front-end application testing method and device, terminal equipment and storage medium
US10621068B2 (en) Software code debugger for quick detection of error root causes
US9256517B1 (en) Display of aggregated stack traces in a source code viewer
CN106339312B (en) API test method and system
US9983979B1 (en) Optimized dynamic matrixing of software environments for application test and analysis
CN111309620B (en) Game protocol testing method and device, electronic equipment and storage medium
CN111026670B (en) Test case generation method, test case generation device and storage medium
CN112187933B (en) Method and system for monitoring services in multi-architecture cloud platform
CN105159832A (en) Method, apparatus and system for collecting application exception information in application test
CN110704297A (en) Code evaluation method and device, computer equipment and storage medium
CN115422063A (en) Low-code interface automation system, electronic equipment and storage medium
US20110016454A1 (en) Method and system for testing an order management system
CN113434396A (en) Interface test method, device, equipment, storage medium and program product
EP3734460B1 (en) Probabilistic software testing via dynamic graphs
CN111694550A (en) Page display control method, device and system
CN111913878A (en) Program analysis result-based bytecode instrumentation method, device and storage medium
CN103544271B (en) Load Image in a kind of browser the method and apparatus for processing window
CN105224457A (en) A kind of test frame implementation method and device
CN110928777A (en) Test case processing method, device, equipment and storage medium
CN113778878A (en) Interface testing method and device, electronic equipment and storage medium
CN113220584A (en) Page testing method and device, computer equipment and readable storage medium
CN107291614B (en) File abnormity detection method and electronic equipment
CN115859280A (en) Memory horse detection method, device, equipment and storage medium
CN111427623B (en) Program exit method, device, computer equipment and storage medium
CN112835803B (en) Tool generation method, test data construction method, device, equipment and medium

Legal Events

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