CN111767223B - File processing method and device, electronic equipment and storage medium - Google Patents
File processing method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN111767223B CN111767223B CN202010605432.0A CN202010605432A CN111767223B CN 111767223 B CN111767223 B CN 111767223B CN 202010605432 A CN202010605432 A CN 202010605432A CN 111767223 B CN111767223 B CN 111767223B
- Authority
- CN
- China
- Prior art keywords
- element node
- node
- ith
- last
- nodes
- 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.)
- Active
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 17
- 238000012360 testing method Methods 0.000 claims abstract description 185
- 238000012545 processing Methods 0.000 claims abstract description 17
- 230000004048 modification Effects 0.000 claims description 26
- 238000012986 modification Methods 0.000 claims description 26
- 238000000034 method Methods 0.000 claims description 21
- 230000008859 change Effects 0.000 claims description 11
- 238000004590 computer program Methods 0.000 claims description 11
- 238000004458 analytical method Methods 0.000 claims description 4
- 238000004891 communication Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 6
- 230000008569 process Effects 0.000 description 6
- 230000008901 benefit Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 230000004044 response Effects 0.000 description 3
- 238000013507 mapping Methods 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 239000003550 marker Substances 0.000 description 1
- 238000002715 modification method Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3692—Test management for test results analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
- G06F40/174—Form filling; Merging
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Computer Hardware Design (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention provides a file processing method, a device, electronic equipment and a storage medium, which are applied to the technical field of data processing. After the test case file in the extensible markup language format is analyzed into the metadata, grading numbering is carried out on each element node according to the arrangement sequence among the element nodes in the metadata, and then the grade numbers of each element node and the contained node data are filled into a list in a target table format, so that the file in the extensible markup language format is converted into the table format with high readability, the identification is convenient for a user, and the test case file is modified.
Description
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for processing a file, an electronic device, and a storage medium.
Background
The Test Link (Test platform) is a browser page-based Test case relation system, is mainly used for creating, managing and executing Test cases, can completely manage the whole Test process from Test requirements to Test execution, and can provide statistics and analysis of a plurality of Test results.
In the prior art, the user can execute the steps of selecting, setting, editing, modifying and storing on the Test set or the Test case through the modification function provided by the Test Link, so as to complete modification. When the modification amount is too large, the user is required to continuously repeat the modification steps, so that the modification method is complex in process and low in efficiency. Therefore, how to efficiently edit test sets and test cases in a test platform becomes a problem to be solved by those skilled in the art.
Disclosure of Invention
In view of the above, the present invention provides a method, an apparatus, an electronic device, and a storage medium for processing files, so as to solve the problems of complicated steps and low modification efficiency in modifying test cases of a test set in a test platform in the prior art.
According to a first aspect of the present invention, there is provided a file processing method, comprising:
acquiring a test case file in an extensible markup language format from a test platform;
acquiring the tuple data of the test case file, wherein nodes in the tuple data are arranged according to a preset sequence;
determining an element node of a target type from the nodes of the tuple data;
determining the level number corresponding to the element node according to the preset sequence;
Filling the level numbers corresponding to the element nodes and the contained node data into a new table in a target table format to obtain a test case file in the target table format;
receiving a modification input instruction aiming at the test case file in the target table format;
and responding to the modification input instruction, and modifying the test case file in the target table format.
Optionally, the data in the test case file in the extensible markup language format is arranged according to a tree structure, and the step of determining the level number corresponding to the element node according to the preset sequence includes:
sequentially determining corresponding hierarchical marks of the element nodes in the tree structure according to the preset sequence;
and determining the level number corresponding to the element node according to the corresponding level mark.
Optionally, the element node includes: the step of sequentially determining the corresponding hierarchical marks of the element nodes in the tree structure according to the preset sequence comprises the following steps:
the tuple data comprises N element nodes, i is an integer, and i is more than or equal to 0 and less than or equal to N;
for the element nodes, determining the hierarchy mark corresponding to the Nth element node according to the steps in the preset sequence according to any one of the following conditions which are met by the element nodes:
When the ith element node is a starting element node and the hierarchy mark of the ith-1 element node is empty or 1 or the last two bits are sequentially 1 and 1, adding one element to the hierarchy mark of the ith-1 element node and taking the value of 1 as the hierarchy mark of the ith element node;
when the ith element node is a starting element node and the last two bits of the hierarchy mark of the ith-1 element node are sequentially 1 and 0, adding 1 to the last element value of the hierarchy mark of the ith-1 element node to serve as the hierarchy mark of the ith element node;
changing the last element value of 1 in the hierarchical label of the ith-1 element node to 0 when the ith element node is an ending element node, and then taking the modified hierarchical label of the ith-1 element node as the hierarchical label of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are not 0 and 0 in sequence;
and changing the last element value of 1 in the hierarchical label of the i-1 th element node into 0 under the condition that the i-1 th element node is an ending element node, and deleting the last element in the hierarchical label of the i-1 th element node as the hierarchical label of the i-1 th element node under the condition that the last two bits of the modified hierarchical label of the i-1 th element node are 0 and 0 in sequence.
Optionally, the step of determining the level number corresponding to the element node according to the corresponding level mark includes: :
for each element node, determining the level numbers corresponding to the N element nodes according to the steps in the preset sequence, wherein the steps are in accordance with any one of the following conditions:
when the ith element node is a starting element node and the hierarchy mark of the ith-1 element node is empty or 1 or the last two bits are sequentially 1 and 1, adding one element to the level number of the ith-1 element node and taking the value as 1 as the level number of the ith element node;
under the condition that the ith element node is a starting element node and the last two bits of the hierarchical label of the ith-1 element node are sequentially 1 and 0, adding 1 to the last element value of the level number of the ith-1 element node to serve as the level number of the ith element node;
changing the last element value of 1 in the hierarchical label of the ith-1 element node to 0 when the ith element node is an ending element node, and then taking the level number of the ith-1 element node as the level number of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are not 0 and 0 in sequence;
And changing the last element value of 1 in the hierarchical label of the ith-1 element node into 0 under the condition that the ith element node is an ending element node, and deleting the last element in the level number of the ith-1 element node as the level number of the ith element node under the condition that the last two bits of the modified hierarchical label of the ith-1 element node are 0 and 0 in sequence.
Optionally, the step of filling the level number corresponding to the element node and the included node data into a new table in the target table format to obtain a test case file in the table format includes:
creating a new table in a target table format, wherein the header field of the new table at least comprises: a level number field, a type field, a name field, and at least one information field, the information field being determined according to a type of node data in the element node;
and constructing data of a dictionary structure according to the header field by using node data of each element node and the level number, wherein the node data comprises: information node data, attribute node data and name node data;
Filling the data of the dictionary structure into the newly-built table to obtain a test case file in a table format of a target table format;
the level number field corresponds to the level number of the element node, the type field corresponds to the attribute node data, the name field corresponds to the name node data, and the information field corresponds to the information node data.
Optionally, the target types include a test set type and a test case type, and the step of obtaining the test case file in the extensible markup language format from the test platform includes:
receiving selection input aiming at test cases and/or test sets in a test platform;
acquiring a test case file in an extensible markup language format from a test platform according to the selection input;
the step of determining the element node of the target type from the nodes of the tuple data comprises:
and determining element nodes of the test case type and/or the test set type from the nodes of the tuple data.
According to a second aspect of the present invention, there is provided a document processing apparatus comprising:
the acquisition module is used for acquiring the test case file in the extensible markup language format from the test platform;
The analysis module is used for acquiring the tuple data of the test case file, and the nodes in the tuple data are arranged according to a preset sequence;
a determining module, configured to determine an element node of a target type from nodes of the tuple data;
the numbering module is used for determining the level numbers corresponding to the element nodes according to the preset sequence;
and the generating module is used for filling the level numbers corresponding to the element nodes and the included node data into a new table in a target table format to obtain a test case file in the table format.
The receiving module is used for receiving a modification input instruction aiming at the test case file in the target table format;
and the processing module is used for responding to the modification input instruction and modifying the test case file in the target table format.
Optionally, the data in the test case file in the extensible markup language format is arranged according to a tree structure, and the numbering module includes:
the first coding submodule is used for sequentially determining corresponding level marks of the element nodes in the tree structure according to the preset sequence;
and the second coding sub-module is used for determining the level number corresponding to the element node according to the corresponding level mark.
Optionally, the element node includes: the first coding submodule comprises a starting element node and an ending element node, and comprises:
the tuple data comprises N element nodes, i is an integer, and i is more than or equal to 0 and less than or equal to N;
for the element nodes, determining the hierarchy mark corresponding to the Nth element node by sequentially passing through the subunits according to the preset sequence, wherein the subunits are in accordance with any one of the following conditions:
a first numbering subunit, configured to add an element to the level mark of the i-1 th element node and use the value of the element as the level mark of the i-1 th element node when the i-1 th element node is the start element node and the level mark of the i-1 th element node is null, or 1, or the last two bits are sequentially 1 and 1;
a second numbering subunit, configured to add 1 to a last element value of the level flag of the i-1 th element node as the level flag of the i-1 th element node when the i-1 th element node is a start element node and the last two bits of the level flag of the i-1 th element node are sequentially 1 and 0;
a third numbering subunit, configured to change, when an i-th element node is an end element node, an element value of a last 1 in the hierarchy label of the i-1-th element node to 0, and then, when the last two bits of the modified hierarchy label of the i-1-th element node are not 0 and 0 in order, use the modified hierarchy label of the i-1-th element node as the hierarchy label of the i-th element node;
And a fourth numbering subunit, configured to change, when the i-th element node is an end element node, an element value of a last 1 in the hierarchy label of the i-1-th element node to 0, and then delete, when the last two bits of the modified hierarchy label of the i-1-th element node are 0 and 0 in order, a last element in the hierarchy label of the i-1-th element node as the hierarchy label of the i-th element node.
Optionally, the second coding sub-module includes: :
for each element node, determining the level numbers corresponding to the N element nodes by sequentially passing through the subunits according to the preset sequence, wherein the subunits correspond to any one of the following conditions:
a fifth numbering subunit, configured to add an element to the level number of the i-1 th element node and use the value of the element as the level number of the i-1 th element node when the i-1 th element node is the start element node and the level label of the i-1 th element node is null, or 1, or the last two bits are sequentially 1 and 1;
a sixth numbering subunit, configured to add 1 to a last element value of the level number of the i-1 th element node as the level number of the i-1 th element node when the i-1 th element node is a start element node and the last two bits of the level label of the i-1 th element node are sequentially 1 and 0;
A seventh numbering subunit, configured to change, when an i-th element node is an end element node, an element value of a last 1 in the hierarchy label of the i-1-th element node to 0, and then, when the last two bits of the modified hierarchy label of the i-1-th element node are not 0 and 0 in order, take a level number of the i-1-th element node as a level number of the i-th element node;
an eighth numbering subunit, configured to change, when the i-th element node is an end element node, an element value of a last 1 in the hierarchy label of the i-1-th element node to 0, and then delete, when the last two bits of the modified hierarchy label of the i-1-th element node are 0 and 0 in order, a last element in the level number of the i-1-th element node as the level number of the i-th element node.
Optionally, the generating module includes:
the creation sub-module is used for creating a new table in a target table format, and the header field of the new table at least comprises: a level number field, a type field, a name field, and at least one information field, the information field being determined according to a type of node data in the element node;
A construction sub-module, configured to construct node data of each element node and the level number according to the header field to form data of a dictionary structure, where the node data includes: information node data, attribute node data and name node data;
the filling sub-module is used for filling the data of the dictionary structure into the newly-built table to obtain a test case file in a table format of a target table format;
the level number field corresponds to the level number of the element node, the type field corresponds to the attribute node data, the name field corresponds to the name node data, and the information field corresponds to the information node data.
Optionally, the target types include a test set type and a test case type, and the obtaining module includes:
the receiving sub-module is used for receiving selection input aiming at test cases and/or test sets in the test platform;
the input sub-module is used for acquiring a test case file in an extensible markup language format from the test platform according to the selection input;
the determining module includes:
and the determining submodule is used for determining element nodes of the test case type and/or the test set type from the nodes of the tuple data.
According to a third aspect of the present invention, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the file processing method according to any of the above-mentioned first aspects when executing the computer program.
According to a fourth aspect of the present invention, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the file processing method of any of the above-described first aspects.
Aiming at the prior art, the invention has the following advantages:
according to the file processing method, the device, the electronic equipment and the storage medium, after the test case file in the extensible markup language format is analyzed into the metadata, the element nodes are numbered in a grading manner according to the arrangement sequence among the element nodes in the metadata, and then the level numbers of the element nodes and the node data contained in the element nodes are filled into a list in the target table format, so that the file in the extensible markup language format is converted into the table format with high readability, the identification by a user is facilitated, and the test case file is modified.
The foregoing description is only an overview of the present invention, and is intended to be implemented in accordance with the teachings of the present invention in order that the same may be more clearly understood and to make the same and other objects, features and advantages of the present invention more readily apparent.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
FIG. 1 is a flowchart illustrating steps of a method for processing a file according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating another two file processing methods according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating steps of a method for determining a hierarchy identification according to an embodiment of the present invention;
FIG. 4 is a flowchart of steps of a method for determining a level number according to an embodiment of the present invention;
FIG. 5 is a block diagram of a document processing apparatus according to an embodiment of the present invention;
Fig. 6 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
Fig. 1 is a file processing method provided in an embodiment of the present invention, including:
step 101, obtaining a test case file in an extensible markup language format from a test platform.
In the embodiment of the invention, the test case file is a formatted file, the XML (EXtensible Markup Language ) is a structured markup language used for marking the electronic file, and data in the XML formatted file is arranged in a node form according to a tree structure, but the text in the XML formatted file can be read and understood by a user, but the data structure is complex, so that the user can hardly find a required part in the file by himself under the condition of large data quantity, and the user is not utilized to change the XML formatted file.
In practical application, if the user needs to modify only a single test case or test set at a time if the test case and test set exported by the Testlink are XML files, and if the user needs to modify a plurality of test cases and test sets, the user needs to export a plurality of test users and/or test sets to be modified from the Testlink into XML files, and then modify the files by themselves. Obviously, a large number of XML-format files cannot be quickly found out to be modified by a user due to poor readability, and thus the XML-format files need to be converted into highly readable files for the user to browse and modify.
Step 102, obtaining the tuple data of the test case file, wherein the nodes in the tuple data are arranged according to a preset sequence.
In the embodiment of the present invention, the test case file may be parsed from top to bottom by using an iterparse function in python (a cross-platform computer programming language) according to a tree structure formed by the included nodes, so as to obtain iteratable tuple data including each node in the test case file. And each node in the tuple data is arranged according to the hierarchical relation of the tree structure in the test case file and the preset sequence, and the tuple data does not contain the hierarchical relation among the nodes.
And step 103, determining the element node of the target type from the nodes of the metadata.
In the embodiment of the invention, the metadata comprises each element node and corresponding attribute nodes, information nodes, name nodes and the like, and the attribute nodes are used for explaining the types of each element node, so that the attribute types of the element nodes can be determined according to the attribute nodes corresponding to the element nodes, the required target types can be determined according to the self requirements, and the element nodes of the target types can be screened from the metadata for subsequent processing.
Step 104, determining the level number corresponding to the element node according to the preset sequence.
In the embodiment of the present invention, the preset sequence refers to a sequence when each node in the test case file is parsed, and the level number is used to express a hierarchical relationship between each element node.
The principle of the iterparse function is that when a ">" symbol of a tag in a test case file in an XML format is encountered, a start element node is triggered to be generated, and when an end mark of the tag is encountered, an end element node is triggered to be generated, so that each element node has a corresponding start element node and end element node. The starting element nodes and the ending element nodes are arranged according to the hierarchical relation of the nodes in the test case file and the preset sequence, so that the hierarchical relation among the element nodes can be determined according to the preset sequence among the element nodes, the hierarchy of the element nodes is determined, each element node is numbered according to the hierarchy, and the level number corresponding to the element nodes is obtained.
And 105, filling the level numbers corresponding to the element nodes and the included node data into a new table in a target table format to obtain a test case file in the table format.
In the embodiment of the present invention, the target table format may be a table format with high readability, such as XLS, XLSX (a compressed file format based on the Office Open XML standard replaces its former proprietary XLS file format), CSV (common-Separated Values), and the like. And respectively filling the obtained element node level numbers and data in information nodes contained in the element nodes into each row of the new page of the new table according to different types by calling a work book function in a tool package xlwt of python to create a file handle and the new page of the target table format, calling a save function of the handle after the data are filled, and storing the filled new table as a test case file of the target table format.
And 106, receiving a modification input instruction aiming at the test case file in the target table format.
In the embodiment of the invention, the test case file in the form format is displayed to the user through the screen of the client, so that the user can intuitively and rapidly find the data needing to be modified in the test case file in the form format. The user may modify the data in the test case file in the target table format that needs to be modified to generate the modification input instructions. Of course, the user can also select the data in the test case file in the table format in batches so as to uniformly modify the batch of data.
And step 107, in response to the modification input instruction, modifying the test case file in the target table format.
In the embodiment of the invention, the client side carries out batch modification on the data in the test case file in the table format according to the modification input instruction of the user on the data in the test case file in the table format, thereby improving the efficiency of data modification.
According to the file processing method provided by the embodiment of the invention, after the test case file in the extensible markup language format is analyzed into the tuple data, the element nodes are numbered in a grading manner according to the arrangement sequence among the element nodes in the tuple data, and then the level numbers of the element nodes and the contained node data are filled into a list in the target table format, so that the file in the extensible markup language format is converted into the table format with high readability, the identification by a user is facilitated, and the test case file is modified.
Fig. 2 is a schematic diagram of another file processing method according to an embodiment of the present invention, including:
step 201, receiving a selection input for a test case and/or a test set in a test platform.
In the embodiment of the invention, the test platform refers to a test case relation system of a browser page, is mainly used for creating, managing and executing test cases, can completely manage the whole test process from test requirement and test design to test execution, and can also provide statistics and analysis of a plurality of test results.
The user can select the needed test cases and/or data sets from the test user and the test set list in the test platform so as to conduct export.
Step 202, obtaining the test case file in the extensible markup language format from the test platform according to the selection input.
In the embodiment of the invention, the test platform inputs and outputs the test case file in the extensible markup language format for subsequent format conversion according to the selection of the user.
And 203, acquiring the tuple data of the test case file, wherein the nodes in the tuple data are arranged according to a preset sequence.
This step is described in detail with reference to step 101, and will not be described here.
Step 204, determining element nodes of the test case type and/or the test set type from the nodes of the metadata.
In the embodiment of the invention, because the user mainly needs to modify the test case and the test set, the element nodes of the test type and the test set type need to be extracted from the obtained element data, and the element nodes comprise the corresponding attribute nodes, so that whether the element nodes are of the target type can be determined through the attribute nodes.
Optionally, the data in the test case file in the extensible markup language format is arranged according to a tree structure.
Step 205, determining the corresponding hierarchical marks of the element nodes in the tree structure according to the preset sequence.
In the embodiment of the present invention, since the tuple data is obtained by sequentially traversing the test case file according to the tree structure formed by the element nodes to parse the test case file, the element nodes are sequentially arranged in the tuple data according to a preset sequence, the preset sequence corresponds to the tree structure of the element nodes in the test case file, and since the element nodes in the XML format are arranged according to the hierarchical relationship, the hierarchy corresponding to the element nodes can be determined according to the preset sequence.
Optionally, the element node includes: a start element node and an end element node, optionally, referring to fig. 3, the step 205 includes:
the tuple data comprises N element nodes, i is an integer, and i is more than or equal to 0 and less than or equal to N.
Step 2051, for the element nodes, determining a hierarchy mark corresponding to the nth element node according to the steps in the preset sequence in any one of the following conditions according to which the element nodes conform to the preset sequence:
In the embodiment of the invention, the hierarchy mark is a hierarchy for determining the correspondence of the element nodes, but the hierarchy cannot reflect the relationship between the hierarchy mark and the element nodes of the parallel hierarchy. Because of the data structure characteristics of the XML format, each element node contains a corresponding start element node and end element node, that is, the number of the start element node and the end element node contained in the tuple data is the same, and the hierarchical label of each element node is determined in turn according to the preset sequence among the element nodes.
Specifically, the hierarchical label of the i-1 th element node is used as the basis for determining the hierarchical label of the i-1 th element node, and the specific determination steps are as follows:
it should be noted that, the level marks are in the form of "1, …,1", the first 1 represents the highest level, then each 1 represents the sub-level of the adjacent higher level, the more elements 1 are included, the lower the level, and conversely, the higher the level, and the highest level is 1. For example: 1,1 is a sub-level of 1, and 1,1 is a sub-level of 1. Each element node comprises a start element node and an end element node, and the level labels of the start element node and the end element node are the same.
And a substep A1, adding an element and a value of 1 to the hierarchical label of the ith-1 element node as the hierarchical label of the ith element node under the condition that the ith element node is a starting element node and the hierarchical label of the ith-1 element node is null or 1 or the last two bits are sequentially 1 and 1.
In the embodiment of the invention, for the ith element node, if the ith element node is the starting element node, judging whether the last two bits of the hierarchy mark of the ith-1 element node arranged in front of the ith element node are sequentially 1 and 1 or the value of the hierarchy mark is 1, determining that the ending element node corresponding to the starting element node does not appear yet, wherein the node contained in the element node is not ended yet, so that the ith element node is the starting element node of the next-level child node contained in the ith-1 element node, adding one element to the last bit of the hierarchy mark of the ith-1 element node and the value of the last bit is 1, and taking the last bit as the hierarchy mark of the ith element node. And when the hierarchy mark of the i-1 th element node is empty, the i-1 th element node is the starting element node of the outermost layer, and an element value of 1 is added to the empty value to serve as the hierarchy mark of the i-1 th element node.
And a substep A2, wherein when the ith element node is a starting element node and the last two bits of the hierarchical label of the ith-1 element node are sequentially 1 and 0, the last element value of the hierarchical label of the ith-1 element node is increased by 1 to be used as the hierarchical label of the ith element node.
In the embodiment of the invention, if the last two bits of the hierarchy mark of the i-1 th element node are sequentially 1 and 0, and the i-th element node arranged behind the i-1 th element node is the starting element node, the i-th element node is the child node of the lower hierarchy of the i-1 th element node, so that the value of 0 of the last bit of the hierarchy mark of the i-1 th element node is increased by 1 and then becomes 1, and the value can be used as the hierarchy mark of the i-th element node. For example: if the hierarchy mark of the i-1 th element node is 1,0, and the i-th element node at the back is the start element node, the 1,0 is changed to 1, and the 1-1 th element node is used as the hierarchy mark of the i-th element node.
And a substep A3, changing the last element value of 1 in the hierarchical label of the ith-1 element node into 0 when the ith element node is an ending element node, and then taking the modified hierarchical label of the ith-1 element node as the hierarchical label of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are not 0 and 0 in sequence.
In the embodiment of the invention, if the ith element node is an ending element node, modifying the last element value of 1 of the hierarchical labels of the ith-1 element nodes arranged in front of the ith element node to be 0 so as to determine the hierarchical label of the subsequent starting element node, judging whether the last two bits of the modified hierarchical label of the ith-1 element node are 0 at the moment, and if not, taking the modified hierarchical label of the ith-1 element node as the hierarchical label of the ith element node. It will be appreciated that only one 0 need follow each hierarchy level marker, and that if there are too many 0's, the hierarchy determination of the subsequent end element node may be affected.
And a substep A4, changing the last element value of 1 in the hierarchical label of the ith-1 element node into 0 when the ith element node is an ending element node, and deleting the last element in the hierarchical label of the ith-1 element node as the hierarchical label of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are 0 and 0 in sequence.
In the embodiment of the present invention, following the description of the above substep A3, after the last element value of 1 of the hierarchical label for the i-1 th element node is changed to 0, the last two bits are both 0, and the last element is deleted at this time, that is, after deleting one 0, the last element is used as the hierarchical label for the i-1 th element node.
And 206, determining the level number corresponding to the element node according to the corresponding level mark.
Optionally, referring to fig. 4, the step 206 includes:
step 2061, for each element node, determining the level numbers corresponding to the N element nodes according to the steps in the preset sequence according to any one of the following conditions that the element nodes conform to:
in the embodiment of the present invention, the hierarchy mark can only reflect the hierarchy where each element node is located, and cannot reflect the parallel relationship between the element nodes, that is, the hierarchy mark can only confirm the upper and lower relationships between the element node and the upper and lower element nodes, and cannot be directly used as the hierarchy number of each element node, for example: if the hierarchy marks of two element nodes in the same hierarchy are 1,1 and 1, and the hierarchy marks are directly used as the level numbers, a user cannot distinguish the two element nodes, so that the level numbers corresponding to the element nodes are required to be determined according to the hierarchy marks and the preset sequence among the element nodes.
And B1, adding an element to the level number of the i-1 th element node and taking the value as 1 as the level number of the i-1 th element node under the condition that the i-1 th element node is the starting element node and the level mark of the i-1 th element node is null or 1 or the last two bits are sequentially 1 and 1.
In the embodiment of the invention, the hierarchical mark and the level number of the ith element node are taken as the basis of the level number of the ith element node. Specifically, if the i-th element node is the start element node, it is determined whether the level flag of the i-1 th element node arranged in front of the i-th element node is empty (the i-th element node is the outermost element node), or 1 (the i-th element node is a child node arranged in front of the i-th element node), and the level number of the i-1 th element node is increased by one element with a value of 1 and then is used as the level number of the i-th element node.
And B2, adding 1 to the last element value of the level number of the ith-1 element node as the level number of the ith element node under the condition that the ith element node is the starting element node and the last two bits of the level mark of the ith-1 element node are sequentially 1 and 0.
In the embodiment of the present invention, if the i-th element node is the start element node and the last two bits of the level label of the i-1 th element node are sequentially 1 and 0, it may be confirmed that the i-th element node is the node at the same level as the i-1 th element node, and at this time, the last element value of the level number of the i-1 th element node needs to be increased by 1 to be used as the level number of the i-th element node. For example: the level number of the i-1 th element node is 1, and the level label is 1,0, and then the level number of the i-1 th element node is 1, 1+1- (1, 2).
And B3, changing the last element value of 1 in the hierarchical label of the ith-1 element node into 0 when the ith element node is an ending element node, and then taking the level number of the ith-1 element node as the level number of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are not 0 and 0 in sequence.
In the embodiment of the present invention, if the i-1 th element node is an end element node, the last element value of 1 in the hierarchical label of the i-1 th element node is changed to 0, and then, if the last two bits of the modified hierarchical label of the i-1 th element node are not 0 and 0 in sequence, the i-1 th element node can be determined to be the start element node, and the i-1 th element node is the end element node corresponding to the i-1 th element node, and since the level numbers of the start element node and the end element node corresponding to each other are the same, the level number of the i-1 th element node is used as the level number of the i-1 th element node.
And B4, changing the last element value of 1 in the hierarchical label of the ith-1 element node into 0 when the ith element node is an ending element node, and deleting the last element in the level number of the ith-1 element node as the level number of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are 0 and 0 in sequence.
In the embodiment of the present invention, if the ith element node is an end element node, the last element value of 1 in the hierarchical label of the ith-1 element node is changed to 0, and then if the last two bits of the modified hierarchical label of the ith-1 element node are 0 and 0 in sequence, it may be determined that the ith element node is the end element node of the father node of the ith-1 element node, and then the level number of the ith-1 element node needs to be deleted as the level number of the ith element node.
In practical use, the steps described in the above steps A1 to A4, and B1 to B4 are exemplified with reference to the following Table-1:
TABLE-1
The sequence number and the attribute in the header indicate the need and the type of the element node, the testsuite indicates that the element node is of a case set type, the testsuite indicates that the element node is of a test case, the start, the testsuite and the end respectively indicate the start element node and the end element node of the case set type, and the start, the testsuite and the end respectively indicate the start element node and the end element node of the test case type. Each row represents the parameters of one element node, and the hierarchy mark and the level number of each row are the basis of the hierarchy mark and the level number of the element node of the next row.
Line 1, satisfying the conditions of the steps A1 and B1, namely, the starting element node, wherein if the level marking value of the last element node is null, the level marking of the element node is 1, and the level number is 1;
line 2, satisfying the conditions of the above steps A1 and B1, namely, the starting element node, wherein the level mark of the last element node is 1, and the level mark of the element node is 1, and the level number is 1,1;
line 3, satisfying the conditions of the above steps A1 and B1, namely, the starting element node, and the last two digits of the hierarchy mark of the last element node are 1, and the hierarchy mark of the element node is 1, and the level number is 1,1.
Row 4, same as row 3;
line 5, satisfying the conditions of the above steps A3 and B3, namely, ending the element node, wherein after the last 1 of the level marks of the last element node is changed to 0, the last two bits are 1,0, and the level marks of the element node are 1,0, and the level numbers are 1,1;
line 6, satisfying the conditions of the above steps A2 and B2, namely, the starting element node, wherein the level mark of the last element node is 1,0, and the level mark of the element node is 1, and the level number is 1,2;
row 7, same as row 5;
Line 8, satisfying the conditions of the above steps A4 and B4, namely, the end element node, wherein the level mark of the last element node is 1,0, and then the last 1 of the level mark is changed to 0 to obtain 1,0, and then one 0 is removed to serve as the level mark of the element node, and the last bit of the level number of the last element node is deleted to obtain 1,1 to serve as the level number of the element node.
The subsequent lines 9 to 22 are obtained according to the logic from the line 1 to the line 8, so that the level number corresponding to each element node is obtained, and it can be found that the level number corresponds to the hierarchical relationship between each element node and each node in the tree structure in the XML-format test case file, so that the user identification is facilitated.
Step 207, creating a new table in the target table format, where a header field of the new table at least includes: a level number field, a type field, a name field, and at least one information field, the information field being determined according to a type of node data in the element node.
In the embodiment of the invention, a new table in a target list format can be created by calling the work book line number of the python tool package xlwt, and the new table contains a number field, a type field, a name field and at least one information field corresponding to the element node, wherein each field is a column. Wherein the information field may be determined according to the type of information field contained by the element node, for example: the element node of the case set type contains information nodes of Details type, and the element node of the test case type contains information nodes of Summary type, information nodes of Preconditions type, and the like. The type of the information field may be specifically determined according to actual requirements, and is not specifically limited herein.
Step 208, constructing data of a dictionary structure according to the header field by using node data of each element node and the level number, where the node data includes: information node data, attribute node data and name node data.
In the embodiment of the present invention, the information node data, attribute node data and name node data contained in each element node are extracted from the tuple data, and these node data and the obtained level numbers are formed into a dictionary structure, for example: the element nodes of the user set type are { "level number": 1, "hierarchical label": "attribute node data", "name node data"; "case set 1", "Details" means "Details information of case set 1" }, for test cases { "level number": "1.1.1", "hierarchical mark": "attribute node data", "name node data": "use case 1.1.1", "Summary": "use case 1.1.1 Summary information", "Precondition": "xxx", "other n": "xxx" }.
And 209, filling the data of the dictionary structure into the newly built table to obtain a test case file in a table format of a target table format. The level number field corresponds to the level number of the element node, the type field corresponds to the attribute node data, the name field corresponds to the name node data, and the information field corresponds to the information node data.
In the embodiment of the invention, a mapping relation between each type of data in the dictionary node and each header in the newly-built table is established, and the mapping relation is specifically: the level number field corresponds to the level number of the element node, the type field corresponds to the attribute node data, the name field corresponds to the name node data, the information field corresponds to the information node data, and then the data of the dictionary structure are sequentially filled into the newly built table according to the corresponding relation to obtain the test case file in the table format of the target table format.
Step 210, receiving a modification input instruction for the test case file in the target table format.
This step is described in detail with reference to step 106 and will not be described here.
Step 211, in response to the modification input instruction, modifying the test case file in the target table format.
This step is described in detail with reference to step 107 and will not be described in detail here.
According to the file processing method provided by the invention, after the test case file in the extensible markup language format is analyzed into the tuple data, the element nodes are numbered in a grading manner according to the arrangement sequence among the element nodes in the tuple data, and then the level numbers of the element nodes and the contained node data are filled into a list in the target table format, so that the file in the extensible markup language format is converted into the table format with high readability, the identification by a user is facilitated, and the test case file is modified. And the level numbers of the element nodes are determined according to the preset sequence among the element nodes, so that the readability of the test case file in the form format is improved, the user can conveniently identify, and the test case file is modified.
Fig. 5 is a block diagram of a file processing apparatus 30 according to an embodiment of the present invention, where the apparatus includes:
the obtaining module 301 is configured to obtain a test case file in an extensible markup language format from the test platform.
And the parsing module 302 is configured to obtain tuple data of the test case file, where nodes in the tuple data are arranged according to a preset sequence.
A determining module 303, configured to determine an element node of a target type from the nodes of the tuple data.
And a numbering module 304, configured to determine a level number corresponding to the element node according to the preset sequence.
And the generating module 305 is configured to fill the level number corresponding to the element node and the node data included in the level number into a new table in the target table format, so as to obtain a test case file in the table format.
And the receiving module 306 is configured to receive a modification input instruction for the test case file in the target table format.
And the processing module 307 is configured to modify the test case file in the target table format in response to the modification input instruction.
Optionally, the data in the test case file in the extensible markup language format is arranged according to a tree structure, and the numbering module 304 includes:
The first numbering submodule 3041 is configured to sequentially determine, according to the preset order, a hierarchy mark corresponding to the element node in the tree structure.
And the second numbering submodule 3042 is used for determining the level number corresponding to the element node according to the corresponding level mark.
Optionally, the element node includes: a start element node and an end element node, the first numbering submodule 3041 includes:
the tuple data comprises N element nodes, i is an integer, and i is more than or equal to 0 and less than or equal to N.
For the element nodes, determining the hierarchy mark corresponding to the Nth element node by sequentially passing through the subunits according to the preset sequence, wherein the subunits are in accordance with any one of the following conditions:
and the first numbering subunit C1 is configured to add an element to the level mark of the i-1 th element node and use the value of 1 as the level mark of the i-1 th element node when the i-1 th element node is the start element node and the level mark of the i-1 th element node is null, or 1, or the last two bits are sequentially 1 and 1.
And the second numbering subunit C2 is configured to add 1 to the last element value of the hierarchy mark of the i-1 th element node as the hierarchy mark of the i-1 th element node when the i-1 th element node is the start element node and the last two bits of the hierarchy mark of the i-1 th element node are sequentially 1 and 0.
And the third numbering subunit C3 is configured to change the last element value of 1 in the hierarchical label of the i-1 th element node to 0 when the i-1 th element node is an end element node, and then use the modified hierarchical label of the i-1 th element node as the hierarchical label of the i-1 th element node when the last two bits of the modified hierarchical label of the i-1 th element node are not 0 and 0 in sequence.
And a fourth numbering subunit C4, configured to change, when the i-th element node is an end element node, an element value of a last 1 in the hierarchical label of the i-1-th element node to 0, and then delete, when the last two bits of the modified i-1-th element node are 0 and 0 in order, a last element in the hierarchical label of the i-1-th element node as the hierarchical label of the i-th element node.
Optionally, the second numbering sub-module 3042 includes: :
for each element node, determining the level numbers corresponding to the N element nodes by sequentially passing through the subunits according to the preset sequence, wherein the subunits correspond to any one of the following conditions:
and a fifth numbering subunit D1, configured to add an element to the level number of the i-1 th element node and use the value of 1 as the level number of the i-1 th element node when the i-1 th element node is the start element node and the level label of the i-1 th element node is null, or 1, or the last two bits are sequentially 1 and 1.
A sixth numbering subunit D2, configured to add 1 to the last element value of the level number of the i-1 th element node as the level number of the i-1 th element node when the i-1 th element node is the start element node and the last two bits of the level label of the i-1 th element node are sequentially 1 and 0.
A seventh numbering subunit D3, configured to change, when the i-th element node is an end element node, an element value of a last 1 in the hierarchical label of the i-1-th element node to 0, and then, when the last two bits of the modified hierarchical label of the i-1-th element node are not 0 and 0 in order, take the level number of the i-1-th element node as the level number of the i-th element node.
An eighth numbering subunit D4, configured to change, when the i-th element node is an end element node, an element value of a last 1 in the hierarchical label of the i-1-th element node to 0, and then delete, when the last two bits of the modified hierarchical label of the i-1-th element node are 0 and 0 in order, a last element in the level number of the i-1-th element node as the level number of the i-th element node.
Optionally, the generating module 305 includes:
the creating submodule 3051 is configured to create a new table in the target table format, where a header field of the new table at least includes: a level number field, a type field, a name field, and at least one information field, the information field being determined according to a type of node data in the element node.
A building sub-module 3052, configured to build the node data of each element node and the level number according to the header field to form data of a dictionary structure, where the node data includes: information node data, attribute node data and name node data.
And a filling sub-module 3053, configured to fill the data of the dictionary structure into the new table, so as to obtain a test case file in a table format of the target table format.
The level number field corresponds to the level number of the element node, the type field corresponds to the attribute node data, the name field corresponds to the name node data, and the information field corresponds to the information node data.
Optionally, the target types include a test set type and a test case type, and the obtaining module 301 includes:
The receiving sub-module 3011 is configured to receive selection input for a test case and/or a test set in the test platform.
And the input submodule 3012 is used for acquiring the test case file in the extensible markup language format from the test platform according to the selection input.
The determining module 303 includes:
a determining submodule 3031 is configured to determine an element node of the test case type and/or the test set type from the nodes of the tuple data.
According to the file processing device provided by the invention, after the test case file in the extensible markup language format is analyzed into the tuple data, the element nodes are numbered in a grading manner according to the arrangement sequence among the element nodes in the tuple data, and then the level numbers of the element nodes and the contained node data are filled into the list in the target table format, so that the file in the extensible markup language format is converted into the table format with high readability, the identification by a user is facilitated, and the test case file is modified. And the level numbers of the element nodes are determined according to the preset sequence among the element nodes, so that the readability of the test case file in the form format is improved, the user can conveniently identify, and the test case file is modified.
For the embodiments of the device described above, the description is relatively simple, as it is substantially similar to the method embodiments, with reference to the description of the method embodiments in part.
The embodiment of the present invention further provides an electronic device, as shown in fig. 6, including a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 complete communication with each other through the communication bus 404,
a memory 403 for storing a computer program;
the processor 401, when executing the program stored in the memory 403, implements the following steps: acquiring a test case file in an extensible markup language format from a test platform; acquiring the tuple data of the test case file, wherein nodes in the tuple data are arranged according to a preset sequence; determining an element node of a target type from the nodes of the tuple data; determining the level number corresponding to the element node according to the preset sequence; filling the level numbers corresponding to the element nodes and the contained node data into a new table in a target table format to obtain a test case file in the table format; receiving a modification input instruction aiming at the test case file in the target table format; and responding to the modification input instruction, and modifying the test case file in the target table format.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or 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 aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, in which instructions are stored, which when run on a computer, cause the computer to perform the file processing method according to any of the above embodiments.
In a further embodiment of the present invention, a computer program product comprising instructions which, when run on a computer, cause the computer to perform the file processing method according to any of the above embodiments is also provided.
In the above embodiments, it may be implemented in whole or in part 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, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more 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)), etc.
It is 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.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims (7)
1. A document processing method, comprising:
acquiring a test case file in an extensible markup language format from a test platform;
acquiring the tuple data of the test case file, wherein nodes in the tuple data are arranged according to a preset sequence;
determining an element node of a target type from the nodes of the tuple data; the element node includes: a start element node and an end element node;
determining the level number corresponding to the element node according to the preset sequence;
filling the level numbers corresponding to the element nodes and the contained node data into a new table in a target table format to obtain a test case file in the target table format;
receiving a modification input instruction aiming at the test case file in the target table format;
responding to the modification input instruction, and modifying the test case file in the target table format;
The data in the test case file in the extensible markup language format is arranged according to a tree structure, and the step of determining the level number corresponding to the element node according to the preset sequence comprises the following steps:
sequentially determining corresponding hierarchical marks of the element nodes in the tree structure according to the preset sequence;
determining a level number corresponding to the element node according to the corresponding level mark;
the step of sequentially determining the corresponding hierarchical labels of the element nodes in the tree structure according to the preset sequence comprises the following steps:
the tuple data comprises N element nodes, i is an integer, and i is more than or equal to 0 and less than or equal to N;
for the element nodes, determining the hierarchy mark corresponding to the Nth element node according to the steps in the preset sequence according to any one of the following conditions which are met by the element nodes:
when the ith element node is a starting element node and the hierarchy mark of the ith-1 element node is empty or 1 or the last two bits are sequentially 1 and 1, adding one element to the hierarchy mark of the ith-1 element node and taking the value of 1 as the hierarchy mark of the ith element node;
when the ith element node is a starting element node and the last two bits of the hierarchy mark of the ith-1 element node are sequentially 1 and 0, adding 1 to the last element value of the hierarchy mark of the ith-1 element node to serve as the hierarchy mark of the ith element node;
Changing the last element value of 1 in the hierarchical label of the ith-1 element node to 0 when the ith element node is an ending element node, and then taking the modified hierarchical label of the ith-1 element node as the hierarchical label of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are not 0 and 0 in sequence;
and changing the last element value of 1 in the hierarchical label of the i-1 th element node into 0 under the condition that the i-1 th element node is an ending element node, and deleting the last element in the hierarchical label of the i-1 th element node as the hierarchical label of the i-1 th element node under the condition that the last two bits of the modified hierarchical label of the i-1 th element node are 0 and 0 in sequence.
2. The method according to claim 1, wherein the step of determining the level number corresponding to the element node according to the corresponding level mark comprises:
for each element node, determining the level numbers corresponding to the N element nodes according to the steps in the preset sequence, wherein the steps are in accordance with any one of the following conditions:
When the ith element node is a starting element node and the hierarchy mark of the ith-1 element node is empty or 1 or the last two bits are sequentially 1 and 1, adding one element to the level number of the ith-1 element node and taking the value as 1 as the level number of the ith element node;
under the condition that the ith element node is a starting element node and the last two bits of the hierarchical label of the ith-1 element node are sequentially 1 and 0, adding 1 to the last element value of the level number of the ith-1 element node to serve as the level number of the ith element node;
changing the last element value of 1 in the hierarchical label of the ith-1 element node to 0 when the ith element node is an ending element node, and then taking the level number of the ith-1 element node as the level number of the ith element node when the last two bits of the modified hierarchical label of the ith-1 element node are not 0 and 0 in sequence;
and changing the last element value of 1 in the hierarchical label of the ith-1 element node into 0 under the condition that the ith element node is an ending element node, and deleting the last element in the level number of the ith-1 element node as the level number of the ith element node under the condition that the last two bits of the modified hierarchical label of the ith-1 element node are 0 and 0 in sequence.
3. The method according to claim 1, wherein the step of filling the level number corresponding to the element node and the included node data into a new table in a target table format to obtain a test case file in the table format includes:
creating a new table in a target table format, wherein the header field of the new table at least comprises: a level number field, a type field, a name field, and at least one information field, the information field being determined according to a type of node data in the element node;
and constructing data of a dictionary structure according to the header field by using node data of each element node and the level number, wherein the node data comprises: information node data, attribute node data and name node data;
filling the data of the dictionary structure into the newly-built table to obtain a test case file in a table format of a target table format;
the level number field corresponds to the level number of the element node, the type field corresponds to the attribute node data, the name field corresponds to the name node data, and the information field corresponds to the information node data.
4. The method of claim 1, wherein the target types include a test set type and a test case type, and the step of obtaining a test case file in a extensible markup language format from a test platform includes:
receiving selection input aiming at test cases and/or test sets in a test platform;
acquiring a test case file in an extensible markup language format from a test platform according to the selection input;
the step of determining the element node of the target type from the nodes of the tuple data comprises:
and determining element nodes of the test case type and/or the test set type from the nodes of the tuple data.
5. A document processing apparatus, comprising:
the acquisition module is used for acquiring the test case file in the extensible markup language format from the test platform;
the analysis module is used for acquiring the tuple data of the test case file, and the nodes in the tuple data are arranged according to a preset sequence;
a determining module, configured to determine an element node of a target type from nodes of the tuple data; the element node includes: a start element node and an end element node;
the numbering module is used for determining the level numbers corresponding to the element nodes according to the preset sequence;
The generation module is used for filling the level numbers corresponding to the element nodes and the included node data into a new table in a target table format to obtain a test case file in the target table format;
the receiving module is used for receiving a modification input instruction aiming at the test case file in the target table format;
the processing module is used for responding to the modification input instruction and modifying the test case file in the target table format;
the data in the test case file with the extensible markup language format is arranged according to a tree structure, and the numbering module comprises:
the first coding submodule is used for sequentially determining corresponding level marks of the element nodes in the tree structure according to the preset sequence;
the second coding submodule is used for determining a level number corresponding to the element node according to the corresponding level mark;
the first coding sub-module includes:
the tuple data comprises N element nodes, i is an integer, and i is more than or equal to 0 and less than or equal to N;
for the element nodes, determining the hierarchy mark corresponding to the Nth element node by sequentially passing through the subunits according to the preset sequence, wherein the subunits are in accordance with any one of the following conditions:
A first numbering subunit C1, configured to add an element to the level flag of the i-1 th element node and use the value of 1 as the level flag of the i-1 th element node when the i-1 th element node is the start element node and the level flag of the i-1 th element node is null, or 1, or the last two bits are sequentially 1 and 1;
a second numbering subunit C2, configured to add 1 to a last element value of the hierarchy mark of the i-1 th element node as the hierarchy mark of the i-1 th element node when the i-1 th element node is a start element node and the last two bits of the hierarchy mark of the i-1 th element node are sequentially 1 and 0;
a third numbering subunit C3, configured to change, when the i-th element node is an end element node, an element value of a last 1 in the hierarchical label of the i-1-th element node to 0, and then, when the last two bits of the modified hierarchical label of the i-1-th element node are not 0 and 0 in order, use the modified hierarchical label of the i-1-th element node as the hierarchical label of the i-th element node;
and a fourth numbering subunit C4, configured to change, when the i-th element node is an end element node, an element value of a last 1 in the hierarchical label of the i-1-th element node to 0, and then delete, when the last two bits of the modified i-1-th element node are 0 and 0 in order, a last element in the hierarchical label of the i-1-th element node as the hierarchical label of the i-th element node.
6. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the file processing method of any of claims 1 to 4 when the computer program is executed.
7. A computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, implements the file processing method of any of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010605432.0A CN111767223B (en) | 2020-06-29 | 2020-06-29 | File processing method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010605432.0A CN111767223B (en) | 2020-06-29 | 2020-06-29 | File processing method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111767223A CN111767223A (en) | 2020-10-13 |
CN111767223B true CN111767223B (en) | 2024-02-23 |
Family
ID=72724524
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010605432.0A Active CN111767223B (en) | 2020-06-29 | 2020-06-29 | File processing method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111767223B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112433954B (en) * | 2020-12-18 | 2023-03-31 | 西安联乘智能科技有限公司 | Method and device for analyzing, extracting and importing test case data |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104156342A (en) * | 2014-08-01 | 2014-11-19 | 福建星网视易信息***有限公司 | Method and device for converting Excel format testing case into XML (extensive markup language) format |
CN109614519A (en) * | 2018-12-07 | 2019-04-12 | 万兴科技股份有限公司 | Data lead-in method and data importing device |
KR102024275B1 (en) * | 2019-06-10 | 2019-09-23 | 한화시스템(주) | Test program development system and its method using script |
CN110597708A (en) * | 2019-08-02 | 2019-12-20 | 北京奇艺世纪科技有限公司 | Test case file conversion method and device, electronic equipment and storage medium |
CN111177074A (en) * | 2019-12-26 | 2020-05-19 | 广东飞企互联科技股份有限公司 | Xml to excel conversion method and system suitable for testlink |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6986101B2 (en) * | 1999-05-06 | 2006-01-10 | International Business Machines Corporation | Method and apparatus for converting programs and source code files written in a programming language to equivalent markup language files |
US20090248716A1 (en) * | 2008-03-31 | 2009-10-01 | Caterpillar Inc. | Hierarchy creation and management tool |
US9037549B2 (en) * | 2010-12-08 | 2015-05-19 | Infosys Limited | System and method for testing data at a data warehouse |
-
2020
- 2020-06-29 CN CN202010605432.0A patent/CN111767223B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104156342A (en) * | 2014-08-01 | 2014-11-19 | 福建星网视易信息***有限公司 | Method and device for converting Excel format testing case into XML (extensive markup language) format |
CN109614519A (en) * | 2018-12-07 | 2019-04-12 | 万兴科技股份有限公司 | Data lead-in method and data importing device |
KR102024275B1 (en) * | 2019-06-10 | 2019-09-23 | 한화시스템(주) | Test program development system and its method using script |
CN110597708A (en) * | 2019-08-02 | 2019-12-20 | 北京奇艺世纪科技有限公司 | Test case file conversion method and device, electronic equipment and storage medium |
CN111177074A (en) * | 2019-12-26 | 2020-05-19 | 广东飞企互联科技股份有限公司 | Xml to excel conversion method and system suitable for testlink |
Also Published As
Publication number | Publication date |
---|---|
CN111767223A (en) | 2020-10-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109614309B (en) | Method, device, computer equipment and storage medium for comparing test results | |
US11107028B2 (en) | Numerical graphical flow diagram conversion and comparison | |
CN108762808A (en) | The generation method and system of interface document | |
WO2016003904A1 (en) | Computerized systems and methods for converting data for storage in a graph database | |
CN110597708A (en) | Test case file conversion method and device, electronic equipment and storage medium | |
CN113485915A (en) | Automatic interface test data generation method and device based on protocol modeling and constraint coverage | |
CN111563199B (en) | Data processing method and device | |
CN111767223B (en) | File processing method and device, electronic equipment and storage medium | |
CN108388796B (en) | Dynamic domain name verification method, system, computer device and storage medium | |
CA3138761A1 (en) | Method, device, computer equipment and storage medium for verifying inter-system data admission | |
CN113095044A (en) | File conversion method, device and equipment | |
CN111078773A (en) | Data processing method and device | |
CN113127776A (en) | Breadcrumb path generation method and device and terminal equipment | |
US20240037325A1 (en) | Ability to add non-direct ancestor columns in child spreadsheets | |
CN113177391B (en) | Method for redirecting operation cursor in streaming interface, computing equipment and storage medium | |
JP6994138B2 (en) | Information management device and file management method | |
CN111736848B (en) | Packet conflict positioning method, device, electronic equipment and readable storage medium | |
CN111221610B (en) | Page element acquisition method and device | |
CN113536762A (en) | JSON text comparison method and device | |
Le Zou et al. | On synchronizing with web service evolution | |
CN107451167A (en) | The click data acquisition methods and system of position are clicked in standing | |
JP2011257877A (en) | Device and method for information retrieval, and program | |
CN112363757A (en) | Method, device and equipment for automatically generating data file and readable storage medium | |
CN109284292A (en) | A kind of generation method of mobile operation list generates system and relevant apparatus | |
CN111176640B (en) | Layout level display method, storage medium, device and system in Android engineering |
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 |