CN110941556A - Method for rapidly compiling test cases on Android platform - Google Patents

Method for rapidly compiling test cases on Android platform Download PDF

Info

Publication number
CN110941556A
CN110941556A CN201911177342.XA CN201911177342A CN110941556A CN 110941556 A CN110941556 A CN 110941556A CN 201911177342 A CN201911177342 A CN 201911177342A CN 110941556 A CN110941556 A CN 110941556A
Authority
CN
China
Prior art keywords
yaml
test case
case
file
page
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
CN201911177342.XA
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.)
Xiamen Meiya Pico Information Co Ltd
Original Assignee
Xiamen Meiya Pico Information 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 Xiamen Meiya Pico Information Co Ltd filed Critical Xiamen Meiya Pico Information Co Ltd
Priority to CN201911177342.XA priority Critical patent/CN110941556A/en
Publication of CN110941556A publication Critical patent/CN110941556A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

Abstract

The invention relates to a method for rapidly compiling test cases on an Android platform, which comprises the following steps: s1, an independent android element positioning module is used for redefining the positioning operation of all elements by using YAML language in a unified way; s2, abstracting all operation behaviors of the test case, and logically packaging the complex code into an independent operation class, namely an Action class; s3, compiling a Page file page.yaml to realize a Page Object mode, and completing code decoupling and multiplexing; s4, compiling a test case file case.yaml; s5, generating test case executable files xxx.py in batches from the test case file case.yaml through jinja2 template language; and S6, running the test case executable file xxx through pytest. By adopting the method, a user only needs to singly use the yaml language to compile the test case, so that inexperienced personnel can quickly compile and modify the test case, the actions of element positioning and test operation are unified, redundant codes are reduced, and the code operation is more stable and efficient.

Description

