CN111258899A - Use case generation method and device, electronic equipment and computer readable storage medium - Google Patents

Use case generation method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN111258899A
CN111258899A CN202010048545.5A CN202010048545A CN111258899A CN 111258899 A CN111258899 A CN 111258899A CN 202010048545 A CN202010048545 A CN 202010048545A CN 111258899 A CN111258899 A CN 111258899A
Authority
CN
China
Prior art keywords
page
target
event
result
use case
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
CN202010048545.5A
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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202010048545.5A priority Critical patent/CN111258899A/en
Publication of CN111258899A publication Critical patent/CN111258899A/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/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 embodiment of the invention provides a use case generation method, a use case generation device, electronic equipment and a computer readable storage medium, wherein the method comprises the following steps: determining a control corresponding to a preset coordinate in a page to be detected as a target control; executing a target event with a preset event type on the target control to obtain a result page; if the page to be tested is inconsistent with the result page, determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page; and generating a use case corresponding to the target event based on the expected result. Based on the above processing, the efficiency of use case generation can be improved.

Description

Use case generation method and device, electronic equipment and computer readable storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a use case generation method and apparatus, an electronic device, and a computer-readable storage medium.
Background
With the rapid development of mobile terminals (e.g., smart phones and tablet computers), it is also increasingly important to test pages displayed by applications in the mobile terminals. The purpose of testing the page is to ensure that the page can provide corresponding functions according to the operation of the user, and the page meets the expected requirements of developers.
In the related technology, operation paths of operations such as clicking, sliding and the like executed by a tester on a control in a page can be recorded in real time, and then a corresponding use case is generated according to the recorded operation paths. When the page needs to be tested, the use case can be run in the page, and then the test result can be obtained.
However, based on the process of generating use cases, it can be seen that when each use case is generated, a tester needs to perform corresponding operations on a control in a page, which may result in low efficiency of use case generation.
Disclosure of Invention
Embodiments of the present invention provide a use case generation method, a use case generation device, an electronic device, and a computer-readable storage medium, so as to improve the efficiency of use case generation. The specific technical scheme is as follows:
in a first aspect of the present invention, a method for generating a use case is provided, where the method includes:
determining a control corresponding to a preset coordinate in a page to be detected as a target control;
executing a target event with a preset event type on the target control to obtain a result page;
if the page to be tested is not consistent with the result page, determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page;
and generating a use case corresponding to the target event based on the expected result.
Optionally, before executing the target event of the preset event type on the target control, the method further includes:
acquiring the weight of the current target control as a first weight, wherein the first weight is used for representing the probability of executing an event on the target control;
and if the first weight is larger than a preset weight threshold value, executing a step of executing a target event of a preset event type on the target control.
Optionally, after the generating the use case corresponding to the target event, the method further includes:
calculating a difference value between the first weight and a preset value to serve as a second weight; wherein the preset value is greater than zero;
and updating the weight of the target control to the second weight.
Optionally, before the determining an expected result of the target event executed on the target control based on the difference between the page to be tested and the result page, the method further includes:
judging whether the page identification of the page to be detected is consistent with the page identification of the result page, wherein the page identification of one page is determined according to the identification of the root window of the page and the page title of the page;
and if the page identifications of the page to be detected are inconsistent with the page identifications of the result page, determining that the page to be detected is inconsistent with the result page.
Optionally, the method further includes:
if the page identification of the page to be detected is consistent with the page identification of the result page, generating a multi-branch tree corresponding to the result page as a first multi-branch tree, wherein the node in the first multi-branch tree corresponds to the control in the result page;
and if the first multi-branch tree and a second multi-branch tree corresponding to the page to be tested have different nodes, determining that the page to be tested is inconsistent with the result page.
Optionally, the determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page includes:
determining an expected result of executing the target event on the target control based on nodes in the first and second multi-way trees that are different.
Optionally, the generating a use case corresponding to the target event based on the expected result includes:
determining an interface for positioning the target control as a positioning interface, and determining an interface for executing the target event as a control interface;
generating a calling statement aiming at the target control based on the calling logic of the positioning interface and the control interface;
and generating a use case containing the calling statement and the expected result as a use case corresponding to the target event.
Optionally, before the generating the use case corresponding to the target event, the method further includes:
judging whether a use case corresponding to the target control and the expected result exists or not;
and if the target event does not exist, executing the step of generating the use case corresponding to the target event.
In a second aspect of the present invention, there is also provided a use case generation apparatus, including:
the first determining module is used for determining a control corresponding to the preset coordinate in the page to be detected as a target control;
the first processing module is used for executing a target event with a preset event type on the target control to obtain a result page;
a second determining module, configured to determine, if the page to be tested is inconsistent with the result page, an expected result of executing the target event on the target control based on a difference between the page to be tested and the result page;
and the generating module is used for generating a use case corresponding to the target event based on the expected result.
Optionally, the apparatus further comprises:
the second processing module is used for acquiring the weight of the current target control as a first weight, wherein the first weight is used for representing the probability of executing an event on the target control;
and if the first weight is larger than a preset weight threshold value, triggering the first processing module.
Optionally, the apparatus further comprises:
the updating module is used for calculating a difference value between the first weight and a preset value to serve as a second weight; wherein the preset value is greater than zero;
and updating the weight of the target control to the second weight.
Optionally, the apparatus further comprises:
the third processing module is used for judging whether the page identifier of the page to be detected is consistent with the page identifier of the result page, wherein the page identifier of one page is determined according to the identifier of the root window of the page and the page title of the page;
and if the page identifications of the page to be detected are inconsistent with the page identifications of the result page, determining that the page to be detected is inconsistent with the result page.
Optionally, the third processing module is further configured to generate a multi-way tree corresponding to the result page as a first multi-way tree if the page identifier of the page to be tested is consistent with the page identifier of the result page, where a node in the first multi-way tree corresponds to a control in the result page;
and if the first multi-branch tree and a second multi-branch tree corresponding to the page to be tested have different nodes, determining that the page to be tested is inconsistent with the result page.
Optionally, the third processing module is specifically configured to determine an expected result of executing the target event on the target control based on a node in the first multi-way tree that is different from a node in the second multi-way tree.
Optionally, the generating module is specifically configured to determine an interface for positioning the target control as a positioning interface, and determine an interface for executing the target event as a control interface;
generating a calling statement aiming at the target control based on the calling logic of the positioning interface and the control interface;
and generating a use case containing the calling statement and the expected result as a use case corresponding to the target event.
Optionally, the apparatus further comprises:
the judging module is used for judging whether a use case corresponding to the target control and the expected result exists or not;
if not, triggering the generation module.
In another aspect of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and a processor configured to implement any of the above-described use case generation methods when executing a program stored in the memory.
In another aspect of the present invention, there is also provided a computer-readable storage medium, which stores instructions that, when executed on a computer, cause the computer to execute any one of the above-mentioned use case generation methods.
In yet another aspect of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the above-described use case generation methods.
The embodiment of the invention provides a use case generation method, wherein a control corresponding to a preset coordinate is determined in a page to be tested and is used as a target control; executing a target event with a preset event type on the target control to obtain a result page; if the page to be tested is inconsistent with the result page, determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page; and generating a use case corresponding to the target event based on the expected result.
Based on the processing, the corresponding target control in the page to be tested can be determined according to the preset coordinates, the expected result of the target event is determined based on the difference between the page before and after the target event is executed on the target control, and then the corresponding use case is generated according to the expected result without the need of corresponding operation of a tester on the target control, namely, the operation of the tester can be reduced, and the efficiency of use case generation is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a flowchart of a use case generation method provided in an embodiment of the present invention;
fig. 2 is a flowchart of a use case generation method provided in an embodiment of the present invention;
fig. 3 is a flowchart of a use case generation method provided in an embodiment of the present invention;
fig. 4 is a flowchart of a use case generation method provided in an embodiment of the present invention;
fig. 5 is a flowchart of a use case generation method provided in an embodiment of the present invention;
fig. 6 is a data flow diagram provided in an embodiment of the present invention;
FIG. 7 is a flowchart of adjusting the weights of controls according to an embodiment of the present invention;
fig. 8 is a structural diagram of a use case generating apparatus provided in an embodiment of the present invention;
fig. 9 is a structural diagram of a use case generating apparatus provided in an embodiment of the present invention;
fig. 10 is a structural diagram of a use case generation apparatus provided in an embodiment of the present invention;
fig. 11 is a structural diagram of a use case generating apparatus provided in an embodiment of the present invention;
fig. 12 is a structural diagram of a use case generating apparatus provided in an embodiment of the present invention;
fig. 13 is a structural diagram of an electronic device provided in an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
In the related art, each use case is generated by requiring a tester to perform corresponding operation on a control in a page, which results in low efficiency of use case generation.
In order to solve the above problem, an embodiment of the present invention provides a use case generation method, and referring to fig. 1, the method may include the following steps:
s101: and determining a control corresponding to the preset coordinate in the page to be detected as a target control.
S102: and executing the target event with the preset event type on the target control to obtain a result page.
S103: and if the page to be tested is not consistent with the result page, determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page.
S104: and generating a use case corresponding to the target event based on the expected result.
According to the case generation method provided by the embodiment of the invention, the corresponding target control in the page to be tested can be determined according to the preset coordinates, the expected result of the target event is determined based on the difference of the page before and after the target event is executed on the target control, and then the corresponding case is generated according to the expected result without the need of corresponding operation on the target control by a tester, namely, the operation of the tester can be reduced, and the case generation efficiency is improved.
In step S101, the preset coordinates may be preset by a tester, or may be generated before the method of the embodiment of the present invention is executed.
In an implementation manner, a tester may preset a plurality of coordinates, and when a use case needs to be generated, may select one coordinate from the plurality of coordinates as a preset coordinate, and generate the use case according to the method of the embodiment of the present invention. The preset plurality of coordinates may be coordinates of a plurality of points in the page to be measured, and the plurality of points may be randomly selected points in the page to be measured.
Or when a use case needs to be generated, a coordinate can be randomly generated according to the length and the width of the page to be detected, so that a point corresponding to the generated coordinate is located in the page to be detected, and the generated coordinate can be used as a preset coordinate for generating the use case.
In an implementation manner, a multi-branch tree corresponding to a page to be tested (i.e., a second multi-branch tree in the embodiment of the present invention) may be constructed, a root node of the second multi-branch tree may represent a root window (root window) of the page to be tested, other nodes except the root node in the second multi-branch tree correspond to controls in the page to be tested one to one, and a parent-child relationship between nodes of the second multi-branch tree is consistent with an affiliated relationship of the controls in the page to be tested. The nodes of the second multi-branch tree can record attributes such as types, coordinates and visualizations of corresponding controls.
Accordingly, after the preset coordinates are obtained, the control (i.e., the target control) corresponding to the preset coordinates may be determined based on the second multi-way tree, for example, the target control corresponding to the preset coordinates may be determined from the second multi-way tree based on a responder chain search algorithm.
In addition, a storage space corresponding to the page can be constructed, the page identification of the page to be detected is used as a key, and the second multi-branch tree is used as a corresponding value to be stored.
The page identifier of the page to be tested can be represented by the page title of the page to be tested and the ID of the root window of the page to be tested.
In step S102, the preset event type may be an event type such as click, slide, or input. The event with the event type of "click" can represent that click operation is executed on the control; the event with the event type of "slide" can represent that a sliding operation is performed on the control; an event with an event type of "input" may indicate that an input operation is performed on the control.
In an implementation manner, when a use case needs to be generated, one event type may be randomly selected from a plurality of preset event types, and a corresponding event (i.e., a target event) is executed on a target control, so that a result page can be obtained.
Optionally, in order to improve the applicability of the generated use case, so that each control in the page to be tested can be tested according to the generated use case, referring to fig. 2, before step S102, the method may further include the following steps:
s105: and acquiring the weight of the current target control as a first weight.
Wherein the first weight is used to represent a probability of executing the event on the target control.
In the embodiment of the present invention, each control in the page to be tested may have an initial weight.
In an implementation manner, the initial weights of the controls may be the same, for example, the range of the weights of the controls may be [0,1], and then the initial weights of the controls in the page to be tested may be all 0.9.
Or, the initial weight of each control may be determined according to the size of each control, for example, if the probability of clicking by the user is greater for a control with a larger size, the initial weight may be set to be larger, and if the probability of clicking by the user is smaller for a corresponding control with a smaller size, the initial weight may be set to be smaller.
In addition, the weights of the controls may be adjusted during the process of generating the use case.
S106: and judging whether the first weight is larger than a preset weight threshold value, if so, executing S102, and if not, executing S107.
In the embodiment of the present invention, after the target control is determined, if the first weight of the target control is greater than the preset weight threshold, a use case corresponding to the target control may be generated, that is, step S102 is executed.
S107: the next preset coordinate is determined.
In the embodiment of the invention, if the first weight is not greater than the preset weight threshold, the use case corresponding to the target control is not generated.
Correspondingly, the next preset coordinate can be determined according to the method of the embodiment of the invention, and corresponding processing is carried out.
For example, for a control that does not receive an interaction, since there is no interaction between the control and the user, the initial weight of the control may be set to be less than a preset weight threshold, that is, a use case corresponding to the control does not need to be generated.
Optionally, in order to generate a use case corresponding to each control in the page to be tested and further improve the applicability of the generated use case, after step S104, the method may further include the following steps: calculating a difference value between the first weight and a preset value as a second weight; and updating the weight of the target control to be the second weight.
Wherein the predetermined value is greater than zero.
In the embodiment of the present invention, if the acquired controls corresponding to the preset coordinates are the same control each time a use case is generated, it may be possible that use cases corresponding to other controls cannot be generated.
Therefore, after the use case corresponding to the target event, that is, the use case corresponding to the target control is generated, the weight of the target control can be reduced, and further, the above problem can be avoided, and the applicability of the generated use case can be improved.
It can be understood that after the target event is executed on the target control, the page may jump, that is, the page to be tested and the result page are not the same page; or, the page does not jump, but the control in the page to be tested changes, which all results in inconsistency between the page to be tested and the result page.
Optionally, referring to fig. 3, before step S103, the method may further include the following steps:
s108: and judging whether the page identifications of the page to be detected and the result page are consistent, if not, executing S109, and if so, executing S110.
S109: and determining that the page to be detected is inconsistent with the result page.
S110: and generating a multi-branch tree corresponding to the result page as a first multi-branch tree, and determining that the page to be detected is inconsistent with the result page if the first multi-branch tree and a second multi-branch tree corresponding to the page to be detected have different nodes.
The page identification of one page is determined according to the identification of the root window of the page and the page title of the page. The nodes in the first multi-way tree correspond to controls in the results page.
In the embodiment of the invention, if the page identifications of the page to be detected and the result page are not consistent, the page jumps after the target event is executed on the target control, that is, the page to be detected and the result page are not consistent can be determined.
In addition, even if the page identifications of the page to be detected and the result page are consistent, if the multi-branch trees corresponding to the page to be detected and the result page have different nodes, the control of the page to be detected and the control of the result page are different, and therefore the page to be detected and the result page can be determined to be inconsistent. In this case, the recorded multi-way tree corresponding to the page identifier of the page to be tested may be updated to the first multi-way tree.
In addition, if the page identifiers of the page to be tested and the result page are consistent, and the nodes in the multi-branch trees corresponding to the page to be tested and the result page are also consistent, it is indicated that the page to be tested does not change before and after the target event is executed, and accordingly, the use case corresponding to the target event may not be generated.
Based on the processing, according to the multi-branch tree corresponding to the page, the efficiency of comparing the page can be improved, and the efficiency of generating the use case is further improved.
In step S103, an expected result of executing the target event on the target control may be determined based on the first multi-way tree corresponding to the result page and the node having a difference in the second multi-way tree corresponding to the page to be tested.
The expected result is used to verify whether the event was performed successfully when the page was tested.
Because other nodes except the root node in the multi-branch tree correspond to the controls in the page one to one, if the first multi-branch tree corresponding to the result page and the second multi-branch tree corresponding to the page to be tested have different nodes, the controls corresponding to the different nodes can represent the expected result of executing the target event on the target control.
In one implementation, the expected result may be divided into a verification mode and an expected parameter.
For example, if a page jumps after a target event is executed on a target control, nodes having a difference between the first multi-way tree and the second multi-way tree include all nodes in the first multi-way tree, that is, the page to be tested and the result page are not the same page, an expected result of executing the target event on the target control is the result page, correspondingly, a verification manner is page jump, and an expected parameter is a page identifier of the result page.
After the target event is executed on the target control, the page does not jump, but a preset number of lists are popped up and displayed in the page to be tested, the control corresponding to the node with the difference between the first multi-branch tree and the second multi-branch tree is the list, the expected result can be the preset number of lists, correspondingly, the checking mode is the number of the lists, and the expected parameter is the preset number.
After the target event is executed on the target control, the page is not jumped, but a prompt box for displaying a preset title pops up in the page to be detected, the control corresponding to the node with the difference between the first multi-branch tree and the second multi-branch tree is the prompt box, the expected result can be the prompt box for the preset title, correspondingly, the verification mode is popup box prompt, and the expected parameter is the preset title.
After the target event is executed on the target control, the page is not jumped, but preset elements are marked in the page to be detected, the control corresponding to the node with the difference in the first multi-branch tree and the second multi-branch tree is the preset element, the expected result is the preset element, correspondingly, the checking mode is whether the element exists, and the expected parameter is the mark of the preset element and a function for positioning the preset element.
After the target event is executed on the target control, the page is not jumped, but an input box is popped up and displayed in the page to be tested, the control corresponding to the node with the difference between the first multi-branch tree and the second multi-branch tree is the input box, the expected result is the input box and the preset text, correspondingly, the checking mode is the value of the input box, and the expected parameter is the preset text.
Based on the processing, the expected result is determined according to the multi-branch tree corresponding to the page, so that the efficiency of comparing the pages can be improved, and the efficiency of generating the use case can be further improved.
Alternatively, referring to fig. 4, step S104 may include the steps of:
s1041: and determining an interface for positioning the target control as a positioning interface, and determining an interface for executing the target event as a control interface.
In an embodiment of the present invention, after determining the expected result, an interface for positioning the target control (i.e., a positioning interface) and an interface for executing the target event on the target control (i.e., a manipulation interface) may be determined from the interface database.
S1042: and generating a calling statement aiming at the target control based on the calling logic of the positioning interface and the control interface, and generating a use case containing the calling statement and an expected result as a use case corresponding to the target event.
In the embodiment of the present invention, the calling functions of the positioning interface and the manipulation interface may be obtained, and corresponding parameters may be respectively transferred to the calling functions, where the transferred parameters may include an identifier of the positioning interface, an identifier of the manipulation interface, a duration of the target event, and an identifier of the target control, and the duration of the target event represents a duration for executing the target event on the target control, and further, based on the calling logic of the positioning interface and the manipulation interface, a calling statement of the calling function including the transferred parameters is generated.
Then, a use case containing the calling statement and the expected result, that is, a use case corresponding to the target event, may be generated.
In addition, the generated use case may further include an event type of the target event and an identifier of the target event.
Optionally, referring to fig. 5, the use case generation method provided in the embodiment of the present invention includes the following steps:
s501: and determining a control corresponding to the preset coordinate in the page to be detected as a target control.
S502: and executing the target event with the preset event type on the target control to obtain a result page.
S503: and if the page to be tested is not consistent with the result page, determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page.
S504: and judging whether a use case corresponding to the target control and the expected result exists or not, if not, executing S505, and if so, executing S506.
S505: and generating a use case corresponding to the target event based on the expected result.
S506: the next preset coordinate is determined.
S501 may refer to S101, S502 may refer to S102, S503 may refer to S103, and S505 may refer to S104.
In the embodiment of the invention, in order to avoid generating the same use case due to the randomness of the selection of the preset coordinates and the preset event types, after the target control and the expected result are determined, whether the corresponding use case is generated can be judged, if the corresponding use case is generated, the corresponding use case can not be generated any more, so that the generation efficiency of the use case is improved, and the execution efficiency of the subsequent use case is improved.
Referring to fig. 6, fig. 6 is a data flow diagram provided in an embodiment of the present invention.
In one implementation, a Random Event Trigger Center (RETC) may be constructed. The RETC may generate a random event, i.e., the above target event, based on the event class, and record the page identifier of the page to be detected and the corresponding multi-way tree.
The Event Class (Event Class) is defined as follows:
event Type: event type
Event Index: event numbering
Element Id: identification of control
Coordinate: coordinates of the object
Time: duration of an event
The Check Type: checking mode
And (4) Expect: desired parameter
Wherein the event type may represent an event type of the generated random event; the event number can be increased from 0 to distinguish the generated random events; the identification of the control represents a control for executing the generated random event; the coordinates can be understood as preset coordinates in the above embodiment, and can be randomly generated according to the width and height of the page to be measured; the duration of the event is used for representing the duration of the random event executed on the control; the verification means and the expected parameters are described in detail in the above embodiments.
The RETC may determine the target control according to the preset coordinates and the multi-branch tree of the page to be tested, construct a corresponding Event class, and send the Event class to an Event Handling Center (EHC). The EHC can call a frame driver, execute a corresponding event on a target control in the page to be tested, determine a checking mode and expected parameters of the event class according to the multi-branch tree under the condition that the page to be tested is inconsistent with the result page, and discard the event class under the condition that the page to be tested is consistent with the result page.
Further, the event classes that are not discarded may be stored in an event queue.
Subsequently, the event class can be taken out from the event queue according to a First Input First Output (FIFO) algorithm, a corresponding thread is created, and a case script is constructed based on the event class to generate a corresponding case.
Referring to fig. 7, fig. 7 is a flowchart of adjusting the weight of a control according to an embodiment of the present invention, where the flowchart may include the following steps: .
S701: and acquiring the multi-branch tree of the page to be detected.
S702: and acquiring the attribute of the control in the page to be tested.
The properties of the control may include coordinates, type, and visualization of the control.
S703: and judging whether the control can receive the interaction, if not, executing S704, and if so, executing S705.
Wherein if the user is allowed to click on the control, the control is able to receive the interaction, otherwise, the interaction is not able to be received.
S704: and distributing the weight smaller than the preset weight threshold value to the control.
And the distributed weight is smaller than a preset weight threshold value, which indicates that the use case corresponding to the control does not need to be generated.
S705: weights are assigned according to the control size.
S706: and adjusting the weight according to the black and white list.
The weight range of the control can be [0,1], a black and white list can be set, the weight of the control in the black list can be adjusted to 0, and the weight of the control in the white list can be adjusted to 0.9.
S707: the weights are dynamically adjusted.
And after the use case corresponding to the control is generated, reducing the weight of the control.
Based on the same inventive concept, referring to fig. 8, an embodiment of the present invention further provides a use case generating apparatus, where the apparatus includes:
a first determining module 801, configured to determine a control corresponding to a preset coordinate in a page to be tested, as a target control;
a first processing module 802, configured to execute a target event of a preset event type on the target control, so as to obtain a result page;
a second determining module 803, configured to determine, if the page to be tested is inconsistent with the result page, an expected result of executing the target event on the target control based on a difference between the page to be tested and the result page;
a generating module 804, configured to generate a use case corresponding to the target event based on the expected result.
Optionally, referring to fig. 9, the apparatus further includes:
a second processing module 805, configured to obtain a weight of the current target control as a first weight, where the first weight is used to represent a probability of executing an event on the target control;
if the first weight is greater than a preset weight threshold, the first processing module 802 is triggered.
Optionally, referring to fig. 10, the apparatus further includes:
an updating module 806, configured to calculate a difference between the first weight and a preset value as a second weight; wherein the preset value is greater than zero;
and updating the weight of the target control to the second weight.
Optionally, referring to fig. 11, the apparatus further includes:
a third processing module 807, configured to determine whether the page identifier of the page to be detected is consistent with the page identifier of the result page, where the page identifier of one page is determined according to the identifier of the root window of the page and the page title of the page;
and if the page identifications of the page to be detected are inconsistent with the page identifications of the result page, determining that the page to be detected is inconsistent with the result page.
Optionally, the third processing module 807 is further configured to generate a multi-way tree corresponding to the result page as a first multi-way tree if the page identifier of the page to be tested is consistent with the page identifier of the result page, where a node in the first multi-way tree corresponds to a control in the result page;
and if the first multi-branch tree and a second multi-branch tree corresponding to the page to be tested have different nodes, determining that the page to be tested is inconsistent with the result page.
Optionally, the third processing module 807 is specifically configured to determine an expected result of executing the target event on the target control based on a node in the first multi-way tree that is different from a node in the second multi-way tree.
Optionally, the generating module 804 is specifically configured to determine an interface for positioning the target control as a positioning interface, and determine an interface for executing the target event as a control interface;
and generating a use case corresponding to the target event based on the expected result, the positioning interface and the control interface.
Optionally, referring to fig. 12, the apparatus further includes:
a judging module 808, configured to judge whether a use case corresponding to the target control and the expected result exists;
if not, the generation module 804 is triggered.
The case generation device provided by the embodiment of the invention can determine the corresponding target control in the page to be tested according to the preset coordinates, determine the expected result of executing the target event based on the difference of the page before and after the target event is executed on the target control, and further generate the corresponding case according to the expected result without the corresponding operation of a tester on the target control, namely, the operation of the tester can be reduced, and the case generation efficiency is improved.
An embodiment of the present invention further provides an electronic device, as shown in fig. 13, including a processor 1301, a communication interface 1302, a memory 1303, and a communication bus 1304, where the processor 1301, the communication interface 1302, and the memory 1303 complete mutual communication through the communication bus 1304,
a memory 1303 for storing a computer program;
the processor 1301 is configured to implement the following steps when executing the program stored in the memory 1303:
determining a control corresponding to a preset coordinate in a page to be detected as a target control;
executing a target event with a preset event type on the target control to obtain a result page;
if the page to be tested is not consistent with the result page, determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page;
and generating a use case corresponding to the target event based on the expected result.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In another embodiment of the present invention, a computer-readable storage medium is further provided, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a computer, the computer is caused to execute the use case generation method in any one of the above embodiments.
In another embodiment of the present invention, a computer program product containing instructions is further provided, which when run on a computer, causes the computer to execute the use case generation method described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the electronic device, the computer-readable storage medium, and the computer program product embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (11)

