+

CN112463611A - Test report generation method and device based on HTML5 and storage medium - Google Patents

Test report generation method and device based on HTML5 and storage medium Download PDF

Info

Publication number
CN112463611A
CN112463611A CN202011387549.2A CN202011387549A CN112463611A CN 112463611 A CN112463611 A CN 112463611A CN 202011387549 A CN202011387549 A CN 202011387549A CN 112463611 A CN112463611 A CN 112463611A
Authority
CN
China
Prior art keywords
test
html5
data
template
report
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011387549.2A
Other languages
Chinese (zh)
Inventor
唐涛
陈龙
洪飞龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Lango Electronic Science and Technology Co Ltd
Original Assignee
Guangzhou Lango Electronic Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Lango Electronic Science and Technology Co Ltd filed Critical Guangzhou Lango Electronic Science and Technology Co Ltd
Priority to CN202011387549.2A priority Critical patent/CN112463611A/en
Publication of CN112463611A publication Critical patent/CN112463611A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Document Processing Apparatus (AREA)

Abstract

本发明提供一种基于HTML5的测试报告生成方法、装置及存储介质,其中方法包括:测试数据解析器接收测试框架的测试数据,将测试数据处理成测试报告生成器能读取和操作的字典类型的数据结构体;将数据结构体中的数据填入预先设置好的HTML5模板中,生成一个后缀为.html的单一的HTML5静态文件的测试报告。基于本发明的方法和装置生成的报告,其可读性和数据结构都可兼顾,并且美观,可以通过修改模板的样式和格式来自定义模板的展示效果,不影响测试数据的结构。

Figure 202011387549

The present invention provides a method, device and storage medium for generating a test report based on HTML5, wherein the method includes: a test data parser receives test data of a test framework, and processes the test data into a dictionary type that the test report generator can read and operate The data structure of the data structure; the data in the data structure is filled into the pre-set HTML5 template, and a test report of a single HTML5 static file with the suffix .html is generated. The report generated based on the method and device of the present invention has both readability and data structure, and is beautiful, and the display effect of the template can be customized by modifying the style and format of the template, without affecting the structure of the test data.

Figure 202011387549

Description