Method for rapidly compiling test cases on Android platform
Technical Field
The invention relates to an Android platform application technology, in particular to a method for rapidly compiling a test case on an Android platform.
Background
In the development of Android platforms, before a version is released each time, a round of automatic GUI test is carried out to ensure the stability of app.
As the project progresses and the use cases increase, the following pain points occur:
the positioning modes of the apium about the android elements are more, different developers use different positioning modes, and the maintenance cost is greatly increased;
when the number of pages and test cases is too many, redundant element positioning and repeated test cases can occur, and understanding and maintenance are difficult;
the duplicate configuration of appium and the duplicate code exist in each test case py file actually called by the pytest;
the writing standard and level of test codes of developers are different from person to person, and the maintenance cost is greatly increased;
the tester is familiar and comprehensive with the test flow, but has no programming knowledge and great difficulty in writing test codes.
Disclosure of Invention
The invention aims to provide a method for rapidly compiling test cases on an Android platform, so as to solve the problems. Therefore, the invention adopts the following specific technical scheme:
a method for rapidly compiling test cases on an Android platform can comprise the following steps:
s1, an independent android element positioning module is used for redefining the positioning operation of all elements by using YAML language in a unified way;
s2, abstracting all operation behaviors of the test case, and logically packaging the complex code into an independent operation class, namely an Action class;
s3, compiling a Page file page.yaml to realize a Page Object mode, and completing code decoupling and multiplexing;
s4, compiling a test case file case.yaml;
s5, generating test case executable files xxx.py in batches from the test case file case.yaml through jinja2 template language;
and S6, a Jenkins calling interface, and running the test case executable file xxx through pytest.
Further, the specific process of S5 is:
s51, traversing the yaml file under the read page directory, and loading the yaml file into a yaml object;
s52, analyzing the positioning element set and the operation object set in the yaml object, and generating a page positioning element set and a page operation object set;
s53, generating a Page object class according to the template by using jinja 2;
s54, traversing and generating all page object files my _ pages.
S55, traversing and reading the yaml file under the test case directory, and loading the yaml file as a yaml object;
s56, generating a test case operation according to the template by using jinja 2;
s57, traversing and generating all test case operation objects my _ cases;
and S58, traversing the project configuration file loaded with case _ info, and respectively generating different project pytest executable files xxx. py through a template by using jinja 2.
Further, the specific process of S6 is:
s61, automatically and sequentially running the test case functions test _ xxx () in the classes by pytest;
s62, the Action parses the yaml format case in the test case my _ cases through case _ run and translates the yaml format case into the specific operation Action in the Action.
Further, the yaml format may be replaced with the JSON format.
By adopting the technical scheme, the invention has the beneficial effects that:
1. a user only needs to singly use the yaml language to compile the test case, so that inexperienced personnel can quickly compile and modify the test case, the actions of element positioning and test operation are unified, redundant codes are reduced, and the code operation is more stable and efficient;
2. the method provides a Jenkins multi-process calling interface and supports multiple devices to simultaneously carry out multiple different test cases.
Drawings
To further illustrate the various embodiments, the invention provides the accompanying drawings. The accompanying drawings, which are incorporated in and constitute a part of this disclosure, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the embodiments. Those skilled in the art will appreciate still other possible embodiments and advantages of the present invention with reference to these figures. Elements in the figures are not drawn to scale and like reference numerals are generally used to indicate like elements.
FIG. 1 is a flow chart of the method of the present invention;
FIG. 2 is a flow chart of the method of the present invention for generating a pytest executable;
FIG. 3 is a flow chart of the Pytest execution test case of the method of the present invention.
Detailed Description
The invention will now be further described with reference to the accompanying drawings and detailed description.
The invention supports YAML, JSON and other data formats to rapidly compile test cases, and the test cases are introduced through the YAML data format. As shown in fig. 1, a method for implementing fast test case compiling on an Android platform may include the following steps:
s1, an independent android element positioning module is used for redefining the positioning operation of all elements by using YAML language in a unified way; the YAML language is an intuitive data serialization format that can be recognized by a computer, has high readability and is easily read by a human, and is easily interacted with a scripting language to express a material sequence.
S2, abstracting all operation behaviors of the test case, and logically packaging the complex code into an independent operation class, namely an Action class;
s3, compiling a Page file page.yaml to realize a Page Object mode, and completing code decoupling and multiplexing; the Page Object mode is that the Page Object encapsulates a test Object and a single test step in each Page Object, and is managed by taking a Page as a unit. An example code for page.yaml is as follows:
Figure BDA0002290313440000041
Figure BDA0002290313440000051
s4, compiling a test case file case.yaml; specifically, a single test case may be quickly written using the YAML language, with the code for one instance as follows:
Figure BDA0002290313440000052
and writing a test case set to be run by the corresponding item by using the YAML language, wherein the code of one example is as follows:
Figure BDA0002290313440000061
s5, generating test case executable files xxx.py in batches from the test case file case.yaml through jinja2 template language; an example code for the template is as follows:
Figure BDA0002290313440000062
py an example code of the test case executable file xxx.py is as follows:
Figure BDA0002290313440000063
Figure BDA0002290313440000071
the specific flow is shown in fig. 2, and may include the following processes:
s51, traversing the yaml file under the read page directory, and loading the yaml file into a yaml object;
s52, analyzing the positioning element set and the operation object set in the yaml object, and generating a page positioning element set and a page operation object set;
s53, generating a Page object class according to the template by using jinja 2;
s54, traversing and generating all page object files my _ pages. One example code for this is as follows:
Figure BDA0002290313440000072
s55, traversing and reading the yaml file under the test case directory, and loading the yaml file as a yaml object;
s56, generating a test case operation according to the template by using jinja 2;
s57, traversing and generating all test case operation objects my _ cases; one example code for this is as follows:
ai_retrieval_case=get_case('ai_retrieval_case')
ai_retrieval_datacenter_result_case=get_case('ai_retrieval_datacenter_result_case')
ai_retrieval_hit_android_case=get_case('ai_retrieval_hit_android_case')
s58, traversing the project configuration file loaded with case _ info, and respectively generating different project pytest executable files xxx.py through a template by using jinja 2; one example code for this is as follows:
Figure BDA0002290313440000081
and S6, a Jenkins calling interface, and running a test case executable file xxx. py through pytest, wherein an example code is as follows:
python:\Project\2015_Lemon\Mango\autotest\MangoScript\GuiTest\main.pycreate_case;
python \ Project \2015_ Lemon \ logo \ autotest \ MangoScript \ GuiTest \ main.
The specific flow is shown in fig. 3, and may include the following processes:
s61, automatically and sequentially running the test case functions test _ xxx () in the classes by pytest;
s62, the Action parses the yaml format case in the test case my _ cases through the case _ run, and translates the yaml format case into a specific operation Action in the Action, that is, the test case object in my _ cases is parsed and translated into the actually running code through the packaged Action class.
The method of the invention has the following technical effects:
1. the user only needs to use the yaml language alone to compile the test case for inexperienced personnel can compile and modify the test case fast, has unified the action of element location and test operation simultaneously, reduces redundant code, makes the code operation more stable and high-efficient.
2. The method provides a Jenkins multi-process calling interface and supports multiple devices to simultaneously carry out multiple different test cases. With the technical scheme of the invention, the low-workload maintenance of the test cases can be ensured under the condition that more and more test cases are used, so that more time is concentrated on research and development by developers, and meanwhile, the simple programmable test cases for the testers are provided, thereby greatly shortening the release time of the versions and improving the stability of the versions.
While the invention has been particularly shown and described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (4)