1. A method for generating use cases, the method comprising:
determining a control corresponding to a preset coordinate in a page to be detected as a target control;
executing a target event with a preset event type on the target control to obtain a result page;
if the page to be tested is not consistent with the result page, determining an expected result of executing the target event on the target control based on the difference between the page to be tested and the result page;
and generating a use case corresponding to the target event based on the expected result.
2. The method of claim 1, wherein prior to executing a target event of a preset event type on the target control, the method further comprises:
acquiring the weight of the current target control as a first weight, wherein the first weight is used for representing the probability of executing an event on the target control;
and if the first weight is larger than a preset weight threshold value, executing a step of executing a target event of a preset event type on the target control.
3. The method according to claim 2, wherein after the generating of the use case corresponding to the target event, the method further comprises:
calculating a difference value between the first weight and a preset value to serve as a second weight; wherein the preset value is greater than zero;
and updating the weight of the target control to the second weight.
4. The method of claim 1, wherein prior to the determining an expected result of the target event being performed on the target control based on the difference between the page under test and the results page, the method further comprises:
judging whether the page identification of the page to be detected is consistent with the page identification of the result page, wherein the page identification of one page is determined according to the identification of the root window of the page and the page title of the page;
and if the page identifications of the page to be detected are inconsistent with the page identifications of the result page, determining that the page to be detected is inconsistent with the result page.
5. The method of claim 4, further comprising:
if the page identification of the page to be detected is consistent with the page identification of the result page, generating a multi-branch tree corresponding to the result page as a first multi-branch tree, wherein the node in the first multi-branch tree corresponds to the control in the result page;
and if the first multi-branch tree and a second multi-branch tree corresponding to the page to be tested have different nodes, determining that the page to be tested is inconsistent with the result page.
6. The method of claim 5, wherein determining an expected result of executing the target event on the target control based on the difference between the page under test and the results page comprises:
determining an expected result of executing the target event on the target control based on nodes in the first and second multi-way trees that are different.
7. The method of claim 1, wherein generating the use case corresponding to the target event based on the expected result comprises:
determining an interface for positioning the target control as a positioning interface, and determining an interface for executing the target event as a control interface;
generating a calling statement aiming at the target control based on the calling logic of the positioning interface and the control interface;
and generating a use case containing the calling statement and the expected result as a use case corresponding to the target event.
8. The method according to claim 1, wherein before the generating the use case corresponding to the target event, the method further comprises:
judging whether a use case corresponding to the target control and the expected result exists or not;
and if the target event does not exist, executing the step of generating the use case corresponding to the target event.
9. A use case generation apparatus, the apparatus comprising:
the first determining module is used for determining a control corresponding to the preset coordinate in the page to be detected as a target control;
the first processing module is used for executing a target event with a preset event type on the target control to obtain a result page;
a second determining module, configured to determine, if the page to be tested is inconsistent with the result page, an expected result of executing the target event on the target control based on a difference between the page to be tested and the result page;
and the generating module is used for generating a use case corresponding to the target event based on the expected result.
10. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 8 when executing a program stored in the memory.
11. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-8.
CN202010048545.5A 2020-01-16 2020-01-16 Use case generation method and device, electronic equipment and computer readable storage medium Pending CN111258899A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010048545.5A CN111258899A (en) 2020-01-16 2020-01-16 Use case generation method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010048545.5A CN111258899A (en) 2020-01-16 2020-01-16 Use case generation method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN111258899A true CN111258899A (en) 2020-06-09

