CN118170640A - Web application automatic test method based on model keyword driving - Google Patents

Web application automatic test method based on model keyword driving Download PDF

Info

Publication number
CN118170640A
CN118170640A CN202410094493.3A CN202410094493A CN118170640A CN 118170640 A CN118170640 A CN 118170640A CN 202410094493 A CN202410094493 A CN 202410094493A CN 118170640 A CN118170640 A CN 118170640A
Authority
CN
China
Prior art keywords
test
model
data
service
test 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
CN202410094493.3A
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.)
COMPUTER APPLICATION RESEARCH INST CHINA ACADEMY OF ENGINEERING PHYSICS
Original Assignee
COMPUTER APPLICATION RESEARCH INST CHINA ACADEMY OF ENGINEERING PHYSICS
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 COMPUTER APPLICATION RESEARCH INST CHINA ACADEMY OF ENGINEERING PHYSICS filed Critical COMPUTER APPLICATION RESEARCH INST CHINA ACADEMY OF ENGINEERING PHYSICS
Priority to CN202410094493.3A priority Critical patent/CN118170640A/en
Publication of CN118170640A publication Critical patent/CN118170640A/en
Pending legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the technical field of automatic testing of web applications, in particular to a web application automatic testing method based on model keyword driving, which comprises the following steps: firstly, analyzing the business requirements of a tested web application, and establishing a business state model and a data state model of a tested system; keywords are designed according to service requirements and bound with a service model; according to the test requirements, a requirement model is established and is associated with a business state model and a data state model; and respectively generating service test cases and data test cases according to the configured test case generation strategy. According to the method, the tested web application is modeled through the state diagram, the model is driven to automatically execute the test and analyze the result through the keyword mode, the method can well maintain the related knowledge in the test process, a new test environment can be built for test items with frequent requirement change and more bug, and the test efficiency is effectively improved.

Description