Test report generation method and device based on HTML5 and storage medium
Technical Field
The invention relates to the technical field of android system testing, in particular to a test report generation method and device based on HTML5 and a storage medium.
Background
Currently, testing of android systems requires the use of test frameworks, such as the Robotium test framework, the Appium test framework. After the android system is tested by using the testing framework, a testing report can be automatically generated. The test reports of the current test framework are all output in a program-friendly form such as xml, but the readability is poor. Because of the test report in the xml format, only the text information is available, and the modification actions for assisting reading, such as chart output, text thickening and highlighting, and the like, cannot be performed. So that the test report cannot express the test content and the test result more flexibly and intuitively.
Disclosure of Invention
The invention aims to provide a test report generation method, a test report generation device and a storage medium based on HTML5, which can solve the problem that in the prior art, a test report output in an xml format only has character information and cannot output modification actions such as a chart and the like.
The purpose of the invention is realized by the following technical scheme:
in a first aspect, the present invention provides a test report generation method based on HTML5, including the following steps:
step 1, a test data parser receives test data of a test framework, and the test data is processed into a dictionary type data structure body which can be read and operated by a test report generator;
and 2, filling the data in the data structure into a preset HTML5 template to generate a HTML test report of a single HTML5 static file.
Furthermore, the data in the data structure is filled into the preset HTML5 template, and the render output is realized by calling the render _ template method of jinja 2.
Further, the process of calling render _ template method of jinja2 to realize rendering output includes:
acquiring template text content;
replacing data in the data structure body analyzed by the test data analyzer to a position corresponding to the template;
generating complete text content;
saved as an HTML5 file.
Further, the test report generation method based on the HTML5 further comprises the steps of generating an HTML5 template:
reporting the key information by using the element layout of HTML, then performing style description on the reporting key information by using CSS, and finally realizing interactive logic by using js.
Further, the report key information includes report summary information and detailed case test data.
Further, the report summary information includes, but is not limited to, a name of a use case, a total number of use cases, a number of pass cases, a number of fail cases, a number of skip cases, a start time, a test time, and a percentage pie chart of a result of a use case.
Further, the detailed use case test data includes, but is not limited to, use case ID, test type, test method, use case description, run time, test result, and view log.
In a second aspect, the present invention provides a test report generating apparatus based on HTML5, including a storage module, a test data parser, and a test report generator, wherein:
the storage module is used for storing an HTML5 template;
the test data parser is used for receiving the test data of the test framework and then processing the test data into a dictionary type data structure body which can be read and operated by the test report generator;
and the test report generator is used for filling the data in the analyzed data structure into a preset HTML5 template to generate a test report of a single HTML5 static file with a suffix of HTML.
In a third aspect, the present invention provides a storage medium having a computer program stored therein, wherein the computer program is operable to execute the test report generation method based on HTML 5.
According to the test report generation method, device and storage medium based on the HTML5, readability and data structure of the output report can be both considered, attractiveness is achieved, the display effect of the template can be defined by modifying the style and format of the template, and the structure of the test data is not affected.
Drawings
FIG. 1 is a diagram of steps of a test report generation method based on HTML 5;
FIG. 2 is a schematic structural diagram of an HTML 5-based test report generation apparatus according to the present invention;
FIG. 3 is a sample HTML5 template of the present invention.
Detailed Description
The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
The embodiments of the present disclosure are described below with specific examples, and other advantages and effects of the present disclosure will be readily apparent to those skilled in the art from the disclosure in the specification. It is to be understood that the described embodiments are merely illustrative of some, and not restrictive, of the embodiments of the disclosure. The disclosure may be embodied or carried out in various other specific embodiments, and various modifications and changes may be made in the details within the description without departing from the spirit of the disclosure. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
The invention discloses a test report generation method based on HTML5, which comprises the following steps:
step 1, a test data parser receives test data of a test framework, and then the test data is processed into a data structure body which can be read and operated by a test report generator, and the structure body is realized by using dictionary types.
The dictionary type is a built-in data type in the Python language. The dictionary in Python is composed of key (key) value (value) pairs, wherein keys and values are separated by colons, different groups of key value pairs are divided by commas, the whole dictionary is wrapped by { }, and the dictionary is unordered, and we can obtain the value of value by key. For example, a dictionary with values of dit 1 { 'apple' 8, 'banana' 3, 'peach' 5 }.
Test frameworks such as Python unitest and Python test, etc., the test data of which is the data of the Python object.
And 2, filling the data in the data structure into a preset HTML5 template to generate a HTML test report of a single HTML5 static file.
Filling data in the data structure into an HTML5 template, and mainly calling a render _ template method of jinja2 to realize rendering output, wherein the process comprises the following steps:
acquiring template text content;
replacing data in the data structure body analyzed by the test data analyzer to a position corresponding to the template;
generating complete text content;
saved as an HTML5 file.
Jinja2 is a python-based template engine. The generated test report can be directly opened and viewed by using a browser or put on a web server for external presentation. render _ template is one of the template rendering functions within the flash itself.
Further, the test report generation method based on the HTML5 of the present invention further includes the step of generating an HTML5 template:
reporting the key information by using the element layout of HTML, then performing style description on the reporting key information by using CSS, and finally realizing interactive logic by using js. Interaction logic such as pie chart drawing and viewing, log viewing interactions, and the like.
The report key information comprises report summary information and detailed case test data. The report summary information includes, but is not limited to, a case name, a total number of cases, a number of passed cases, a number of failed cases, a number of skipped cases, a start time, a test time, and a percentage pie chart of case results. The detailed case test data includes, but is not limited to, case ID, test type, test method, case description, run time, test result, and view log.
The invention discloses a test report generating device based on HTML5, which comprises a storage module, a test data parser and a test report generator, wherein:
and the storage module is used for storing the HTML5 template.
The HTML5 template is preset in a storage module. Fig. 3 is an example of an HTML5 template, which should not be construed as limiting the HTML5 template, and the HTML5 template may be in other forms, which are specifically set according to the user's needs.
And the test data parser is used for receiving the test data of the test framework and then processing the test data into a data structure body which can be read and operated by the test report generator.
And the test report generator is used for filling the data in the analyzed data structure into a preset HTML5 template to generate a test report of a single HTML5 static file with a suffix of HTML.
A storage medium having a computer program stored therein, the computer program being executable to perform the method of:
step 1, a test data parser receives test data of a test framework, and the test data is processed into a dictionary type data structure body which can be read and operated by a test report generator;
and 2, filling the data in the data structure into a preset HTML5 template to generate a HTML test report of a single HTML5 static file.
Further, in a preferred embodiment of the present application, the data in the data structure is filled into a preset HTML5 template, and a render _ template method of jinja2 is called to implement rendering output.
Further, in a preferred embodiment of the present application, the process of calling render _ template method of jinja2 to implement rendering output includes:
acquiring template text content;
replacing data in the data structure body analyzed by the test data analyzer to a position corresponding to the template;
generating complete text content;
saved as an HTML5 file.
Preferably, the test report generation method based on HTML5 of the present invention further includes the step of generating an HTML5 template: reporting the key information by using the element layout of HTML, then performing style description on the reporting key information by using CSS, and finally realizing interactive logic by using js.
In the present invention, unless otherwise expressly stated or limited, the terms "mounted," "connected," "secured," and the like are to be construed broadly and can, for example, be fixedly connected, detachably connected, or integrally formed; may be mechanically coupled, may be electrically coupled or may be in communication with each other; they may be directly connected or indirectly connected through intervening media, or they may be connected internally or in any other suitable relationship, unless expressly stated otherwise. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
The above description is for the purpose of illustrating embodiments of the invention and is not intended to limit the invention, and it will be apparent to those skilled in the art that any modification, equivalent replacement, or improvement made without departing from the spirit and principle of the invention shall fall within the protection scope of the invention.