Family

ID=70950715

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010048545.5A Pending CN111258899A (en) 2020-01-16 2020-01-16 Use case generation method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111258899A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020648A (en) * 2022-01-04 2022-02-08 广东拓思软件科学园有限公司 Application control testing method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130031503A1 (en) * 2007-10-15 2013-01-31 Google Inc. Analyzing a Form Page for Indexing
CN107562610A (en) * 2017-09-21 2018-01-09 上海谦问万答吧云计算科技有限公司 Obtain method, apparatus, terminal and the medium of page load time
CN110297759A (en) * 2019-05-22 2019-10-01 深圳壹账通智能科技有限公司 A kind of method, apparatus making test page script, equipment and storage medium
CN110457097A (en) * 2019-05-24 2019-11-15 平安普惠企业管理有限公司 Page response control method, device, computer equipment and storage medium
CN110516206A (en) * 2019-07-23 2019-11-29 平安科技(深圳)有限公司 File comparison method, device, computer equipment and storage medium
CN110580222A (en) * 2019-08-29 2019-12-17 清华大学 Software test case generation method and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130031503A1 (en) * 2007-10-15 2013-01-31 Google Inc. Analyzing a Form Page for Indexing
CN107562610A (en) * 2017-09-21 2018-01-09 上海谦问万答吧云计算科技有限公司 Obtain method, apparatus, terminal and the medium of page load time
CN110297759A (en) * 2019-05-22 2019-10-01 深圳壹账通智能科技有限公司 A kind of method, apparatus making test page script, equipment and storage medium
CN110457097A (en) * 2019-05-24 2019-11-15 平安普惠企业管理有限公司 Page response control method, device, computer equipment and storage medium
CN110516206A (en) * 2019-07-23 2019-11-29 平安科技(深圳)有限公司 File comparison method, device, computer equipment and storage medium
CN110580222A (en) * 2019-08-29 2019-12-17 清华大学 Software test case generation method and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114020648A (en) * 2022-01-04 2022-02-08 广东拓思软件科学园有限公司 Application control testing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109062809B (en) Online test case generation method and device and electronic equipment
US10990511B2 (en) Apparatus and application interface traversing method
US20190286657A1 (en) Object clustering method and system
CN108427731B (en) Page code processing method and device, terminal equipment and medium
CN113489713B (en) Network attack detection method, device, equipment and storage medium
CN110572409B (en) Industrial Internet security risk prediction method, device, equipment and storage medium
CN108459954B (en) Application program vulnerability detection method and device
CN107329894B (en) Application program system testing method and device and electronic equipment
CN110311902A (en) A kind of recognition methods of abnormal behaviour, device and electronic equipment
CN108008936B (en) Data processing method and device and electronic equipment
CN112799953A (en) Interface testing method and device, computer equipment and storage medium
CN115292197A (en) Software testing method and device, electronic equipment and storage medium
CN111258899A (en) Use case generation method and device, electronic equipment and computer readable storage medium
CN109976828B (en) Method and device for configuring file
CN109684213A (en) A kind of test method, device and storage medium
CN110633196A (en) Automatic use case execution method and device of application program
CN115378747A (en) Malicious data detection method, terminal device and storage medium
CN113590180A (en) Detection strategy generation method and device
CN109542300B (en) Method and device for updating web directory, electronic equipment and storage medium
CN109165127B (en) Problem interface positioning method and device and electronic equipment
CN111736848A (en) Packet conflict positioning method and device, electronic equipment and readable storage medium
CN110866253B (en) Threat analysis method and device, electronic equipment and storage medium
CN111324505B (en) Log collection method and device, electronic equipment and storage medium
CN114969759B (en) Asset security assessment method, device, terminal and medium of industrial robot system
CN114331167B (en) Method, system, medium and equipment for managing champion challenger strategy

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