Web application automatic test method based on model keyword driving
Technical Field
The invention relates to the technical field of automatic testing of web applications, in particular to a web application automatic testing method based on model keyword driving.
Background
Along with the wide application of Web application in the current society, the effective guarantee of quality and reliability thereof also becomes extremely important. Software testing is an important means for improving the quality and reliability of software, and in spite of the increasing complexity of web applications, in order to adapt to the increasingly serious business competition, software developers have to reduce the testing time of software to accelerate the marketing process, so that the quality, safety and reliability of the software are difficult to ensure. In addition, the continuous optimization and bug repair of functions, performances, architecture and the like of the web application enable software to be in a dynamic evolution process, so that the test requirements change frequently, and the cost of test case execution, management and maintenance related to automatic test is high. Accordingly, there is an increasing need for web application development for automated test tools and efficient software testing methods.
According to the web application automatic test method based on model keyword driving, the tested software test requirements are modeled, the test case set meeting the test requirements can be automatically generated based on the case generation algorithm, and the test can be automatically executed, so that the automatic test of complex software is realized, and meanwhile, the test efficiency is greatly improved through the automatic test for 7×24 hours; on the other hand, through a keyword-model driving mode, related knowledge in the test process can be well maintained, and a new test environment can be quickly constructed for test items with frequent requirement change and more bug.
Disclosure of Invention
The invention aims to provide an automatic web application testing method based on model keyword driving, so as to solve the problems in the background technology.
In order to achieve the above purpose, the present invention provides the following technical solutions:
a web application automation test method based on model keyword driving comprises the following steps:
step 101, firstly analyzing the business requirement of a tested web application, and establishing a business state model and a data state model of a tested system;
102, designing keywords according to service requirements and binding the keywords with a service model;
step 103, establishing a demand model according to the test demand and associating the demand model with a business state model and a data state model;
Step 104, respectively generating a service test case and a data test case according to the configured test case generation strategy;
Step 105, combining the business test cases and the data test cases to establish a test case execution set;
And 106, automatically testing the tested system according to the test case execution set, recording the test process and the result, dynamically displaying in real time, and automatically generating a test related document according to the template.
Further, in step 101, the service state model is a modeling of a service function of the measured object, and covers a normal flow and an abnormal flow; the data state model is used for modeling data required by the tested object during working and covers normal data and abnormal data.
Further, in step 102, the keyword is an operation step of the tested object during working, such as opening a web page, logging in by a user, etc.; the binding of the keywords and the business model refers to establishing the corresponding relation between the keywords and the business model.
Further, in step 103, the requirement model is a test requirement of the tested object, and the emphasis of each round of test is determined by associating with the service state model and the data state model.
Further, in step 104, the test case generation policy is implemented by using a state diagram traversal algorithm, and one traversed path is a test case; the service test case is the operation of one flow of a user, namely a group of keyword sequences; the data test case is data used by a user in one flow operation.
Further, in step 105, the data generated by one data test case in the test execution set may be used by a plurality of service test cases, and each service test case must use the data generated by one data test case.
Further, in step 106, the automatic test, recording the test process and result, and the real-time dynamic display means that the test is sequentially executed according to the sequence of the test cases in the test case execution set, each test case forms a log file, the file content includes the execution result of the test case and the execution result of each keyword in the test case, and the statistics of the number of successful execution, failure and non-execution of the test case forms a statistical graph, and the execution result of each test case is dynamically displayed on the model graph; the automatic generation of the test related documents according to the templates means that the templates can be customized according to the needs of users, and the test records and other related documents can be automatically generated.
Compared with the prior art, the invention has the beneficial effects that:
According to the web application automatic test method based on model keyword driving, the tested web application is modeled through the state diagram, and the model is driven to automatically execute test and analyze results through the keyword mode.
Drawings
FIG. 1 is a flow chart of one embodiment of the method of the present invention;
FIG. 2 is a flow chart of one embodiment of the automatic execution of a test case set of the present invention;
FIG. 3 is a schematic diagram of a web application model under test performing a test in accordance with the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1-3, the present invention provides a technical solution:
embodiment one:
FIG. 1 is a flow chart of one embodiment of the method of the present invention, an implementation thereof, comprising the steps of:
step 101, analyzing service requirements of a tested web application, and establishing a service model and a data model, wherein the service model is used for modeling service functions of a tested object and covers a normal flow and an abnormal flow; the data state model is used for modeling data required by the tested object during working and covers normal data and abnormal data.
Further, the service model and the data model are constructed by adopting a state diagram, fig. 3 is an example of the service model and the data model, and as shown in the drawing, the primitives for constructing the service model and the data model include a start point, an end point, a state and a migration four primitives. Wherein a state diagram has and only has a start point and an end point; the state is an abstraction of software forms which can exist stably, such as a login success state, a startup success state and the like; migration is an abstraction of a process of transition between states, and some columns of actions are triggered and executed by events, such as user name, password and click login are input as events in an unregistered state, and the login process is a soft and hard action of some columns, and the transition process of migration is represented by the pointing direction of arrows between states. It should be noted that, when the data is in a state, migration is only used as a pointing function, and is established according to the requirement that different data used in the same step are placed in the same horizontal direction, if the data are in different steps, the data are expressed in the longitudinal direction, if the application website, the account name and the password belong to different steps, the data are expressed in the longitudinal direction of the state diagram, and different data of the step that different account names and passwords belong to "login" are placed in the same horizontal direction, so that the data are established. Based on the requirements, the business requirements of the tested web application are analyzed, the software state and the migration process of the tested web application are abstracted (the abstract strength can be adjusted according to the test requirements), and then the business model and the data model can be constructed.
Further, during testing, the data model is executed first to generate data required by the test case, and then user operation is simulated based on the service model to test. Therefore, in the invention, through the construction of the data model and the service model, the separation of service logic and service data is realized, and when the service logic or the service data changes, a new round of test can be carried out only by reconstructing the model. Describing the "login" action in the business model with the example of fig. 3, only how to input account name, password, and click login button need be described when designing keywords, without paying attention to specific data content; three groups of account names and passwords are given in the data model, and when the account names and passwords are changed, a new round of test can be carried out only by reconstructing the account names and the passwords in the data model.
102, Designing keywords and binding the keywords with a business model, wherein the keywords are an operation step when a tested object works, such as opening a webpage, logging in by a user and the like; the binding of the keywords and the business model refers to establishing the corresponding relation between the keywords and the business model.
Further, keywords are classified into an action class and a check class. The action class is generally triggering or inputting, and specific actions are executed, such as operations of opening a webpage, inputting account names and passwords at specified positions and the like; the check class is typically a check and validation of the result, such as whether the page is in an unregistered state.
Furthermore, in the invention, the key words are maintained independently, the key words are a step in the test cases, in general, the business logic may change frequently in the development stage of the software, the business model is basically not fixed, after the business logic or page element changes, the corresponding key words or models are maintained, so that the inheritance and flexibility of the web application automation test are improved, the method can maintain the related knowledge in the test process well, and a new test environment can be built quickly for test items with frequent requirement change and more bug, thereby effectively improving the test efficiency.
And 103, establishing a test demand model, and associating the test demand model with a business model and a data model, wherein the demand model is the test demand of the tested object, and determining the focus of each round of test through associating the test demand model with the business state model and the data state model.
Further, the demand model is used to describe the test demand of the tested object, and as shown in fig. 3, an example of the demand model is shown, the humanoid graphic primitive represents "user", and the elliptic graphic primitive represents "test demand". Wherein, the user is a user of the test requirement, and one requirement model can have a plurality of users; "test requirements" are the content of interest of "users" and can be connected with other multiple "test requirements", but only one "user" can be connected, and only the terminal "test requirements" can generate a test set. Based on the rules, a requirement model can be constructed by analyzing the test requirements of the tested object. Then selecting a 'test requirement' to be associated, if the service model is associated, associating the test key of the 'test requirement' with the related primitive in the service model, as shown in fig. 3; if the data model is associated, the data with the greatest influence on the service function is associated with the test requirement.
Step 104, generating a business test case and a data test case according to a test case generation strategy, wherein the test case generation strategy is realized by adopting a state diagram traversal algorithm, and one traversed path is a test case; the service test case is a process operation of a user, and is a group of keyword sequences in combination with step 102; the data test case is data used by a user in one flow operation.
Further, the test case generation strategy is implemented by adopting a state diagram traversal algorithm, the state diagram traversal is performed on the service model and the data model to generate the test case, and in combination with step 103, the path of the primitive associated with the demand model is preferentially generated. Taking fig. 3 as an example for illustration, for the test requirement of "login", the state diagram traversal algorithm preferentially generates a path including the primitive of "login success" in the service model, such as a path of "start- > open web page- > login success- > exit login- > not login- > close web page- > end", that is, a service test case testcase.
Further, in connection with step 102, the business test case testcase: "start- > open web- > not login- > login success- > exit login- > not login- > close web- > end", corresponds to a set of keyword sequences, namely start; open (url); unlogincheck; login (user, psw); loginSuccesscheck; logout; unlogincheck; close; and end. Likewise, data use case datacase: "start- > application website- > account name and password 1- > end", the corresponding key sequence is start; data (url=web address); data (user=account 1, psw=123456); after the execution of the data use case is completed, a data file is generated to provide data such as url, user, psw required by the execution of the service use case.
Step 105, combining the service test cases and the data test cases to establish a test execution set, wherein data generated by one data test case in the test execution set can be used by a plurality of service test cases, and each service test case must use the data generated by one data test case.
Further, in connection with step 104, each service instance must be prepared in advance for its execution, but since not every keyword requires a parameter, the data generated by the data instance may support the execution of multiple service instances. One example of a test execution set is as follows:
Execution sets
{
datacase1;
testcase1;
testcase2;
testcase3;
datacase2;
testcase4;
datacase3;
testcase5;
}
The data use cases always are in front and the service use cases are behind in the test execution set, so that the data required by the execution of the service use cases can be ensured to be acquired. It should be noted that, in order to ensure that the service instance always obtains the required data during execution, the present invention configures a default data file for storing all parameters required by the execution of the key words bound on the service model, and sets a default value for each parameter.
And 106, sending the test case set to a test terminal to automatically execute the test and recording the test result. The automatic test, the recording of test processes and results and the real-time dynamic display are performed sequentially according to the sequence of test cases in a test execution set, each test case forms a log file, the file content contains the execution results of the test cases and the execution results of each keyword in the test cases, meanwhile, the statistics of the number of successful execution, failed execution and unexecuted execution of the test cases forms a statistical graph, and the execution results of each test case are dynamically displayed on a model graph; the automatic generation of the test related documents according to the templates means that the templates can be customized according to the needs of users, and the test records and other related documents can be automatically generated.
Further, when the test case is executed, the configured browser is started and controlled through an interface provided by webdriver, data generated by the data model are read through keywords, user operation is simulated according to the sequence of the keywords in the test case and the service logic of a single keyword, and the whole test process is displayed to the user in a visual mode.
Embodiment two:
FIG. 2 is a flow chart of one embodiment of the automatic execution of a test case set of the present invention, the implementation of which includes the steps of:
step 201, establishing connection between an MBT and an SES, wherein the MBT is a server of a system and is responsible for model establishment, case generation, test case set construction and the like, and the SES is a script engine deployed at a test terminal and is responsible for communication between the test terminal and the MBT, analysis of the test case set, execution scheduling and the like. Distributed execution of the test case set may be achieved through the SES.
Step 202, the MBT sends the built test case set to the SES, and starts to execute the test case.
And 203, the SES sequentially analyzes the received test case set into a test case, and sends the analyzed keyword sequence of each test case to the test execution unit for testing.
Step 204, the test execution unit executes a use case, i.e. a group of keyword sequences, records the execution result and process of each keyword, and returns the result to the SES in real time. When all the key word execution results are correct, the test case results are correct; when any keyword execution result is wrong, the test case result is wrong.
Step 205, the SES returns the execution result of the keyword to the MBT in real time, and dynamically displays the result on the model, and generates a log script when the keyword sequence of one test case is completely executed.
And 206, after all the test case sets issued by the MBT are executed, counting the successful execution, the failure execution and the unexecuted information of the test case, and forming a statistical report in a graphical mode.
Embodiment III:
FIG. 3 is a schematic diagram of a web application model under test performing a test in accordance with the present invention. A data model and a business model are built aiming at the login function of the web application to be tested, data, such as web addresses, account names and passwords, which need to be input by user operation are defined through the data model, keywords simulating the user operation, such as opening a webpage, logging in, logging out, closing the webpage and the like, are defined through the business model, and the keywords are realized by adopting a Python script.
When the test is executed, firstly, a data model is executed, data required by the execution of the service model is generated, then, the service model is executed, a configured browser is started, and the user operation is simulated according to the key words bound by the service model, such as: starting-opening a webpage-not logging in (state detection) -logging in (inputting a user name and a password) -logging in successfully (state detection) -logging out-closing the webpage-ending, and realizing the complete operation of one test case when a user tests.
It should be noted that, for the foregoing method embodiments, for the sake of understanding, a series of actions are described as a combination, but it should be understood by those skilled in the art that the present invention is not limited by the described order of actions, and some steps may be performed simultaneously.
The web application automatic test method based on model keyword driving provided by the invention is introduced in detail, and has the advantages that the web application to be tested is modeled through the state diagram, the model is driven by keywords to automatically execute test and analyze results, the method can well maintain relevant knowledge in the test process, and a new test environment can be quickly constructed for test items with frequent requirement change and more bug, so that the test efficiency is effectively improved. In summary, the above embodiments are only for illustrating the present invention, and should not be construed as limiting the present invention.
The foregoing has shown and described the basic principles, principal features and advantages of the invention. It will be understood by those skilled in the art that the present invention is not limited to the above-described embodiments, and that the above-described embodiments and descriptions are only preferred embodiments of the present invention, and are not intended to limit the invention, and that various changes and modifications may be made therein without departing from the spirit and scope of the invention as claimed. The scope of the invention is defined by the appended claims and equivalents thereof.

