CN117171052A - Script testing method, device, equipment and medium based on XML language - Google Patents

Script testing method, device, equipment and medium based on XML language Download PDF

Info

Publication number
CN117171052A
CN117171052A CN202311415689.XA CN202311415689A CN117171052A CN 117171052 A CN117171052 A CN 117171052A CN 202311415689 A CN202311415689 A CN 202311415689A CN 117171052 A CN117171052 A CN 117171052A
Authority
CN
China
Prior art keywords
test
script
code set
program
interpreter
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.)
Granted
Application number
CN202311415689.XA
Other languages
Chinese (zh)
Other versions
CN117171052B (en
Inventor
夏吉运
程隆
邱立全
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZHEJIANG HECHUAN TECHNOLOGY CO LTD
Original Assignee
ZHEJIANG HECHUAN 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 ZHEJIANG HECHUAN TECHNOLOGY CO LTD filed Critical ZHEJIANG HECHUAN TECHNOLOGY CO LTD
Priority to CN202311415689.XA priority Critical patent/CN117171052B/en
Publication of CN117171052A publication Critical patent/CN117171052A/en
Application granted granted Critical
Publication of CN117171052B publication Critical patent/CN117171052B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses a script test method, a device, equipment and a medium based on XML language, which relate to the technical field of computers and comprise the following steps: acquiring test information of an article to be tested, and generating a corresponding test script code set based on the test information and XML language rules; the test script code set is sent to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and an analyzed program is obtained; and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result. According to the application, the test script codes are written through the XML script language, so that the test code writing operation is simplified, and the development cost of the test system is reduced.

Description

Script testing method, device, equipment and medium based on XML language
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for testing a script based on XML language.
Background
In the prior art, a script execution scheme mostly adopts an open source script language scheme, such as Python (computer programming language), lua (lightweight script language), and the like. However, the open source scripting languages are complex at present, and are mainly characterized by high learning cost, and aiming at a simple testing tool, a test case writer must master such huge scripting languages as Python, etc., which increases the writing difficulty of the test case and the product development time. Secondly, the expansion difficulty is high, so that in order to improve the simplicity of the test case, a writer of the test case hopes that the script language provides specific operations, such as certain interactive operations aiming at the interface module, and the script language is required to be expanded. However, due to the syntactic semantic complexity of the open source scripting language, it is difficult to expand new syntactic semantic elements on the basis of the syntactic semantic complexity; and the complexity of the language brings the complexity of the interpreter, and the interpreter needs to be modified to add new language elements, so that the task is very difficult and difficult to control.
At present, a testing tool is developed for each product, but in many cases, derivative or similar products are required to be constructed according to the existing products, so that a product series is formed, and if each product is required to be constructed with a testing tool, the development cost is increased, and the development efficiency is reduced.
Disclosure of Invention
Therefore, the application aims to provide a script test method, a script test device, script test equipment and a script test medium based on an XML language, which can simplify test code writing operation, reduce development cost of a test system and improve development efficiency. The specific scheme is as follows:
in a first aspect, the application discloses a script testing method based on XML language, comprising the following steps:
acquiring test information of an article to be tested, and generating a corresponding test script code set based on the test information and XML language rules;
the test script code set is sent to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and an analyzed program is obtained;
and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result.
Optionally, the obtaining test information of the to-be-tested article and generating the corresponding test script code set based on the test information and the XML language rule includes:
acquiring test information of an article to be tested, and determining corresponding code writing label information in an XML language rule based on each test information; the code writing label information comprises data types, writing sentences and expression operations;
and generating the test script code set based on the code writing label information and the test information.
Optionally, the sending the test script code set to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, to obtain a parsed program, including:
transmitting the test script code set to a script interpreter, and judging whether the number of test scripts in the test script code set is greater than 1;
if the number of the test scripts in the test script code set is 1, directly entering the step of constructing an abstract syntax tree based on the script interpreter and the test script code set to obtain a resolved program;
and if the number of the test scripts in the test script code set is greater than 1, executing the abstract syntax tree constructed based on the script interpreter and the test script code set on each test script in the test script code set in sequence to obtain a resolved program.
Optionally, the sending the test script code set to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, to obtain a parsed program, including:
transmitting the test script code set to the script interpreter, and loading the test scripts in the test script code set through a reading area in the script interpreter;
analyzing and checking whether the grammar element in the test script is correct, if so, constructing the abstract grammar tree based on the code writing label information and the corresponding logic structure to obtain the analyzed program.
Optionally, after analyzing and checking whether the syntax element in the test script is correct, the method further includes:
and if the grammar element in the test script is incorrect, generating and prompting corresponding error information.
Optionally, the constructing an abstract syntax tree based on the script interpreter and the test script code set, after obtaining the parsed program, further includes:
analyzing and checking whether the semantics in the parsed program are correct;
and if the semantics in the resolved program are correct, entering the step of executing the resolved program.
Optionally, the sending the test script code set to a script interpreter, so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and before obtaining the parsed program, further includes:
and constructing the script interpreter based on the XML language rule.
In a second aspect, the present application discloses a script testing device based on XML language, comprising:
the test script code generation module is used for acquiring the test information of the to-be-tested articles and generating a corresponding test script code set based on the test information and the XML language rule;
the program acquisition module is used for sending the test script code set to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set to obtain an analyzed program;
the program execution module is used for executing the analyzed program to obtain a test result of the test script code;
and the result display module is used for sending the test result to the interaction page and displaying the test result.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the XML language based script test method as disclosed previously.
In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the XML-language-based script test method as previously disclosed.
The application provides a script testing method based on XML language, which comprises the following steps: acquiring test information of an article to be tested, and generating a corresponding test script code set based on the test information and XML language rules; the test script code set is sent to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and an analyzed program is obtained; and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result. Therefore, the application writes the test script code through the XML script language, simplifies the test code writing operation through the simple characteristic of XML semantic writing, has certain expandability, reduces the development cost of the test system when a tester can modify the test code by modifying the XML label, and improves the development efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a script test method based on XML language disclosed by the application;
FIG. 2 is a schematic diagram of an XML script execution scheme disclosed in the present application;
FIG. 3 is a flowchart of a specific XML-based script testing method disclosed in the present application;
FIG. 4 is a flowchart of a specific XML-based script testing method disclosed in the present application;
FIG. 5 is a schematic diagram of XML scripting language elements disclosed herein;
FIG. 6 is a schematic diagram of an interpreter architecture of the present disclosure;
FIG. 7 is a schematic diagram of a script testing device based on XML language provided by the application;
fig. 8 is a block diagram of an electronic device according to the present application.
Detailed Description
The following description of the embodiments of the present application 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 application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
At present, a script execution scheme mostly adopts an open source script language scheme, but the open source script language is complex at present, and the open source script language is mainly characterized in that firstly, the study cost is high, and aiming at a simple test tool, a test case writer needs to master a huge script language, so that the writing difficulty of the test case and the product development time are increased. Secondly, the expansion difficulty is high, so that in order to improve the simplicity of the test case, a writer of the test case hopes that the script language provides specific operations, such as certain interactive operations aiming at the interface module, and the script language is required to be expanded. However, due to the syntactic semantic complexity of the open source scripting language, it is difficult to expand new syntactic semantic elements on the basis of the syntactic semantic complexity; and the complexity of the language brings the complexity of the interpreter, and the interpreter needs to be modified to add new language elements, so that the task is very difficult and difficult to control. Therefore, the application provides a script test method based on XML (Extensive Markup Language, extensible markup language) language, which can simplify test code writing operation, reduce development cost of a test system and promote development efficiency.
The embodiment of the application discloses a script testing method based on XML language, which is shown in figure 1 and comprises the following steps:
step S11: and acquiring test information of the to-be-tested articles, and generating a corresponding test script code set based on the test information and the XML language rule.
In this embodiment, test information of an article to be tested is obtained, and a corresponding test script code set is generated based on the test information and an XML language rule. Specifically, test information of an article to be tested is obtained, and corresponding code writing label information in an XML language rule is determined based on each test information; the code writing label information comprises data types, writing sentences and expression operations; and generating the test script code set based on the code writing label information and the test information. It can be understood that the tester obtains the test information of the to-be-tested articles by analyzing the functions of the articles or by means of documents written by other people, and the like, and writes a corresponding test script code set based on the test information and XML language rules.
Building any product requires providing a set of functional and performance descriptions to the user, thereby enabling the user to handle and exercise the product, which is also an initial goal of building the product. Functional certainty and performance stability are core attributes of products, and testing is a guarantee means of the core attributes. The test means are various and mainly comprise a purely manual test and an automatic test depending on a test system; the current automatic test is widely used due to the high efficiency and flexibility. The application aims at developing test for specific products, extracting commonality of each test tool and abstracting the test tool, so that one test tool can be applied to test of a plurality of products.
The test system architecture of the application is shown in fig. 2, and comprises an interactive interface, a script interpreter and a test case script. The interactive interface module is mainly responsible for interaction with a tester, for example, a product to be tested is selected, the bar code of the product to be tested is scanned after authority of the tester is set, and information such as a test result, a test progress and the like is displayed on the interactive interface. The script interpreter is mainly responsible for interpreting and executing test case script code. The test case code is the test script code which is specially written for the functions and performances of each product. The method comprises the steps that common and different points exist between various models in a product series in terms of functions and performances, and a testing tool is developed for the product series by using a script-based testing system framework; and according to different products, script test case codes of specific models are rewritten, and the interaction interface and the interpreter are shared, so that the development cost of the test system is reduced.
Step S12: and sending the test script code set to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and obtaining a resolved program.
In this embodiment, after generating a corresponding test script code set based on the test information and the XML language rule, the test script code set is sent to a script interpreter, so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and obtain a parsed program. Specifically, the test script code set is sent to a script interpreter, and whether the number of test scripts in the test script code set is larger than 1 is judged; if the number of the test scripts in the test script code set is 1, directly entering the step of constructing an abstract syntax tree based on the script interpreter and the test script code set to obtain a resolved program; and if the number of the test scripts in the test script code set is greater than 1, executing the abstract syntax tree constructed based on the script interpreter and the test script code set on each test script in the test script code set in sequence to obtain a resolved program.
It will be appreciated that the test case set is a set of code files written in XML scripting language, i.e. there may be one test script or a plurality of test scripts in the set. If a plurality of test scripts exist, the test scripts are sequentially executed according to logic in the test information of the articles to be tested.
Step S13: and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result.
In this embodiment, the set of test script codes is sent to a script interpreter, so that an abstract syntax tree is constructed based on the script interpreter and the set of test script codes, after an parsed program is obtained, the parsed program is executed, so as to obtain a test result of the test script codes, and the test result is sent to an interaction page and displayed.
The application uses a script programming language in XML format, as shown in figure 3, the language comprises basic variable definition, basic sentences such as if/for/while/switch/goto/expr, and programming elements such as function definition; the application uses an interpreter for XML script language, the interpreter reads script files and interprets codes in the execution script; the application is constructed based on XML, so that the script language is easy to expand and learn, and the interpreter is easy to realize, thereby reducing the development difficulty of the test system, improving the efficiency of writing test cases by testers, and expanding the applicable tested objects of the system.
The application provides a script testing method based on XML language, which comprises the following steps: acquiring test information of an article to be tested, and generating a corresponding test script code set based on the test information and XML language rules; the test script code set is sent to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and an analyzed program is obtained; and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result. Therefore, the application writes the test script code through the XML script language, simplifies the test code writing operation through the simple characteristic of XML semantic writing, has certain expandability, reduces the development cost of the test system when a tester can modify the test code by modifying the XML label, and improves the development efficiency.
Referring to fig. 4, the embodiment of the application discloses a script testing method based on XML language, and compared with the previous embodiment, the embodiment further describes and optimizes the technical scheme.
Step S21: and acquiring test information of the to-be-tested articles, and generating a corresponding test script code set based on the test information and the XML language rule.
In this embodiment, the program is data and data manipulation, as shown in fig. 5, based on the design of the XML-based scripting language. Data, i.e., variables or constants, data types include bool (boolean type is used as a logical judgment), int (integer type), string (string type). Operations on data include expressions, statements, and functions; specifically, the sentences include sentences such as if, for, while, expr (arithmetic expression); expression operations include arithmetic operations, comparison operations, bit operations, logical operations, function calls; user-defined function functions are provided. Because of the scripting language built on the basis of XML, the variable definitions, sentences and function definitions must be given in the form of XML tags.
Step S22: and constructing the script interpreter based on the XML language rule.
In this embodiment, when the script interpreter is constructed, the same rule as that used for generating the corresponding test script code set is used for constructing, that is, the XML language rule is used for constructing the script interpreter. XML is simple and easy to learn, so that a script writer can learn and write test cases easily; the structuring of XML makes script interpretation and development very easy, it is easy to construct abstract syntax tree, and the extensibility of XML makes language easy to expand, and new language elements are easy to be added by adding new tags.
Step S23: and sending the test script code set to the script interpreter, and loading the test scripts in the test script code set through a reading area in the script interpreter.
In this embodiment, after the script interpreter is constructed based on the XML language rule, the test script code set is sent to the script interpreter, and the test script in the test script code set is loaded through a reading area in the script interpreter. It will be appreciated that since the scripting language is XML-based, the test script is loaded first using an open-source XML reading module.
Step S24: analyzing and checking whether the grammar element in the test script is correct, if so, constructing the abstract grammar tree based on the code writing label information and the corresponding logic structure to obtain the analyzed program.
In this embodiment, after loading the test script in the test script code set through a read area in the script interpreter, analyzing and checking whether a syntax element in the test script is correct, if the syntax element in the test script is correct, constructing the abstract syntax tree based on the code writing tag information and a corresponding logic structure, and obtaining the parsed program. Specifically, if the syntax element in the test script is incorrect, corresponding error information is generated and prompted. Further, analyzing and checking whether the semantics in the parsed program are correct; and if the semantics in the resolved program are correct, entering the step of executing the resolved program.
It will be appreciated that, as shown in fig. 6, the related syntax elements in the XML are analyzed to determine whether the writing format of the code is wrong, if the syntax elements pass the inspection, an abstract syntax tree is constructed, then the semantics are analyzed and inspected to determine whether the code has a semantic error, and if the code has no semantic error, the program is executed. The structuring of XML allows the XML to be loaded and then its tags directly parsed, thereby quickly building an abstract syntax tree.
The application makes it easy to write test case script by using the simple and easy-to-learn feature of XML, makes it easy to add new language element by using the extensible feature of XML, and makes script interpreter development simple by using the structuring feature of XML.
For example script semantic sample code (note: the content in: - - - - - - - >) is annotated):
< | - - -defines an int type variable named comWriteM 2010- - >
<var name= "comWriteM2010" type= "int" />
< | - - -defines an int type variable named readM 2010- - >
<var name= "readM2010" type="int" />
< -
< call > testapi.writeProducLog ("test $ { pTips } USB communication", product_sn) </call >)
The < |— invoking the testapi, hcapi_comwritebytes function reads the register value in the product → -
<call>comWriteM2010= TestApi. HcApi_ComWriteBytes (2,77,4020, 2, 21930)</ call>
<if cond= "comNriteM2010 == 0">
< call > testApi. WriteProductLog ("USB write 0x55AA successful to $ { pTips } device mw 2010", product_sn) </call >
<call>currentTime1 = testApi.GetCurTime ()</ call>
<for init= "timel=currentTime1" cond= "time2<= 2000" incr= "time2 = currentTime2-currentTime1">
<call>readM2010 = testApi. HcApi_ComReadBytes (errorCode,2, 77, 4020, 2)</ call>
<call>currentTime2 = testApi. GetCurTime ()</ call>
<call>errorCodeIsEmpty. TestApi. CheckStrIsEmpty (errorCode)</ call>
<if cond="errorCodeIsEmpty ==true">
<Break></ break>
</ if>
</ for>
<call>errorCodeIsEmpty = testApi. CheckStrIsEmpty(errorCode)</ call>
<if cond= "errorCodeIsEmpty == false">
< expr > testSysErrorstr= "USB read device M2010" + error code </expr >
<goto>test_sys_error</ goto>
</ if>
<if cond= "readM2010! = 21930">
< expr > testSysErrorStr= "USB read $ { pTips } M2010 device failure" </expr >
<goto>test_ sys_ error</ goto>
</ if>
Step S25: and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result.
For the specific content of the step S25, reference may be made to the corresponding content disclosed in the foregoing embodiment, and no detailed description is given here.
Therefore, the embodiment of the application generates the corresponding test script code set by acquiring the test information of the to-be-tested articles and based on the test information and the XML language rule; constructing the script interpreter based on the XML language rule; transmitting the test script code set to the script interpreter, and loading the test scripts in the test script code set through a reading area in the script interpreter; analyzing and checking whether the grammar element in the test script is correct, if so, constructing the abstract grammar tree based on the code writing tag information and the corresponding logic structure to obtain a resolved program; and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page for display, so that the writing operation of the test code is simplified, the development cost of a test system is reduced, and the development efficiency is improved.
Referring to fig. 7, the embodiment of the application also correspondingly discloses a script testing device based on XML language, which comprises:
the test script code generation module 11 is used for acquiring the test information of the articles to be tested and generating a corresponding test script code set based on the test information and XML language rules;
a program acquisition module 12, configured to send the test script code set to a script interpreter, so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and obtain an parsed program;
a program execution module 13, configured to execute the parsed program to obtain a test result of the test script code;
and the result display module 14 is used for sending the test result to the interaction page and displaying the test result.
It can be seen that the present application includes: acquiring test information of an article to be tested, and generating a corresponding test script code set based on the test information and XML language rules; the test script code set is sent to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and an analyzed program is obtained; and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result. Therefore, the application writes the test script code through the XML script language, simplifies the test code writing operation through the simple characteristic of XML semantic writing, has certain expandability, reduces the development cost of the test system when a tester can modify the test code by modifying the XML label, and improves the development efficiency.
In some specific embodiments, the test script code generating module 11 specifically includes:
the test information acquisition unit is used for acquiring the test information of the articles to be tested;
the tag information determining unit is used for determining corresponding code writing tag information in the XML language rule based on each piece of test information; the code writing label information comprises data types, writing sentences and expression operations;
and the code generating unit is used for generating the test script code set based on the code writing label information and the test information.
In some embodiments, before the program obtaining module 12, the method specifically further includes:
and the script interpreter construction unit is used for constructing the script interpreter based on the XML language rule.
In some embodiments, the program acquisition module 12 specifically includes:
the test script quantity judging unit is used for sending the test script code set to a script interpreter and judging whether the quantity of the test scripts in the test script code set is larger than 1;
the first analysis program unit is used for directly entering the step of constructing an abstract syntax tree based on the script interpreter and the test script code set to obtain an analyzed program if the number of the test scripts in the test script code set is 1;
and the second analysis program unit is used for executing the steps of constructing an abstract syntax tree based on the script interpreter and the test script code set to each test script in the test script code set in sequence if the number of the test scripts in the test script code set is larger than 1, so as to obtain the analyzed program.
In some embodiments, the program acquisition module 12 specifically includes:
a test script code set sending unit, configured to send the test script code set to the script interpreter;
a test script loading unit, configured to load the test script in the test script code set through a reading area in the script interpreter;
a syntax element checking unit for analyzing and checking whether syntax elements in the test script are correct;
a third parsing program unit, configured to construct the abstract syntax tree based on the code writing tag information and a corresponding logic structure if the syntax element in the test script is correct, so as to obtain a parsed program;
the error prompting unit is used for generating and prompting corresponding error information if the grammar element in the test script is incorrect;
and the semantic checking unit is used for analyzing and checking whether the semantics in the parsed program are correct.
In some embodiments, the program execution module 13 specifically includes:
the program execution unit is used for executing the analyzed program if the semantics in the analyzed program are correct so as to obtain the test result of the test script code;
and the unit is used for sending the test result to the interaction page and displaying the test result.
In some embodiments, the result presentation module 14 specifically includes:
and the result display unit is used for sending the test result to the interaction page and displaying the test result.
Further, the embodiment of the application also provides electronic equipment. Fig. 8 is a block diagram of an electronic device 20, according to an exemplary embodiment, and the contents of the diagram should not be construed as limiting the scope of use of the present application in any way.
Fig. 8 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein the memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement relevant steps in the script testing method based on XML language disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol to be followed is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein; the input/output interface 25 is used for acquiring external input data or outputting external output data, and the specific interface type thereof may be selected according to the specific application requirement, which is not limited herein.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon may include an operating system 221, a computer program 222, and the like, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the electronic device 20 and computer programs 222, which may be Windows Server, netware, unix, linux, etc. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the XML-language-based script testing method performed by the electronic device 20 disclosed in any of the foregoing embodiments.
Further, the embodiment of the application also discloses a computer readable storage medium, wherein the storage medium stores a computer program, and when the computer program is loaded and executed by a processor, the script testing method based on the XML language disclosed in any embodiment is realized.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Finally, it is further noted that relational terms such as first and second, and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The script testing method, device, equipment and medium based on XML language provided by the application are described in detail, and specific examples are applied to illustrate the principle and implementation of the application, and the description of the above examples is only used for helping to understand the method and core ideas of the application; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. A script testing method based on XML language, comprising:
acquiring test information of an article to be tested, and generating a corresponding test script code set based on the test information and XML language rules;
the test script code set is sent to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set, and an analyzed program is obtained;
and executing the analyzed program to obtain a test result of the test script code, and sending the test result to an interaction page and displaying the test result.
2. The method for testing the script based on the XML language according to claim 1, wherein said obtaining the test information of the article to be tested and generating the corresponding test script code set based on the test information and the XML language rule includes:
acquiring test information of an article to be tested, and determining corresponding code writing label information in an XML language rule based on each test information; the code writing label information comprises data types, writing sentences and expression operations;
and generating the test script code set based on the code writing label information and the test information.
3. The XML-language-based script testing method of claim 2, wherein said sending the set of test script codes to a script interpreter to construct an abstract syntax tree based on the script interpreter and the set of test script codes, resulting in a parsed program, comprises:
transmitting the test script code set to a script interpreter, and judging whether the number of test scripts in the test script code set is greater than 1;
if the number of the test scripts in the test script code set is 1, directly entering the step of constructing an abstract syntax tree based on the script interpreter and the test script code set to obtain a resolved program;
and if the number of the test scripts in the test script code set is greater than 1, executing the abstract syntax tree constructed based on the script interpreter and the test script code set on each test script in the test script code set in sequence to obtain a resolved program.
4. A method of testing a script based on an XML language according to claim 3, wherein said sending said set of test script codes to a script interpreter to construct an abstract syntax tree based on said script interpreter and said set of test script codes, resulting in a parsed program, comprises:
transmitting the test script code set to the script interpreter, and loading the test scripts in the test script code set through a reading area in the script interpreter;
analyzing and checking whether the grammar element in the test script is correct, if so, constructing the abstract grammar tree based on the code writing label information and the corresponding logic structure to obtain the analyzed program.
5. The XML-language-based script testing method of claim 4, wherein after said analyzing and checking whether the syntax element in the test script is correct, further comprising:
and if the grammar element in the test script is incorrect, generating and prompting corresponding error information.
6. The method for testing a script based on an XML language according to claim 1, wherein said constructing an abstract syntax tree based on said script interpreter and said test script code set, after obtaining the parsed program, further comprises:
analyzing and checking whether the semantics in the parsed program are correct;
and if the semantics in the resolved program are correct, entering the step of executing the resolved program.
7. The XML-language-based script testing method according to any one of claims 1 to 6, wherein said sending the set of test script codes to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the set of test script codes, before obtaining the parsed program, further comprises:
and constructing the script interpreter based on the XML language rule.
8. A script testing device based on XML language, comprising:
the test script code generation module is used for acquiring the test information of the to-be-tested articles and generating a corresponding test script code set based on the test information and the XML language rule;
the program acquisition module is used for sending the test script code set to a script interpreter so as to construct an abstract syntax tree based on the script interpreter and the test script code set to obtain an analyzed program;
the program execution module is used for executing the analyzed program to obtain a test result of the test script code;
and the result display module is used for sending the test result to the interaction page and displaying the test result.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the XML-language-based script testing method of any one of claims 1 to 7.
10. A computer readable medium for storing a computer program; wherein the computer program, when executed by a processor, implements the XML-language-based script testing method of any one of claims 1 to 7.
CN202311415689.XA 2023-10-30 2023-10-30 Script testing method, device, equipment and medium based on XML language Active CN117171052B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311415689.XA CN117171052B (en) 2023-10-30 2023-10-30 Script testing method, device, equipment and medium based on XML language

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311415689.XA CN117171052B (en) 2023-10-30 2023-10-30 Script testing method, device, equipment and medium based on XML language

