[go: up one dir, main page]

CN113076247A - Method and system for managing and running test script - Google Patents

Method and system for managing and running test script Download PDF

Info

Publication number
CN113076247A
CN113076247A CN202110365687.9A CN202110365687A CN113076247A CN 113076247 A CN113076247 A CN 113076247A CN 202110365687 A CN202110365687 A CN 202110365687A CN 113076247 A CN113076247 A CN 113076247A
Authority
CN
China
Prior art keywords
script
control
class
running
name
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110365687.9A
Other languages
Chinese (zh)
Other versions
CN113076247B (en
Inventor
郑永波
范渊
吴永越
郑学新
刘韬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu DBAPPSecurity Co Ltd
Original Assignee
Chengdu DBAPPSecurity 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 Chengdu DBAPPSecurity Co Ltd filed Critical Chengdu DBAPPSecurity Co Ltd
Priority to CN202110365687.9A priority Critical patent/CN113076247B/en
Publication of CN113076247A publication Critical patent/CN113076247A/en
Application granted granted Critical
Publication of CN113076247B publication Critical patent/CN113076247B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a system for managing and running a test script. The invention is realized by a plug-in development interface provided by Pycharm; defining a script format: the script is a Python file and comprises a plurality of classes, each class is a test case, and each test case comprises three functions of environment configuration, formal script content and environment cleaning configuration; and importing the script into Pycharm, identifying key words of class names and function names in the script, generating corresponding controls in a directory tree, and realizing freely-combined running of use cases, or running of single functions by checking and selecting the controls. The invention defines the script, is convenient to operate and manage the specific script, is not limited by an automation framework, and improves the execution efficiency and the accuracy.

Description

Method and system for managing and running test script
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a method and a system for managing and running a test script.
Background
Python is a mainstream automated testing script language at present, PyCharm is a mainstream Python integrated development environment, the PyCharm has very powerful functions in Python development and debugging at present, but only the developed Python automated script is used as a common Python file for processing, when a certain Python script needs to be run, a right key corresponding to the script can be found in a directory tree for running, but when all or part of the scripts are run under one folder, only one Python script can be rewritten to call the developed scripts in sequence (the current mainstream automated framework is the same), or one right key runs, which is obviously inefficient, and no way for organizing and running the automated testing script is provided.
At present, PyCharm can only operate a single Python script under a folder, when a part of or all scripts under one folder need to be operated, only one right key can be operated, or one PyCharm script is rewritten to be called in sequence, and the PyCharm script cannot be freely organized and operated. The invention aims to freely select and run an automatic script, simultaneously, the unified script format is convenient for script management and maintenance, and the plug-in can be expanded to other similar IDE, such as eclipse, vscode and the like.
The invention realizes that when the written script is imported into PyCharm, the corresponding control is generated in the directory tree by adopting the plug-in to identify the keywords (class name and function name) in the script, the free combination operation of the use case is realized by checking and selecting the control, and the single use case or the single function (such as cleaning configuration) in the use case can be operated, thereby facilitating the debugging, organizing and operating the script use case.
Disclosure of Invention
The invention aims to provide a method for managing and running test scripts, which is convenient for running and managing specific scripts by defining the scripts without being limited by an automation framework, and effectively improves the execution efficiency and the accuracy.
The invention also aims to provide a system for managing and running the test scripts, which aims to solve the problems and realize the quick running of all or part of the scripts under one folder.
The invention is mainly realized by the following technical scheme: the method for managing and running the test script is realized through a plug-in development interface provided by Pycharm; defining a script format: the script is a Python file and comprises a plurality of classes, each class is a test case, and each test case comprises three functions of environment configuration, formal script content and environment cleaning configuration; and importing the script into Pycharm, identifying key words of class names and function names in the script, generating corresponding controls in a directory tree, and realizing freely-combined running of use cases, or running of single functions by checking and selecting the controls.
In order to better implement the invention, further, when the class name in the script is identified, a control with the same name as the class name is generated, and the right key is implemented through the control to operate the test case defined by the class name.
In order to better realize the invention, further, when a function defined by a function name keyword exists in the identification script, a control with the same function name is generated, and the corresponding test step is independently operated by checking the right key of the control.
In order to better realize the invention, any one or more functions of run, debug, del and copy are further associated to the corresponding control, the right key displays the corresponding option, and the operation is realized according to the checking and selecting of the control.
In order to better implement the invention, the method mainly comprises the following steps:
step S100: traversing newly added contents of the script in real time, detecting a class name and a function name of a keyword in the script, and generating a corresponding control in a directory tree according to the class name and the function name;
step S200: when the control is selected, the corresponding field is 1, otherwise, the corresponding field is 0;
step S300: and associating any one or more functions of run, debug, del and copy to the corresponding control, displaying the corresponding option by the right key, and realizing corresponding operation according to whether the control is checked or not.
The invention is mainly realized by the following technical scheme: the system for managing and running the test script comprises a dynamic detection and control generation module, a control state recording module and a control association module; defining a script format: the script is a Python file and comprises a plurality of classes, each class is a test case, and each test case comprises three functions of environment configuration, formal script content and environment cleaning configuration; the method comprises the steps that a script is led into Pycharm, the dynamic detection and control generation module is used for traversing newly added content of the script in real time, detecting key word class names and function names in the script and generating corresponding controls in a directory tree according to the class names and the function names; when the control is selected, the corresponding field in the control state recording module is 1, otherwise, the corresponding field is 0; the control association module is used for associating any one or more functions of run, debug, del and copy to the corresponding control, realizing the display of the corresponding option by a right key and realizing the corresponding operation according to the checking of the control.
PyCharm is a Python development tool made by jetbranches that can be used to write, debug and run Python code.
Python is a lightweight programming language and is widely used for development of automated test scripts.
testsit test suite, a test suite contains a plurality of test cases (testcase).
the testcase test case comprises a plurality of steps.
Test step is the test procedure.
class defines the key of a class.
def defines the key of a function.
The invention has the beneficial effects that:
(1) the invention defines the format of Python script, one class is a test case, and three functions in the class correspond to three big steps: environment configuration, script text and environment clearing are beneficial to script management and maintenance.
(2) The method and the device automatically generate the traceable foldable control according to the keywords (class \ def) in the script, are convenient to operate and manage the specific script, are not limited by an automation frame, do not need to operate one right key during batch operation, and improve the execution efficiency and the accuracy.
(3) The invention is convenient for management and maintenance work when the large-scale project script is huge in quantity, and testers can quickly position the script of a certain functional module (generally, scripts with the same function are all under one testsutit) through the control names, thereby facilitating development and testing of the script. The scripts of which functional modules can be freely selected to run, and when full-function testing is not needed, other modules can be folded, and independent testing can be performed on a change point without changing any script.
Drawings
FIG. 1 is a schematic diagram of a directory tree before plug-in optimization;
FIG. 2 is a diagram of a directory tree after plug-in optimization;
FIG. 3 is a schematic diagram of a directory tree before optimization of plug-in example 5;
FIG. 4 is a schematic diagram of a directory tree after plug-in optimization in example 5;
FIG. 5 is a diagram illustrating the operation of the right key of the directory tree after the plug-in optimization in example 5.
Detailed Description
Example 1:
a method for managing and running test scripts, wherein plug-ins can be realized through a plug-in development interface (java) provided by Pycarm, and the script format is defined as follows: a Python file (py) is a test suite (testsut), a class (class) in the Python file is a test case (testcase), and each test case is classically divided into three steps (three functions in the class): 1. environment configuration, 2, formal script content, 3, cleaning environment configuration. When a written script is imported into Pycharm, the plug-in identifies keywords (class \ def) in the script to generate a corresponding control in a directory tree, and freely combines and runs a use case through checking and selecting the control, and can also run a single use case or a single function (such as cleaning and configuration) in the use case, so that debugging is facilitated.
Example 2:
in this embodiment, optimization is performed on the basis of embodiment 1, as shown in fig. 1 and fig. 2, the optimized PyCharm of the plug-in performs deeper parsing on each Python test script, and when there is a class (a test case testcase) in the script, a control having the same name as the class is automatically generated, and the testcase defined by the class can be operated (run, debug, copy, del, and the like) by using the control through the right key.
Similarly, when a function defined by the def keyword is analyzed (a test step teststep) in the script, a control with the same name as the function is automatically generated, the test step can be independently operated by clicking the right key of the control, and if only the environment configuration is to be cleared, the teststep3 can be operated.
Other parts of this embodiment are the same as embodiment 1, and thus are not described again.
Example 3:
a method for managing and running test scripts mainly comprises the following steps:
step S100: installing a Pycharm plug-in; traversing newly added contents of the script in real time, detecting a class name and a function name of a keyword in the script, and generating a corresponding control in a directory tree according to the class name and the function name;
step S200: importing a project script to generate a corresponding control; when the control is selected, the corresponding field is 1, otherwise, the corresponding field is 0;
step S300: realizing free running of the script by checking whether the control is selected; and associating any one or more functions of run, debug, del and copy to the corresponding control, realizing that the right key displays the corresponding option, and realizing corresponding operation according to whether the control is selected or not.
The invention is convenient for management and maintenance work when the large-scale project script is huge in quantity, and testers can quickly position the script of a certain functional module (generally, scripts with the same function are all under one testsutit) through the control names, thereby facilitating development and testing of the script. The scripts of which functional modules can be freely selected to run, and when full-function testing is not needed, other modules can be folded, and independent testing can be performed on a change point without changing any script.
Example 4:
the system for managing and running the test script comprises a dynamic detection and control generation module, a control state recording module and a control association module; defining a script format: the script is a Python file and comprises a plurality of classes, each class is a test case, and each test case comprises three functions of environment configuration, formal script content and environment cleaning configuration; the method comprises the steps that a script is led into Pycharm, the dynamic detection and control generation module is used for traversing newly added content of the script in real time, detecting key word class names and function names in the script and generating corresponding controls in a directory tree according to the class names and the function names; when the control is selected, the corresponding field in the control state recording module is 1, otherwise, the corresponding field is 0; the control association module is used for associating any one or more functions of run, debug, del and copy to the corresponding control, realizing the display of the corresponding option by a right key and realizing the corresponding operation according to the checking of the control.
The invention is convenient for management and maintenance work when the large-scale project script is huge in quantity, and testers can quickly position the script of a certain functional module (generally, scripts with the same function are all under one testsutit) through the control names, thereby facilitating development and testing of the script. The scripts of which functional modules can be freely selected to run, and when full-function testing is not needed, other modules can be folded, and independent testing can be performed on a change point without changing any script.
Example 5:
a method for managing and running test scripts, as shown in fig. 3-5, mainly includes the following steps:
1. py, the following contents are imported:
class testcase:
def teststep:
pass
in this script, a class is defined by the keyword class, the class name is testcase, and in this class, a function is defined by the keyword def, the function name is teststep.
2. And detecting the keywords class and def in the script by traversing the newly added content of the script in real time, and generating a corresponding control in the directory tree according to the class name and the function name.
(1) Traversing the file content, and detecting related keys class and def in the script;
(2) generating a control testcase according to the class name;
(3) and generating a control teststep according to the function name.
3. Recording the state of the control, wherein when the control is selected, the corresponding field is 1, otherwise, the corresponding field is 0;
(1) maintaining a file for recording the control state, and detecting whether the generated two controls testcase and teststep are checked
(2) Selecting: setting the field for recording the control state in the file to be 1
(3) And (3) selecting: setting the field for recording the control state in the file to 0
4. And (4) control association, namely associating functions of run, debug, del, copy and the like to corresponding controls, so that a right key can see corresponding options, and corresponding operations can be performed according to whether the controls of the module C are selected, and the controls can be folded.
Associating the functions of run, debug and the like to the control testcase and teststep, so that the script content corresponding to the control can be operated through the control, such as running.
And reading a file of the module B recording the state of the control, wherein if the field is 1 (checking), the module corresponding to the control is not skipped during operation, and otherwise, the module is skipped (not checking).
5. Py at file name teststop.py a right click run (run):
(1) when the control testcase is selected, the testcase is operated;
(2) when the control testcase is not checked, the testcase is skipped, and the subsequent cases (a plurality of testcases are usually existed in a project) are executed continuously;
(3) whether teststep and testunit are in collusion or not can also control whether the teststep and testunit are operated or not.
The method and the device automatically generate the traceable foldable control according to the keywords (class \ def) in the script, are convenient to operate and manage the specific script, are not limited by an automation frame, do not need to operate one right key during batch operation, and improve the execution efficiency and the accuracy.
The invention is convenient for management and maintenance work when the large-scale project script is huge in quantity, and testers can quickly position the script of a certain functional module (generally, scripts with the same function are all under one testsutit) through the control names, thereby facilitating development and testing of the script. The scripts of which functional modules can be freely selected to run, and when full-function testing is not needed, other modules can be folded, and independent testing can be performed on a change point without changing any script.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, and all simple modifications and equivalent variations of the above embodiments according to the technical spirit of the present invention are included in the scope of the present invention.

Claims (6)

1. A method for managing and running test scripts is characterized by being realized through a plug-in development interface provided by Pycharm; defining a script format: the script is a Python file and comprises a plurality of classes, each class is a test case, and each test case comprises three functions of environment configuration, formal script content and environment cleaning configuration; and importing the script into Pycharm, identifying key words of class names and function names in the script, generating corresponding controls in a directory tree, and realizing freely-combined running of use cases, or running of single functions by checking and selecting the controls.
2. The method of claim 1, wherein when identifying the class name in the script, generating a control with the same name as the class name, and implementing the right key to operate the test case defined by the class name through the control.
3. The method of claim 1, wherein when the function defined by the keyword of the function name exists in the script, the control with the same function name is generated, and the corresponding testing step is executed independently by checking the right button of the control.
4. A method for managing and running test scripts according to any one of claims 1 to 3, characterized in that any one or more of run, debug, del and copy functions are associated with the corresponding control, the right button displays the corresponding option, and the operation is implemented according to the check of the control.
5. A method for managing and running test scripts according to any one of claims 1 to 3, mainly comprising the following steps:
step S100: traversing newly added contents of the script in real time, detecting a class name and a function name of a keyword in the script, and generating a corresponding control in a directory tree according to the class name and the function name;
step S200: when the control is selected, the corresponding field is 1, otherwise, the corresponding field is 0;
step S300: and associating any one or more functions of run, debug, del and copy to the corresponding control, realizing that the right key displays the corresponding option, and realizing corresponding operation according to whether the control is selected or not.
6. The system for managing and running the test script is characterized by comprising a dynamic detection and control generation module, a control state recording module and a control association module; defining a script format: the script is a Python file and comprises a plurality of classes, each class is a test case, and each test case comprises three functions of environment configuration, formal script content and environment cleaning configuration; the method comprises the steps that a script is led into Pycharm, the dynamic detection and control generation module is used for traversing newly added content of the script in real time, detecting key word class names and function names in the script and generating corresponding controls in a directory tree according to the class names and the function names; when the control is selected, the corresponding field in the control state recording module is 1, otherwise, the corresponding field is 0; the control association module is used for associating any one or more functions of run, debug, del and copy to the corresponding control, realizing the display of the corresponding option by a right key and realizing the corresponding operation according to the checking of the control.
CN202110365687.9A 2021-04-06 2021-04-06 Method and system for managing and running test script Active CN113076247B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110365687.9A CN113076247B (en) 2021-04-06 2021-04-06 Method and system for managing and running test script

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110365687.9A CN113076247B (en) 2021-04-06 2021-04-06 Method and system for managing and running test script

Publications (2)

Publication Number Publication Date
CN113076247A true CN113076247A (en) 2021-07-06
CN113076247B CN113076247B (en) 2023-07-04

Family

ID=76615362

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110365687.9A Active CN113076247B (en) 2021-04-06 2021-04-06 Method and system for managing and running test script

Country Status (1)

Country Link
CN (1) CN113076247B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101706753A (en) * 2009-12-11 2010-05-12 武汉虹信通信技术有限责任公司 Unit testing framework and method based on Perl
US20100153927A1 (en) * 2008-12-16 2010-06-17 Microsoft Corporation Transforming user script code for debugging
CA2708685A1 (en) * 2009-07-16 2011-01-16 Accenture Global Services Gmbh Modularizing and aspectizing graphical user interface directed test scripts
US20130086420A1 (en) * 2011-10-03 2013-04-04 Verizon Patent And Licensing, Inc. Method and system for implementing a test automation results importer
CN103186460A (en) * 2011-12-30 2013-07-03 金蝶软件(中国)有限公司 Method, device and system for generating script of test case
CN104407971A (en) * 2014-11-18 2015-03-11 中国电子科技集团公司第十研究所 Method for automatically testing embedded software
CN104484269A (en) * 2014-11-27 2015-04-01 北京广利核系统工程有限公司 Method for automatically generating testing script
CN108874680A (en) * 2018-07-09 2018-11-23 上海瀚银信息技术有限公司 A kind of method for testing software and system of automation
CN109189663A (en) * 2018-07-12 2019-01-11 武汉精测电子集团股份有限公司 A kind of plug-in unit adjustment method, test method and microkernel architecture system
CN109491897A (en) * 2018-10-26 2019-03-19 成都安恒信息技术有限公司 A kind of system resource leak testing method based on trend analysis
CN112597037A (en) * 2020-12-28 2021-04-02 江苏苏宁银行股份有限公司 Java and Python combined automatic script development method and device

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100153927A1 (en) * 2008-12-16 2010-06-17 Microsoft Corporation Transforming user script code for debugging
CA2708685A1 (en) * 2009-07-16 2011-01-16 Accenture Global Services Gmbh Modularizing and aspectizing graphical user interface directed test scripts
CN101706753A (en) * 2009-12-11 2010-05-12 武汉虹信通信技术有限责任公司 Unit testing framework and method based on Perl
US20130086420A1 (en) * 2011-10-03 2013-04-04 Verizon Patent And Licensing, Inc. Method and system for implementing a test automation results importer
CN103186460A (en) * 2011-12-30 2013-07-03 金蝶软件(中国)有限公司 Method, device and system for generating script of test case
CN104407971A (en) * 2014-11-18 2015-03-11 中国电子科技集团公司第十研究所 Method for automatically testing embedded software
CN104484269A (en) * 2014-11-27 2015-04-01 北京广利核系统工程有限公司 Method for automatically generating testing script
CN108874680A (en) * 2018-07-09 2018-11-23 上海瀚银信息技术有限公司 A kind of method for testing software and system of automation
CN109189663A (en) * 2018-07-12 2019-01-11 武汉精测电子集团股份有限公司 A kind of plug-in unit adjustment method, test method and microkernel architecture system
CN109491897A (en) * 2018-10-26 2019-03-19 成都安恒信息技术有限公司 A kind of system resource leak testing method based on trend analysis
CN112597037A (en) * 2020-12-28 2021-04-02 江苏苏宁银行股份有限公司 Java and Python combined automatic script development method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
T. WAKAMORI等: "Reconfigurable Scripting Language with Programming Risk", 《2012 IEEE 23RD INTERNATIONAL SYMPOSIUM ON SOFTWARE RELIABILITY ENGINEERING WORKSHOPS》, pages 316 - 318 *
王宛生: "基于Eclipse的可视化界面开发技术", 《中国优秀硕士学位论文全文数据库信息科技辑》, no. 6, pages 138 - 234 *

Also Published As

Publication number Publication date
CN113076247B (en) 2023-07-04

Similar Documents

Publication Publication Date Title
US8935673B1 (en) System and method for debugging computer program based on execution history
US10372594B2 (en) Method and device for retrieving test case based on code coverage
CN101739339B (en) Program dynamic dependency relation-based software fault positioning method
US8875110B2 (en) Code inspection executing system for performing a code inspection of ABAP source codes
EP0785510B1 (en) Program debugging system for debugging a program having a graphical user interface
US10565089B2 (en) Identification of code features potentially associated with code behavior
US20060230319A1 (en) Automated migration of software instructions
CN106776343A (en) A kind of web application automated test tool and method
US20080313208A1 (en) Apparatus, system, and method for automated context-sensitive message organization
CN110908894B (en) Visual report tool automatic testing method and device based on vuex
US9311077B2 (en) Identification of code changes using language syntax and changeset data
CN102567164A (en) Instruction set batch testing device and method for processor
CN111352842A (en) Embedded software debugging method
Wang et al. An empirical study on bugs in python interpreters
CN114924737A (en) Battery management system source code integration test method and device and electronic equipment
CN111694738B (en) Method for generating SQL test script
Yang et al. Compatibility issue detection for android apps based on path-sensitive semantic analysis
US8819626B2 (en) Sharable development environment bookmarks for functional/data flow
Amintabar et al. ExceptionTracer: A solution recommender for exceptions in an integrated development environment
CN113076247B (en) Method and system for managing and running test script
CN117075874A (en) SCADE model and C code mapping tool
KR20130032756A (en) Plug-in module based on eclipse platform
CN118838845A (en) Fault diagnosis method for JDI and AI
Yong et al. Data change analysis based on function call path
US20070168978A1 (en) Computer program code debugging method and 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
GR01 Patent grant
GR01 Patent grant