Claims (7)

1. The web application automatic test method based on model keyword driving is characterized by comprising the following steps of:
step 101, firstly analyzing the business requirement of a tested web application, and establishing a business state model and a data state model of a tested system;
102, designing keywords according to service requirements and binding the keywords with a service model;
step 103, establishing a demand model according to the test demand and associating the demand model with a business state model and a data state model;
Step 104, respectively generating a service test case and a data test case according to the configured test case generation strategy;
Step 105, combining the business test cases and the data test cases to establish a test case execution set;
And 106, automatically testing the tested system according to the test case execution set, recording the test process and the result, dynamically displaying in real time, and automatically generating a test related document according to the template.
2. The model keyword-driven web application automation test method as claimed in claim 1, wherein: in the step 101, the service state model is a modeling of a service function of the measured object, and covers a normal flow and an abnormal flow; the data state model is used for modeling data required by the tested object during working and covers normal data and abnormal data.
3. The model keyword-driven web application automation test method as claimed in claim 1, wherein: in step 102, the keyword is an operation step of the tested object during working, such as opening a web page, logging in by a user, etc.; the binding of the keywords and the business model refers to establishing the corresponding relation between the keywords and the business model.
4. The model keyword-driven web application automation test method as claimed in claim 1, wherein: in step 103, the requirement model is a test requirement of the tested object, and the emphasis of each round of test is determined by associating with the business state model and the data state model.
5. The model keyword-driven web application automation test method as claimed in claim 1, wherein: in step 104, the test case generation strategy is implemented by using a state diagram traversal algorithm, and one traversed path is a test case; the service test case is the operation of one flow of a user, namely a group of keyword sequences; the data test case is data used by a user in one flow operation.
6. The model keyword-driven web application automation test method as claimed in claim 1, wherein: in step 105, the data generated by one data test case in the test execution set may be used by a plurality of service test cases, and each service test case must use the data generated by one data test case.
7. The model keyword-driven web application automation test method as claimed in claim 1, wherein: in step 106, the automatic test, recording test procedures and results, and real-time dynamic display means that the test cases are sequentially executed according to the sequence of the test cases in the test case execution set, each test case forms a log file, the file content contains the execution results of the test cases and the execution results of each keyword in the test cases, and meanwhile, statistics is performed on the number of successful execution, failure execution and unexecuted test cases to form a statistical graph, and the execution results of each test case are dynamically displayed on a model graph; the automatic generation of the test related documents according to the templates means that the templates can be customized according to the needs of users, and the test records and other related documents can be automatically generated.
CN202410094493.3A 2024-01-23 2024-01-23 Web application automatic test method based on model keyword driving Pending CN118170640A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410094493.3A CN118170640A (en) 2024-01-23 2024-01-23 Web application automatic test method based on model keyword driving

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410094493.3A CN118170640A (en) 2024-01-23 2024-01-23 Web application automatic test method based on model keyword driving