Publications (2)

Publication Number Publication Date
CN117171052A true CN117171052A (en) 2023-12-05
CN117171052B CN117171052B (en) 2024-02-09

Family

ID=88943449

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311415689.XA Active CN117171052B (en) 2023-10-30 2023-10-30 Script testing method, device, equipment and medium based on XML language

Country Status (1)

Country Link
CN (1) CN117171052B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1657634A2 (en) * 2004-11-12 2006-05-17 Empirix Inc. Test agent architecture
CN101996131A (en) * 2009-08-19 2011-03-30 航天信息股份有限公司 Automatic test method and automatic test platform for graphic user interface (GUI) based on x extensive makeup language (XML) packaging key word
US8028276B1 (en) * 2007-06-29 2011-09-27 Oracle America, Inc. Method and system for generating a test file
CN102541730A (en) * 2011-12-08 2012-07-04 北京空间飞行器总体设计部 Semantic identification and automatic generation method for spacecraft test script
CN108804305A (en) * 2017-05-05 2018-11-13 北京嘀嘀无限科技发展有限公司 A kind of method and device of automatic test
CN110232012A (en) * 2018-03-06 2019-09-13 国家计算机网络与信息安全管理中心 A kind of fuzz testing language protocol test script and testing engine based on xml
CN110861085A (en) * 2019-11-18 2020-03-06 哈尔滨工业大学 VxWorks-based mechanical arm instruction interpreter system
CN113419946A (en) * 2021-05-31 2021-09-21 西南电子技术研究所(中国电子科技集团公司第十研究所) Ice interface test case and test script automatic generation method
US20220067172A1 (en) * 2020-09-03 2022-03-03 Oracle International Corporation Dynamic taint tracking in abstract syntax tree interpreters

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1657634A2 (en) * 2004-11-12 2006-05-17 Empirix Inc. Test agent architecture
US8028276B1 (en) * 2007-06-29 2011-09-27 Oracle America, Inc. Method and system for generating a test file
CN101996131A (en) * 2009-08-19 2011-03-30 航天信息股份有限公司 Automatic test method and automatic test platform for graphic user interface (GUI) based on x extensive makeup language (XML) packaging key word
CN102541730A (en) * 2011-12-08 2012-07-04 北京空间飞行器总体设计部 Semantic identification and automatic generation method for spacecraft test script
CN108804305A (en) * 2017-05-05 2018-11-13 北京嘀嘀无限科技发展有限公司 A kind of method and device of automatic test
CN110232012A (en) * 2018-03-06 2019-09-13 国家计算机网络与信息安全管理中心 A kind of fuzz testing language protocol test script and testing engine based on xml
CN110861085A (en) * 2019-11-18 2020-03-06 哈尔滨工业大学 VxWorks-based mechanical arm instruction interpreter system
US20220067172A1 (en) * 2020-09-03 2022-03-03 Oracle International Corporation Dynamic taint tracking in abstract syntax tree interpreters
CN113419946A (en) * 2021-05-31 2021-09-21 西南电子技术研究所(中国电子科技集团公司第十研究所) Ice interface test case and test script automatic generation method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
朱经纬: "XML技术在软件测试自动化中的应用", 计算机工程, no. 02 *
焦红革;陈文;李泽民;焦鹏;: "基于XML的软件测试脚本生成", 车辆与动力技术, no. 01 *