Claims (9)

1.基于HTML5的测试报告生成方法,其特征在于,包括以下步骤:1. a test report generation method based on HTML5, is characterized in that, comprises the following steps: 步骤1、测试数据解析器接收测试框架的测试数据,将测试数据处理成测试报告生成器能读取和操作的字典类型的数据结构体;Step 1. The test data parser receives the test data of the test framework, and processes the test data into a dictionary-type data structure that the test report generator can read and operate; 步骤2、将数据结构体中的数据填入预先设置好的HTML5模板中,生成一个后缀为.html的单一的HTML5静态文件的测试报告。Step 2: Fill the data in the data structure into the pre-set HTML5 template, and generate a test report of a single HTML5 static file with a suffix of .html. 2.根据权利要求1所述的基于HTML5的测试报告生成方法,其特征在于,所述的将数据结构体中的数据填入预先设置好的HTML5模板中,是调用jinja2的render_template方法实现渲染输出的。2. the test report generation method based on HTML5 according to claim 1 is characterized in that, the described data in the data structure is filled in the HTML5 template set in advance, is to call the render_template method of jinja2 to realize rendering output of. 3.根据权利要求2所述的基于HTML5的测试报告生成方法,其特征在于,所述的调用jinja2的render_template方法实现渲染输出的过程包括:3. the test report generation method based on HTML5 according to claim 2 is characterized in that, the described render_template method of calling jinja2 realizes that the process of rendering output comprises: 获取模板文本内容;Get the template text content; 将测试数据解析器解析的数据结构体中的数据替换到模板对应的位置;Replace the data in the data structure parsed by the test data parser to the corresponding position of the template; 生成完整的文本内容;Generate complete text content; 保存为HTML5文件。Save as HTML5 file. 4.根据权利要求1所述的基于HTML5的测试报告生成方法,其特征在于,还包括生成HTML5模板的步骤:4. the test report generation method based on HTML5 according to claim 1, is characterized in that, also comprises the step of generating HTML5 template: 使用HTML的元素布局报告关键信息,然后使用CSS对报告关键信息进行样式描述,最后使用js实现交互逻辑。Use HTML element layout to report key information, then use CSS to style the report key information, and finally use js to implement interactive logic. 5.根据权利要求4所述的基于HTML5的测试报告生成方法,其特征在于,所述的报告关键信息包括报告汇总信息和详细用例测试数据。5. The method for generating a test report based on HTML5 according to claim 4, wherein the key information of the report comprises report summary information and detailed use case test data. 6.根据权利要求5所述的基于HTML5的测试报告生成方法,其特征在于,所述的报告汇总信息包括但不限于用例名称、用例总数、用例通过数、用例失败数、用例跳过数、开始时间、测试时间、用例结果百分饼图。6. The method for generating a test report based on HTML5 according to claim 5, wherein the report summary information includes but is not limited to the name of the use case, the total number of the use case, the number of passed use cases, the number of failed use cases, the number of use cases skipped, Start time, test time, percentile pie chart of use case results. 7.根据权利要求5所述的基于HTML5的测试报告生成方法,其特征在于,所述的详细用例测试数据包括但不限于用例ID、测试类型、测试方法、用例描述、运行时长、测试结果、查看日志。7. The test report generation method based on HTML5 according to claim 5, is characterized in that, described detailed use case test data includes but not limited to use case ID, test type, test method, use case description, running time, test result, View logs. 8.基于HTML5的测试报告生成装置,其特征在于,包括存储模块、测试数据解析器和测试报告生成器,其中:8. test report generation device based on HTML5, is characterized in that, comprises storage module, test data parser and test report generator, wherein: 存储模块,用于存储HTML5模板;Storage module for storing HTML5 templates; 测试数据解析器,用于接收测试框架的测试数据,然后处理成测试报告生成器能读取和操作的字典类型的数据结构体;The test data parser is used to receive the test data of the test framework, and then process it into a dictionary-type data structure that the test report generator can read and operate; 测试报告生成器,用于将解析的数据结构体中的数据填入预先设置好的HTML5模板中,生成一个后缀为.html的单一的HTML5静态文件的测试报告。The test report generator is used to fill the data in the parsed data structure into the pre-set HTML5 template, and generate a test report of a single HTML5 static file with a suffix of .html. 9.一种存储介质,所述存储介质中存储有计算机程序,其特征在于,运行所述计算机程序,能执行权利要求1至7任一项所述的基于HTML5的测试报告生成方法。9 . A storage medium, wherein a computer program is stored in the storage medium, wherein running the computer program can execute the HTML5-based test report generation method according to any one of claims 1 to 7 .
CN202011387549.2A 2020-12-01 2020-12-01 Test report generation method and device based on HTML5 and storage medium Pending CN112463611A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011387549.2A CN112463611A (en) 2020-12-01 2020-12-01 Test report generation method and device based on HTML5 and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011387549.2A CN112463611A (en) 2020-12-01 2020-12-01 Test report generation method and device based on HTML5 and storage medium