Publications (1)

Publication Number Publication Date
CN118170640A true CN118170640A (en) 2024-06-11

Family

ID=91351649

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410094493.3A Pending CN118170640A (en) 2024-01-23 2024-01-23 Web application automatic test method based on model keyword driving

Country Status (1)

Country Link
CN (1) CN118170640A (en)

Similar Documents

Publication Publication Date Title
US8001532B1 (en) System and method for generating source code-based test cases
US6301701B1 (en) Method for computer-assisted testing of software application components
AU748588B2 (en) Method for defining durable data for regression testing
US7881440B2 (en) Method for automatic graphical profiling of a system
WO2019216976A1 (en) Analytics for an automated application testing platform
Marchetto et al. A case study-based comparison of web testing techniques applied to AJAX web applications
CN111352826B (en) Automatic interface test case generation method and tool
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
Gulzar et al. Perception and practices of differential testing
Eldh et al. A framework for comparing efficiency, effectiveness and applicability of software testing techniques
Villalobos-Arias et al. Model-based testing areas, tools and challenges: A tertiary study
CN111414309A (en) Automatic test method of application program, computer equipment and storage medium
CN114297961A (en) Chip test case processing method and related device
Villalobos-Arias et al. Evaluation of a model‐based testing platform for Java applications
Schmid et al. A survey of simulation tools for requirements engineering
CN118170640A (en) Web application automatic test method based on model keyword driving
Ibrahim et al. Finite State Machine-Model Based Testing on Website Application
CN110738384B (en) Event sequence checking method and system
GB2397905A (en) Method for automatically generating and ordering test scripts
Vasconcelos Mining Web Usage to Generate Regression GUI Tests Automatically
Lin et al. Usage modeling through sequence enumeration for automated statistical testing of a GUI application
Sneed Source Animation as a means of Program Comprehension for object-oriented Systems
Rodríguez Silva et al. White-Box Testing Framework for Object-Oriented Programming based on Message Sequence Specification
Walkinshaw et al. Incrementally discovering testable specifications from program executions
Tsybin et al. Software Testing and Documenting Automation

Legal Events

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