1. A method for rapidly compiling test cases on an Android platform is characterized by comprising the following steps:
s1, an independent android element positioning module is used for redefining the positioning operation of all elements by using YAML language in a unified way;
s2, abstracting all operation behaviors of the test case, and logically packaging the complex code into an independent operation class, namely an Action class;
s3, compiling a Page file page.yaml to realize a Page Object mode, and completing code decoupling and multiplexing;
s4, compiling a test case file case.yaml;
s5, generating test case executable files xxx.py in batches from the test case file case.yaml through jinja2 template language;
and S6, running the test case executable file xxx through pytest.
2. The method of claim 1, wherein the specific process of S5 is:
s51, traversing the yaml file under the read page directory, and loading the yaml file into a yaml object;
s52, analyzing the positioning element set and the operation object set in the yaml object, and generating a page positioning element set and a page operation object set;
s53, generating a Page object class according to the template by using jinja 2;
s54, traversing and generating all page object files my _ pages.
S55, traversing and reading the yaml file under the test case directory, and loading the yaml file as a yaml object;
s56, generating a test case operation according to the template by using jinja 2;
s57, traversing and generating all test case operation objects my _ cases;
and S58, traversing the project configuration file loaded with case _ info, and respectively generating different project pytest executable files xxx. py through a template by using jinja 2.
3. The method of claim 2, wherein the specific process of S6 is:
s61, automatically and sequentially running the test case functions test _ xxx () in the classes by pytest;
s62, the Action parses the yaml format case in the test case my _ cases through case _ run and translates the yaml format case into the specific operation Action in the Action.
4. A method according to any one of claims 1 to 3, wherein the yaml format is substituted for the JSON format.
CN201911177342.XA 2019-11-27 2019-11-27 Method for rapidly compiling test cases on Android platform Pending CN110941556A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911177342.XA CN110941556A (en) 2019-11-27 2019-11-27 Method for rapidly compiling test cases on Android platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911177342.XA CN110941556A (en) 2019-11-27 2019-11-27 Method for rapidly compiling test cases on Android platform

Publications (1)

Publication Number Publication Date
CN110941556A true CN110941556A (en) 2020-03-31

Family

ID=69908950

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911177342.XA Pending CN110941556A (en) 2019-11-27 2019-11-27 Method for rapidly compiling test cases on Android platform

Country Status (1)