Publications (1)

Publication Number Publication Date
CN112463611A true CN112463611A (en) 2021-03-09

Family

ID=74806736

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011387549.2A Pending CN112463611A (en) 2020-12-01 2020-12-01 Test report generation method and device based on HTML5 and storage medium

Country Status (1)

Country Link
CN (1) CN112463611A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113110998A (en) * 2021-04-23 2021-07-13 中国邮政储蓄银行股份有限公司 Interface test report generation method and generation device
CN117827652A (en) * 2023-12-21 2024-04-05 陕西法士特汽车传动集团有限责任公司 A method and system for automatically writing data into a custom template

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040205562A1 (en) * 2001-12-27 2004-10-14 G.E. Information Services, Inc. System and method for transforming documents to and from an XML format
CN102695187A (en) * 2012-06-01 2012-09-26 重庆邮电大学 Distributed Web-based device and method for testing 6LoWPAN protocol consistency
CN110032720A (en) * 2018-12-28 2019-07-19 万康源(天津)基因科技有限公司 A kind of visualization report typesetting and automatic generation method and system based on XML
CN111858354A (en) * 2020-07-23 2020-10-30 远光软件股份有限公司 Method, device, storage medium and electronic device for automatically generating test report

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040205562A1 (en) * 2001-12-27 2004-10-14 G.E. Information Services, Inc. System and method for transforming documents to and from an XML format
CN102695187A (en) * 2012-06-01 2012-09-26 重庆邮电大学 Distributed Web-based device and method for testing 6LoWPAN protocol consistency
CN110032720A (en) * 2018-12-28 2019-07-19 万康源(天津)基因科技有限公司 A kind of visualization report typesetting and automatic generation method and system based on XML
CN111858354A (en) * 2020-07-23 2020-10-30 远光软件股份有限公司 Method, device, storage medium and electronic device for automatically generating test report

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ALICE1: "其他-如何使用 Flask/Jinja2 将 Python 字典放入 HTML 模板中", 《HTTP://NUOMIPHP.COM/A/STACKOVERFLOW/ZH/637A877F88CF5A56EA1BDF1B.HTML》, pages 1 - 2 *
小顾问: "java使用dom4j和XPath解析XML与.net 操作XML小结", 《HTTP://CNBLOGS.COM/PANJUN-DONET/ARCHIVE/2009/07/17/1525432.HTML》, pages 1 - 15 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113110998A (en) * 2021-04-23 2021-07-13 中国邮政储蓄银行股份有限公司 Interface test report generation method and generation device
CN117827652A (en) * 2023-12-21 2024-04-05 陕西法士特汽车传动集团有限责任公司 A method and system for automatically writing data into a custom template