Also Published As

Publication number Publication date
CN117171052B (en) 2024-02-09

Similar Documents

Publication Publication Date Title
US10108535B2 (en) Web application test script generation to test software functionality
US8850415B2 (en) Generating a transition system for use with model checking
CN102693323B (en) Cascading style sheet resolving method, resolver, webpage presentation method and server
US9329985B1 (en) Using emulation to disassociate verification from stimulus in functional test
CN110673837B (en) Code repairing method and device, electronic equipment and computer readable storage medium
CN113094625B (en) Page element positioning method and device, electronic equipment and storage medium
CN111209210A (en) Method and device for generating test case, electronic equipment and storage medium
KR102546424B1 (en) Machine learning data generating apparatus, apparatus and method for analyzing errors in source code
Oda et al. VDMPad: a lightweight IDE for exploratory VDM-SL specification
CN117171052B (en) Script testing method, device, equipment and medium based on XML language
Grieskamp et al. Instrumenting scenarios in a model-driven development environment
Garcia et al. ESBMC^ QtOM Q t OM: A Bounded Model Checking Tool to Verify Qt Applications
US20230195825A1 (en) Browser extension with automation testing support
CN116166907A (en) Method and device for developing Web application by using WebAsssembly and service page compiling technology
KR20200066778A (en) Code coverage measuring apparatus, code coverage measuring method of the code coverage mearusing apparatus, and code coverage measuring system
CN115328456A (en) Method for supporting automatic test script language based on xml
CN114428788A (en) Natural language processing method, device, equipment and storage medium
Ali Behavior-driven development as an error-reduction practice for mobile application testing
CN116860324B (en) Development data processing method, development data processing apparatus, and readable storage medium
CN112102844B (en) Writing and maintaining method and device for offline recognition of xbnf
Matsumoto et al. A method of verifying time-response requirements
bin Uzayr Conquering JavaScript: The Practical Handbook
CN118069103A (en) Multi-platform software development kit development and test method and electronic equipment
Gomathi et al. Pyrun–Auto solution searching feature in an online Python interpreter
CN118468816A (en) Project file generation method, device, equipment, medium and computer program product

Legal Events

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