Country Link
CN (1) CN110941556A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111639036A (en) * 2020-06-08 2020-09-08 成都信息工程大学 Continuous integration test development method and system based on AI test
CN112256569A (en) * 2020-10-16 2021-01-22 四川长虹电器股份有限公司 Automatic testing method for simultaneous operation of multiple mobile phones based on apium + python
CN112506769A (en) * 2020-12-04 2021-03-16 数字广东网络建设有限公司 Interface document-based request body generation method and device and computer equipment
CN113791968A (en) * 2021-08-10 2021-12-14 武汉光庭信息技术股份有限公司 UI automation test method, system, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150277899A1 (en) * 2014-03-27 2015-10-01 Microsoft Corporation Hierarchical directives-based management of runtime behaviors
CN107562626A (en) * 2017-08-31 2018-01-09 国家电网公司 A kind of method that encapsulation Selenium and Sikuli realizes Web automatic tests

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150277899A1 (en) * 2014-03-27 2015-10-01 Microsoft Corporation Hierarchical directives-based management of runtime behaviors
CN107562626A (en) * 2017-08-31 2018-01-09 国家电网公司 A kind of method that encapsulation Selenium and Sikuli realizes Web automatic tests

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
ZOUHUI: "基于python+appium+yaml安卓UI自动化测试分享", 《公开网址:HTTPS://WWW.CNBLOGS.COM/FINER/P/8434062.HTML》 *
徐彩霞等: "面向CLI的自动化测试方法的研究与实现", 《计算机与数字工程》 *
悠悠: "appium+python自动化49-yaml管理定位元素", 《公开网址:HTTPS://WWW.CNBLOGS.COM/YOYOKETANG/P/9037558.HTML》 *
悠悠: "appium+python自动化50-生成定位对象模板templet(jinja2)", 《公开网址:HTTPS://WWW.CNBLOGS.COM/YOYOKETANG/P/9047821.HTML》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111639036A (en) * 2020-06-08 2020-09-08 成都信息工程大学 Continuous integration test development method and system based on AI test
CN112256569A (en) * 2020-10-16 2021-01-22 四川长虹电器股份有限公司 Automatic testing method for simultaneous operation of multiple mobile phones based on apium + python
CN112506769A (en) * 2020-12-04 2021-03-16 数字广东网络建设有限公司 Interface document-based request body generation method and device and computer equipment
CN113791968A (en) * 2021-08-10 2021-12-14 武汉光庭信息技术股份有限公司 UI automation test method, system, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110941556A (en) Method for rapidly compiling test cases on Android platform
Fazzini et al. Barista: A technique for recording, encoding, and running platform independent android tests
KR101699981B1 (en) Memory optimization of virtual machine code by partitioning extraneous information
US20160342397A1 (en) Adaptive selection of programming language versions for compilation of software programs
CN106775744B (en) Method and device for generating static library
CN107832059B (en) Code static analysis method and device based on Makefile
CN111459495B (en) Unit test code file generation method, electronic device and storage medium
CN109902005B (en) Automatic testing method and system
US20140298290A1 (en) Identification of code changes using language syntax and changeset data
CN108762805A (en) A kind of Hybrid Development Frameworks and frame design method based on Cordova and Typescript
CN111459499A (en) Program compiling method and device, computer storage medium and electronic equipment
CN111740948A (en) Data packet issuing method, dynamic updating method, device, equipment and medium
CN107688456B (en) File generation method, device and computer readable storage medium
CN111190791A (en) Application exception reporting method and device and electronic equipment
CN100361075C (en) Method and device for quickly developing embedded system using automatic compilation frame
CN111352631B (en) Interface compatibility detection method and device
CN109739756B (en) Method and equipment for testing application of mobile terminal
US9405739B1 (en) Source code format for IDE code development with embedded objects
CN112953721B (en) IPA file analysis method, IPA file analysis device, IPA file analysis equipment and storage medium
US9575878B2 (en) Data-driven testing without data configuration
CN113672465A (en) Method, system, medium, terminal and unmanned aerial vehicle for generating process log system by process name
CN114003257A (en) Upgrading method and device
Ament Arquillian Testing Guide
CN112631894A (en) Code detection method, device, storage medium and computer equipment
CN112181550A (en) UI multi-language conversion method and system for smart television operating system

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200331

RJ01 Rejection of invention patent application after publication