Similar Documents

Publication Publication Date Title
CN109739478B (en) Front-end project automatic construction method and device, storage medium and electronic equipment
US7840851B2 (en) Annotating GUI test automation playback and debugging
CN106502896B (en) A kind of generation method and device of function test code
US8898523B2 (en) Generating imperative test tasks from declarative test instructions
CN106980508A (en) Method and apparatus for generating the page
CN110609681A (en) System, method, device and medium for generating WEB application by visual configuration
CN110196733A (en) A kind of default API document structure tree method, apparatus, equipment and storage medium
CN108762805A (en) A kind of Hybrid Development Frameworks and frame design method based on Cordova and Typescript
CN112463611A (en) Test report generation method and device based on HTML5 and storage medium
CN114816391B (en) A component rendering method and device
CN107506190A (en) XML file amending method and device based on Spring frameworks
CN118796180A (en) A method, device, equipment and medium for automatically generating code
CN113885841A (en) Script generation method and device, electronic equipment and readable medium
CN113568709B (en) Courseware operation method, configuration method, device, electronic device and storage medium
CN112799670B (en) Method and system for unified multi-terminal logic development
CN112000416B (en) Card view generation method, device and computer readable storage medium
US9104573B1 (en) Providing relevant diagnostic information using ontology rules
CN102637290B (en) Operating system based on browser and compiling method
CN118503142A (en) Test case modification method, device, storage medium and program product
CN117707982A (en) Test method, apparatus, device, medium and program product
Ge et al. Advancing vision-language models in front-end development via data synthesis
US20240321412A1 (en) Synthetic data set generation of chemical illustrations
CN107885648A (en) A kind of method and apparatus for generating test report
CN116599864A (en) Communication test system, method, device and storage medium for automatic interface generation and use case modular development
CN112783495B (en) Page event management method, device, medium and electronic equipment

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
CB02 Change of applicant information

Address after: Room 238, room 406, No.1, Yichuang street, Huangpu District, Guangzhou, Guangdong 510000

Applicant after: Guangzhou langguo Electronic Technology Co.,Ltd.

Address before: Room 238, room 406, No.1, Yichuang street, Huangpu District, Guangzhou, Guangdong 510000

Applicant before: GUANGZHOU LANGO ELECTRONIC SCIENCE & TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
RJ01 Rejection of invention patent application after publication

Application publication date: 20210309

RJ01 Rejection of invention patent application after publication
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载