WO2018121531A1 - 一种生成测试用例脚本的方法和装置 - Google Patents

一种生成测试用例脚本的方法和装置 Download PDF

Info

Publication number
WO2018121531A1
WO2018121531A1 PCT/CN2017/118639 CN2017118639W WO2018121531A1 WO 2018121531 A1 WO2018121531 A1 WO 2018121531A1 CN 2017118639 W CN2017118639 W CN 2017118639W WO 2018121531 A1 WO2018121531 A1 WO 2018121531A1
Authority
WO
WIPO (PCT)
Prior art keywords
script
unit function
word
frequency vector
call information
Prior art date
Application number
PCT/CN2017/118639
Other languages
English (en)
French (fr)
Inventor
葛中远
龙天剑
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2018121531A1 publication Critical patent/WO2018121531A1/zh

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • the present invention relates to the field of communications and computers, and more particularly to a method and apparatus for generating test case scripts.
  • Automated testing has improved test efficiency and has evolved into an increasingly important test.
  • automated testing requires testers to have certain code development capabilities and to redevelop after test cases have changed.
  • test case scripts In some methods of generating test case scripts, there are strict requirements for the design and description of test case scripts. Therefore, testers are required to master the design specifications of the test case script. At the same time, because the description of the test case script does not conform to the characteristics of human natural language, test cases cannot be applied to complex and variable fields, especially complex logic services and scenarios. To alleviate the burden of code development, a method and system for automatically generating test case scripts is needed.
  • the present invention provides a method and apparatus for generating a test case script such that the test case script can be described in a natural language that conforms to the tester's habits, thereby improving the efficiency of automated test development and enhancing the ease of use of the test case.
  • An aspect of the present invention provides a method for generating a test case script, including: acquiring call information for calling a unit function script, where the unit function script includes script code for executing a unit function test and a script comment; The script annotation with the highest probability corresponds to the unit function script, and the selected unit function script is combined into a test case script; and the test case script is used to test the application.
  • the step of obtaining call information for invoking a unit function script includes: acquiring a text string of a natural language and performing word segmentation processing on the text string to obtain a plurality of word segments of the call information.
  • the script annotation contains a plurality of word segments, and the word segmentation of the script annotation corresponds to the unit function of the script code of the execution unit function test.
  • the step of selecting a unit function script according to the script with the highest probability corresponding to the call information comprises: acquiring a script comment of a unit function script of the plurality of unit function scripts, and each participle in the call information
  • Each word segment of the script comment with the one unit function script constitutes a word segment set; according to the frequency of occurrence of each participle of the word segment set in each participle of the call information, the call information is mapped to a call word frequency vector, according to the word segment set
  • the frequency of occurrence of each participle in each participle of the script annotation maps the script annotation to an annotation word frequency vector; and calculates a similarity value between the calling word frequency vector and the annotation word frequency vector according to the calling word frequency vector and the annotation word frequency vector; Repeating the above steps until a plurality of similarity values between the call word frequency vector and the comment word frequency vector for the plurality of unit function scripts are calculated; selecting a maximum similarity value among the plurality of similarity values And selecting a unit function foot corresponding
  • the method further comprises: determining whether the maximum similarity value is greater than a predetermined threshold; and when the maximum similarity When the degree value is greater than the predetermined threshold, the unit function script corresponding to the maximum similarity value is selected.
  • the step of calculating a similarity value between the calling word frequency vector and the annotation word frequency vector according to the calling word frequency vector and the annotation word frequency vector comprises: calculating the calling word frequency vector and the annotation word frequency vector according to a cosine theorem a cosine value and the similarity value is generated based on the cosine value.
  • the step of selecting a unit function script according to the similarity value comprises: if the maximum similarity value is greater than a preset threshold, selecting a unit function script corresponding to the maximum similarity value.
  • Another aspect of the present invention provides an apparatus for generating a test case script, comprising: an obtaining module configured to acquire call information for calling a unit function script, wherein the unit function script includes a script for performing a unit function test a code and a script comment; the combination module is configured to select a unit function script according to the script comment with the highest probability corresponding to the call information, and combine the selected unit function script into a test case script; and the test module is configured to adopt the test The use case script tests the application under test.
  • the obtaining module comprises: a receiving unit configured to acquire a text string of a natural language; and a word segmentation unit configured to perform word segmentation processing on the text string to obtain a plurality of word segments of the call information.
  • the combination module includes: a collection unit configured to acquire a script annotation of a unit function script, and each word segmentation in the call information and each word segment of the script annotation form a word segmentation set; the calculation unit is configured to The calling information is mapped to the calling word frequency vector according to the frequency of occurrence of each participle of the word segmentation in each participle of the calling information, and the script is annotated according to the frequency of occurrence of each participle of the word segmentation in each participle of the script comment Mapping to an annotation word frequency vector, and calculating a similarity value between the calling word frequency vector and the annotation word frequency vector according to the calling word frequency vector and the annotation word frequency vector; and selecting a unit configured to select a unit function script according to the similarity value.
  • FIG. 1 is a flow chart showing the steps of a method for generating a test case script according to an embodiment of the present invention
  • FIG. 2 is a flow chart showing the steps of a script comment selection unit function script with the highest probability corresponding to the call information according to the embodiment of the present invention
  • FIG. 3 is an apparatus for generating a test case script according to an embodiment of the present invention.
  • test case scripts As mentioned above, automated testing can improve test efficiency.
  • this can be achieved by developing a use case writing specification (eg, including keyword definitions, template definitions).
  • testers are required to write test cases in strict accordance with the design specifications in order to generate test scripts by entering test cases of a certain format.
  • the test case In a method of generating a test case script, for example, the test case can be designed by keyword and the keyword in the code map by using the operation command of the test case.
  • the user needs to input a test case file according to a certain format.
  • the test case file includes at least a template ID and a message code. As you can see, in these methods of generating test case scripts, testers need to master complex script design languages.
  • Embodiments of the present invention provide a method of generating a test case script.
  • 1 is a flow chart showing the steps of a method of generating a test case script in accordance with an embodiment of the present invention. As shown in FIG. 1, the method includes the following steps:
  • S102 Select a unit function script according to the script comment with the highest probability corresponding to the call information, and combine the selected unit function script into a test case script;
  • the step of obtaining call information for invoking a unit function script includes: acquiring a text string of a natural language and performing word segmentation processing on the text string to obtain a plurality of word segments of the call information.
  • the script annotation includes a plurality of word segments, wherein the word segmentation of the script annotation corresponds to a unit function of the script code of the execution unit function test.
  • the obtained natural language text string input by the tester is decomposed into a plurality of words to obtain call information input by the tester; and then the call information is used to search the database for the maximum probability corresponding to the call information.
  • the script comment select the set unit function script by using the correspondence between the script comment and the unit function script; and combine the selected series of unit function scripts into the test case script.
  • the unit function script can be invoked by using natural language as the call information. Therefore, the tester can write automated test cases according to the actual situation of the test object without using the complex design voice of the test case script, thereby reducing the burden of code development and improving the test efficiency.
  • FIG. 2 is a flow chart showing the steps of a script comment selection unit function script having a maximum probability corresponding to the call information according to an embodiment of the present invention.
  • the step of selecting a unit function script according to the script annotation having the greatest probability corresponding to the call information includes the following steps:
  • S201 Acquire a script comment of a unit function script in the plurality of unit function scripts, and combine each word segment of the call information with each word segment of the script comment of the one unit function script to form a word segment set;
  • S202 mapping the call information to a call word frequency vector according to a frequency of occurrence of each participle of the word segmentation set in each participle of the call information, and each participle of the script comment according to each word segment of the word segment set.
  • the frequency appearing in the map maps the script comment to an annotated word frequency vector;
  • S203 Calculate a similarity value between the calling word frequency vector and the annotation word frequency vector according to the called word frequency vector and the annotation word frequency vector;
  • Step S201 to step S203 are repeated until a similarity value between the called word frequency vector and the comment word frequency vector for the script comment of the plurality of unit function scripts is calculated;
  • the method further includes: determining whether the maximum similarity value is greater than a predetermined threshold; and selecting, when the maximum similarity value is greater than a predetermined threshold The unit function script corresponding to the maximum similarity value.
  • the similarity value may be calculated based on the called word frequency vector and the annotated word frequency vector, and the corresponding unit function script is selected by the similarity value.
  • the similarity value can be obtained based on calculating the calling word frequency vector and the cosine value of the annotated word frequency vector according to the cosine theorem.
  • the apparatus for generating a test case script includes: an obtaining module 32 configured to acquire call information for calling a unit function script, wherein the unit function script includes script code for performing unit function test and a scripting annotation; the combining module 34 is configured to select a unit function script according to the script annotation having the greatest probability corresponding to the calling information, and combine the selected unit function script into a test case script; and the testing module 33 is configured to adopt The test case script tests the application to be tested.
  • the obtaining module includes: a receiving unit configured to acquire a text string of a natural language; and a word segmentation unit configured to perform word segmentation processing on the text string to obtain a plurality of word segments of the call information.
  • the combination module includes: a collection unit configured to acquire a script annotation of a unit function script, and each word segmentation in the call information and each word segmentation of the script annotation form a word segmentation set; a calculation unit, constructing Converting the call information into a call word frequency vector according to the frequency of occurrence of each participle of the word segmentation in each participle of the call information, and appearing in each participle of the script comment according to each participle of the word segment set Frequency mapping the script annotation to an annotation word frequency vector, and calculating a similarity value between the calling word frequency vector and the annotation word frequency vector according to the calling word frequency vector and the annotation word frequency vector; and selecting a unit configured to The similarity value selects the unit function script.
  • the method of generating a test case script is further explained below.
  • the tester enters a test step in the test case: create a DHCP wan connection.
  • the script comment of the unit function script stored in the database is: create DS-Lite tunnel; LAN1 port plays multicast stream; create DHCP wan connection; create PPPoE wan connection;
  • S401 Decompose the test step input by the user according to the word segmentation vocabulary into: create/one/DHCP/Wan/connection, denoted by X;
  • a script comment for extracting a unit function script in the S402 database create /DS-Lite/tunnel, denoted by Y;
  • the method of generating a test case script according to the present invention can use natural language as the call information and obtain a script comment having the greatest probability corresponding to the natural language. Therefore, the burden of code development can be alleviated and the test efficiency can be improved.
  • modules or steps of the present invention described above can be implemented by a general-purpose computing device, which can be centralized on a single computing device or distributed over a network of multiple computing devices. Alternatively, they may be implemented by program code executable by a computing device such that they may be stored in a storage device by a computing device and, in some cases, may be executed in a different order than herein.
  • the steps shown or described are either made separately into individual integrated circuit modules, or a plurality of modules or steps are fabricated as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software.

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)
  • Stored Programmes (AREA)

Abstract

一种生成测试用例脚本的方法,包括:获取用于调用单元功能脚本的调用信息,其中,该单元功能脚本包括用于执行单元功能测试的脚本代码以及脚本注释(S101);根据该调用信息对应的具有最大概率的脚本注释选取单元功能脚本,并且将选取的该单元功能脚本组合成测试用例脚本(S102);以及采用该测试用例脚本对待测应用程序进行测试(S103)。

Description

一种生成测试用例脚本的方法和装置 技术领域
本发明涉及通信和计算机领域,特别涉及一种生成测试用例脚本的方法和装置。
背景技术
自动化测试提高了测试效率,已经发展为越来越重要的测试手段。但是自动化测试要求测试人员具有一定的代码开发能力,并且测试用例发生变化后需要重新开发。
在一些生成测试用例脚本的方法中,对测试用例脚本的设计和描述具有严格的要求。因此,需要测试人员掌握测试用例脚本的设计规范。同时,因为测试用例脚本的描述不符合人类自然语言的特性,因此测试用例无法应用于复杂多变的领域,特别是有较复杂的逻辑业务和场景。为了减轻代码开发的负担,需要一种自动生成测试用例脚本的方法和系统。
发明内容
本发明提供一种生成测试用例脚本的方法和装置,使得测试用例脚本可以使用符合测试人员习惯的自然语言描述,从而提高自动化测试开发的效率并且增强测试用例的易用性。
本发明一方面提供了一种生成测试用例脚本的方法,包括:获取用于调用单元功能脚本的调用信息,其中,该单元功能脚本包括用于执行单元功能测试的脚本代码以及脚本注释;根据该调用信息对应的具有最大概率的脚本注释选取单元功能脚本,并且将选取的该单元功能脚本组合成测试用例脚本;以及采用该测试用例脚本对待测应用程序进行测试。
在一个实施例中,获取用于调用单元功能脚本的调用信息的步骤包括:获取自然语言的文本串并且对该文本串进行分词处理得到所述调用信息的多个分词。
在一个实施例中,该脚本注释包含多个分词,并且该脚本注释的分词 与该执行单元功能测试的脚本代码的单元功能相对应。
在一个实施例中,根据该调用信息对应的具有最大概率的脚本注释选取单元功能脚本的步骤包括:获取多个单元功能脚本中的一个单元功能脚本的脚本注释,将该调用信息中的各个分词与所述一个单元功能脚本的脚本注释的各个分词组成分词集合;按照该分词集合的各个分词在该调用信息的各个分词中出现的频率将该调用信息映射为调用词频向量,按照该分词集合的各个分词在该脚本注释的各个分词中出现的频率将该脚本注释映射为注释词频向量;根据该调用词频向量和该注释词频向量计算该调用词频向量与该注释词频向量之间的相似度值;重复上述步骤,直到计算出针对所述多个单元功能脚本的所述调用词频向量与所述注释词频向量之间的多个相似度值;选取所述多个相似度值中的最大相似度值;以及选取与所述最大相似度值对应的单元功能脚本。
在一个实施例中,在选取所述多个相似度值中的最大相似度值的步骤之后,所述方法还包括:判断所述最大相似度值是否大于预定阈值;以及当所述最大的相似度值大于预定阈值时,选取与所述最大相似度值相对应的单元功能脚本。
在一个实施例中,根据该调用词频向量和该注释词频向量计算该调用词频向量与该注释词频向量之间的相似度值的步骤包括:根据余弦定理计算该调用词频向量和该注释词频向量的余弦值,并根据该余弦值生成该相似度值。
在一个实施例中,根据该相似度值选取单元功能脚本的步骤包括:如果最大相似度值大于预先设定的阈值,则选取所述最大相似度值对应的单元功能脚本。
本发明另一方面还提供了一种生成测试用例脚本的装置,包括:获取模块,构造成获取用于调用单元功能脚本的调用信息,其中,该单元功能脚本包括用于执行单元功能测试的脚本代码以及脚本注释;组合模块,构造成根据该调用信息对应的具有最大概率的脚本注释选取单元功能脚本,并且将选取的该单元功能脚本组合成测试用例脚本;以及测试模块,构造成采用该测试用例脚本对待测应用程序进行测试。
在一个实施例中,该获取模块包括:接收单元,构造成获取自然语言 的文本串;分词单元,构造成对该文本串进行分词处理得到所述调用信息的多个分词。
在一个实施例中,该组合模块,包括:集合单元,构造成获取一个单元功能脚本的脚本注释,将该调用信息中的各个分词与该脚本注释的各个分词组成分词集合;计算单元,构造成按照该分词集合的各个分词在该调用信息的各个分词中出现的频率将该调用信息映射为调用词频向量,按照该分词集合的各个分词在该脚本注释的各个分词中出现的频率将该脚本注释映射为注释词频向量,并且根据该调用词频向量和该注释词频向量计算该调用词频向量与该注释词频向量之间的相似度值;以及选取单元,构造成根据该相似度值选取单元功能脚本。
附图说明
图1是根据本发明实施例的一种生成测试用例脚本的方法的步骤流程图;
图2是本发明实施例的根据该调用信息对应的概率最大的脚本注释选取单元功能脚本的步骤流程图;
图3是本发明实施例的一种生成测试用例脚本的装置;
具体实施方式
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。
如上文所述,自动化测试可以提高测试效率。在一种生成测试用例脚本的方法中,可以通过制定用例编写规范(例如,包括关键字定义、模板定义)来达到上述目的。但是,要求测试人员需要严格按照设计规范来编写测试用例,以便通过输入一定格式的测试用例来生成测试脚本。在一种生成测试用例脚本的中,例如,可以通过将测试用例的操作命令以关键字与代码映 射表中关键字命名,测试用例需要按照关键字来设计编写。在一种生成测试用例脚本的中,用户需要按照一定格式输入测试用例文件,例如,测试用例文件中至少包含模板ID、消息码。可以看出,在这些生成测试用例脚本的方法中,测试人员的需要掌握复杂的脚本设计语言。
本发明的实施例提供了一种生成测试用例脚本的方法。图1是根据本发明的实施例的一种生成测试用例脚本的方法的步骤流程图。如图1所示,所述方法包括以下步骤:
S101,获取用于调用单元功能脚本的调用信息,其中,所述单元功能脚本包括用于执行单元功能测试的脚本代码以及脚本注释;
S102,根据所述调用信息对应的具有最大概率的脚本注释选取单元功能脚本,并且将选取的所述单元功能脚本组合成测试用例脚本;以及
S103,采用所述测试用例脚本对待测应用程序进行测试。
在一个实施例中,获取用于调用单元功能脚本的调用信息的步骤包括:获取自然语言的文本串并且对该文本串进行分词处理得到所述调用信息的多个分词。
在一个实施例中,所述脚本注释包含多个分词,其中所述脚本注释的分词与该执行单元功能测试的脚本代码的单元功能相对应。
根据本发明的实施例,将获取的测试人员输入的自然语言的文本串分解成若干词,以得到测试人员输入的调用信息;然后利用该调用信息从数据库中搜索与调用信息对应的具有最大概率的脚本注释;利用脚本注释与单元功能脚本的对应关系选集合单元功能脚本;将选取的一系列单元功能脚本组合为测试用例脚本。在本发明的实施例中,可以通过使用自然语言作为调用信息来调用单元功能脚本。因此,测试人员不必使用测试用例脚本的复杂设计语音就可以根据测试对象的实际情况编写自动化测试用例,从而减轻了代码开发的负担,提高了测试效率。
图2是本发明的实施例的根据所述调用信息对应的具有最大概率的脚本注释选取单元功能脚本的步骤流程图。如图2所示,根据所述调用信息对应的具有最大概率的脚本注释选取单元功能脚本的步骤包括以下步骤:
S201:获取多个单元功能脚本中的一个单元功能脚本的脚本注释,将 所述调用信息的各个分词与所述一个单元功能脚本的脚本注释的各个分词组成分词集合;
S202:按照所述分词集合的各个分词在所述调用信息的各个分词中出现的频率将所述调用信息映射为调用词频向量,并且按照所述分词集合的各个分词在所述脚本注释的各个分词中出现的频率将所述脚本注释映射为注释词频向量;
S203:根据所述调用词频向量和所述注释词频向量计算所述调用词频向量与所述注释词频向量之间的相似度值;
S204:重复步骤S201-步骤S203,直到计算出针对所述多个单元功能脚本的脚本注释的所述调用词频向量与所述注释词频向量之间的相似度值;
S205:选取所述多个相似度值中的最大相似度值;以及
S206:选取与所述最大相似度值对应的单元功能脚本。
在本公开的一个实施例中,在步骤S205之后,所述方法还包括:判断所述最大相似度值是否大于预定阈值;以及当所述最大的相似度值大于预定阈值时,选取与所述最大相似度值相对应的单元功能脚本。
根据本发明的实施例,可以基于调用词频向量和注释词频向量计算相似度值,通过相似度值来选取对应的单元功能脚本。相似度值可以基于以下方式获得:根据余弦定理计算该调用词频向量和该注释词频向量的余弦值。
图3是本发明实施例的一种生成测试用例脚本的装置。如图3所示,该生成测试用例脚本的装置包括:获取模块32,构造成获取用于调用单元功能脚本的调用信息,其中,所述单元功能脚本包括用于执行单元功能测试的脚本代码以及脚本注释;组合模块34,构造成根据所述调用信息对应的具有最大概率的脚本注释选取单元功能脚本,并且将选取的所述单元功能脚本组合成测试用例脚本;以及测试模块33,构造成采用所述测试用例脚本对待测应用程序进行测试。
在一个实施例中,所述获取模块包括:接收单元,构造成获取自然语言的文本串;和分词单元,用于对该文本串进行分词处理得到所述调用信息的多个分词。
在一个实施例中,所述组合模块包括:集合单元,构造成获取一个单元功能脚本的脚本注释,将该调用信息中的各个分词与所述脚本注释的各个 分词组成分词集合;计算单元,构造成按照所述分词集合的各个分词在所述调用信息的各个分词中出现的频率将该调用信息映射为调用词频向量,按照所述分词集合的各个分词在所述脚本注释的各个分词中出现的频率将所述脚本注释映射为注释词频向量,并且根据所述调用词频向量和所述注释词频向量计算所述调用词频向量与该注释词频向量之间的相似度值;以及选取单元,构造成根据所述相似度值选取所述单元功能脚本。
作为本发明的一个实例,以下对生成测试用例脚本的方法做出进一步阐释。例如,测试人员输入测试用例中的一条测试步骤:创建一条DHCP wan连接。
数据库中储存的单元功能脚本的脚本注释依次为:创建DS-Lite隧道;LAN1端口播放组播流;创建DHCP wan连接;创建PPPoE wan连接;
设定相似度阈值为:0.8。
S401:根据分词词库将用户输入的测试步骤分解为:创建/一条/DHCP/Wan/连接,用X表示;
S402数据库中提取出一条单元功能脚本的脚本注释:创建/DS-Lite/隧道,用Y表示;
S403:获得X和Y的词汇集合:{创建/一条/DHCP/DS-Lite/Wan/连接/隧道},用Z表示;其中,Z中的各个词汇在X中出现的频率为:
Figure PCTCN2017118639-appb-000001
Figure PCTCN2017118639-appb-000002
以及
Figure PCTCN2017118639-appb-000003
并且
将Z映射为多维向量
Figure PCTCN2017118639-appb-000004
用c表示
S404:计算Z中的各个词汇在X中出现的频率,出现的频率为(没有出现的词汇以0表示):
Figure PCTCN2017118639-appb-000005
DS-Lite=0,
Figure PCTCN2017118639-appb-000006
以及隧道=0,并且
将X映射为多维向量
Figure PCTCN2017118639-appb-000007
用α表示;
S405:计算Z中的各个词汇在Y中出现的频率,出现的频率为(没有出现的词汇以0表示):
Figure PCTCN2017118639-appb-000008
一条=0,DHCP=0,
Figure PCTCN2017118639-appb-000009
Wan=0,连接=0以及
Figure PCTCN2017118639-appb-000010
Figure PCTCN2017118639-appb-000011
,并且
将Y映射为多维向量
Figure PCTCN2017118639-appb-000012
用β表示;
S406:根据余弦定理(等式1)对向量α、β,得到余弦值0.258,用γ表示,该数值就是相似度;
Figure PCTCN2017118639-appb-000013
等式1
S407:重复上述步骤S402-S406,直到遍历数据库中单元功能脚本的所有的脚本注释,以计算出与所有的脚本注释对应的余弦值0.258、0、0.894、0.67;以及
S408:如果最大相似度值大于相似度阈值,则返回最大相似度(即,0.894)对应的脚本注释,即返回脚本注释“创建DHCP wan连接”。
可以看出,根据本发明的生成测试用例脚本的方法,可以使用自然语言作为调用信息,并且获得与自然语言对应的具有最大概率的脚本注释。因此,可以减轻代码开发的负担,并且提高测试效率。
本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。
以上仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (10)

  1. 一种生成测试用例脚本的方法,包括:
    获取用于调用单元功能脚本的调用信息,其中,所述单元功能脚本包括用于执行单元功能测试的脚本代码以及脚本注释;
    根据所述调用信息对应的具有最大概率的脚本注释选取单元功能脚本,并且将选取的所述单元功能脚本组合成测试用例脚本;以及
    采用所述测试用例脚本对待测应用程序进行测试。
  2. 根据权利要求1所述的方法,其中,获取用于调用单元功能脚本的调用信息的步骤包括:
    获取自然语言的文本串并且对所述文本串进行分词处理得到所述调用信息的多个分词。
  3. 根据权利要求2所述的方法,其中,所述脚本注释包含多个分词,并且其中所述脚本注释的分词与所述执行单元功能测试的脚本代码的单元功能相对应。
  4. 根据权利要求3所述的方法,其中,根据所述调用信息对应的具有最大概率的脚本注释选取单元功能脚本的步骤包括:
    获取多个单元功能脚本中的一个单元功能脚本的脚本注释,将所述调用信息中的各个分词与所述一个单元功能脚本的脚本注释的各个分词组成分词集合;
    按照所述分词集合的各个分词在所述调用信息的各个分词中出现的频率将所述调用信息映射为调用词频向量,并且按照所述分词集合的各个分词在所述脚本注释的各个分词中出现的频率将所述脚本注释映射为注释词频向量;
    根据所述调用词频向量和所述注释词频向量计算所述调用词频向量与所述注释词频向量之间的相似度值;
    重复上述步骤,直到计算出针对所述多个单元功能脚本的所述调用词 频向量与所述注释词频向量之间的多个相似度值;
    选取所述多个相似度值中的最大相似度值;以及
    选取与所述最大相似度值对应的单元功能脚本。
  5. 根据权利要求4所述的方法,其中,在选取所述多个相似度值中的最大相似度值的步骤之后,所述方法还包括:
    判断所述最大相似度值是否大于预定阈值;以及
    当所述最大的相似度值大于预定阈值时,选取与所述最大相似度值相对应的单元功能脚本。
  6. 根据权利要求4所述的方法,其中,根据所述调用词频向量和所述注释词频向量计算所述调用词频向量与所述注释词频向量之间的相似度值的步骤包括:
    根据余弦定理计算所述调用词频向量和所述注释词频向量的余弦值,并根据所述余弦值生成所述相似度值。
  7. 根据权利要求6所述的方法,其中,根据所述相似度值选取单元功能脚本的步骤包括:
    如果最大相似度值大于预先设定的阈值,则选取所述最大相似度值对应的单元功能脚本
  8. 一种生成测试用例脚本的装置,其中,包括:
    获取模块,构造成获取用于调用单元功能脚本的调用信息,其中,所述单元功能脚本包括用于执行单元功能测试的脚本代码以及脚本注释;
    组合模块,构造成根据所述调用信息对应的具有最大概率的脚本注释选取单元功能脚本,并且将选取的所述单元功能脚本组合成测试用例脚本;以及
    测试模块,构造成采用所述测试用例脚本对待测应用程序进行测试。
  9. 根据权利要求8所述的装置,其中,所述获取模块包括:
    接收单元,构造成获取自然语言的文本串;
    分词单元,构造成对所述文本串进行分词处理得到所述调用信息的多个分词。
  10. 根据权利要求8所述的装置,其中,所述组合模块,包括:
    集合单元,构造成获取一个单元功能脚本的脚本注释,将所述调用信息中的各个分词与所述脚本注释的各个分词组成分词集合;
    计算单元,构造成按照所述分词集合的各个分词在所述调用信息的各个分词中出现的频率将所述调用信息映射为调用词频向量,按照所述分词集合的各个分词在所述脚本注释的各个分词中出现的频率将所述脚本注释映射为注释词频向量,并且根据所述调用词频向量和所述注释词频向量计算所述调用词频向量与所述注释词频向量之间的相似度值;以及
    选取单元,构造成根据所述相似度值选取所述单元功能脚本。
PCT/CN2017/118639 2016-12-30 2017-12-26 一种生成测试用例脚本的方法和装置 WO2018121531A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611259648.6A CN108268368A (zh) 2016-12-30 2016-12-30 一种生成测试用例脚本的方法和装置
CN201611259648.6 2016-12-30

Publications (1)

Publication Number Publication Date
WO2018121531A1 true WO2018121531A1 (zh) 2018-07-05

Family

ID=62710904

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/118639 WO2018121531A1 (zh) 2016-12-30 2017-12-26 一种生成测试用例脚本的方法和装置

Country Status (2)

Country Link
CN (1) CN108268368A (zh)
WO (1) WO2018121531A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109766274A (zh) * 2018-12-28 2019-05-17 河南思维轨道交通技术研究院有限公司 一种测试脚本自动化融合方法、存储介质
CN110221965A (zh) * 2019-05-09 2019-09-10 阿里巴巴集团控股有限公司 测试用例生成、测试方法、装置、设备及系统
CN110879785A (zh) * 2019-11-25 2020-03-13 斑马网络技术有限公司 接口测试场景集的生成方法
CN111078202A (zh) * 2019-12-06 2020-04-28 中国工商银行股份有限公司 业务架构模型维护方法、装置、电子设备和介质
CN112506756A (zh) * 2020-11-11 2021-03-16 东风汽车集团有限公司 一种车辆控制器测试用例脚本生成方法和装置
CN116155788A (zh) * 2023-04-19 2023-05-23 鹏城实验室 网络安全测试方法、装置、设备及可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109688599B (zh) * 2019-01-11 2022-04-22 北京华力创通科技股份有限公司 终端测试仪分组域调度方法及装置
CN109818833B (zh) * 2019-03-14 2021-08-17 北京信而泰科技股份有限公司 一种以太网测试系统和以太网测试方法
CN110245088B (zh) * 2019-06-21 2022-10-18 四川长虹电器股份有限公司 一种基于Jenkins的缺陷自动验证系统及验证方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104932980A (zh) * 2015-06-30 2015-09-23 北京奇虎科技有限公司 软件自动测试方法及装置
CN105068929A (zh) * 2015-08-06 2015-11-18 网易(杭州)网络有限公司 测试脚本生成方法和装置、测试方法、测试装置以及测试系统
CN105608012A (zh) * 2016-03-10 2016-05-25 武汉斗鱼网络科技有限公司 一种自动化测试方法及系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104932980A (zh) * 2015-06-30 2015-09-23 北京奇虎科技有限公司 软件自动测试方法及装置
CN105068929A (zh) * 2015-08-06 2015-11-18 网易(杭州)网络有限公司 测试脚本生成方法和装置、测试方法、测试装置以及测试系统
CN105608012A (zh) * 2016-03-10 2016-05-25 武汉斗鱼网络科技有限公司 一种自动化测试方法及系统

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109766274A (zh) * 2018-12-28 2019-05-17 河南思维轨道交通技术研究院有限公司 一种测试脚本自动化融合方法、存储介质
CN109766274B (zh) * 2018-12-28 2022-03-15 河南思维轨道交通技术研究院有限公司 一种测试脚本自动化融合方法、存储介质
CN110221965A (zh) * 2019-05-09 2019-09-10 阿里巴巴集团控股有限公司 测试用例生成、测试方法、装置、设备及系统
CN110221965B (zh) * 2019-05-09 2023-01-20 创新先进技术有限公司 测试用例生成、测试方法、装置、设备及系统
CN110879785A (zh) * 2019-11-25 2020-03-13 斑马网络技术有限公司 接口测试场景集的生成方法
CN110879785B (zh) * 2019-11-25 2023-05-30 斑马网络技术有限公司 接口测试场景集的生成方法
CN111078202A (zh) * 2019-12-06 2020-04-28 中国工商银行股份有限公司 业务架构模型维护方法、装置、电子设备和介质
CN112506756A (zh) * 2020-11-11 2021-03-16 东风汽车集团有限公司 一种车辆控制器测试用例脚本生成方法和装置
CN112506756B (zh) * 2020-11-11 2023-06-06 东风汽车集团有限公司 一种车辆控制器测试用例脚本生成方法和装置
CN116155788A (zh) * 2023-04-19 2023-05-23 鹏城实验室 网络安全测试方法、装置、设备及可读存储介质
CN116155788B (zh) * 2023-04-19 2023-06-20 鹏城实验室 网络安全测试方法、装置、设备及可读存储介质

Also Published As

Publication number Publication date
CN108268368A (zh) 2018-07-10

Similar Documents

Publication Publication Date Title
WO2018121531A1 (zh) 一种生成测试用例脚本的方法和装置
CN106796585B (zh) 条件验证规则
WO2018205730A1 (zh) 在区块链中获得智能合约接口的方法和设备
US20180336018A1 (en) Method and system for template extraction based on source code similarity
US20180025092A1 (en) Modular memoization, tracking and train-data management of feature extraction
US20140289705A1 (en) Systems and Methods for Generating Function-Relation Call Trees
WO2019114673A1 (zh) 基于最小分支路径函数胎记的软件局部抄袭证据生成方法
WO2018107953A1 (zh) 智能终端及其应用程序的自动分类方法
CN112187713B (zh) 报文转换的方法、装置、计算机设备和存储介质
CN112035480A (zh) 数据表管理方法、装置、设备及存储介质
US20230315416A1 (en) Code translation method and apparatus, and device
CN113961768B (zh) 敏感词检测方法、装置、计算机设备和存储介质
CN110888876A (zh) 生成数据库脚本的方法、装置、存储介质及计算机设备
CN110175128B (zh) 一种相似代码案例获取方法、装置、设备和存储介质
CN111177506A (zh) 一种基于大数据的分类存储方法及系统
US20190147124A1 (en) Operation model generator and operation model generation method
US11379224B2 (en) Scale calculation apparatus and computer readable medium
CN108664384B (zh) 数据处理装置和数据处理方法
CN115794105A (zh) 一种微服务的提取方法、装置以及电子设备
JP2019074966A (ja) Sql文抽出装置、sql文抽出方法及びプログラム
CN114328681A (zh) 一种数据转换方法、装置、电子设备及存储介质
CN113391795A (zh) 一种应用场景和软件开发包自适应映射的实现方法和系统
CN110647568A (zh) 一种图数据库数据转化为编程语言数据方法及装置
CN106855842B (zh) 一种基于正则表达式的程序静态分析方法
JP2016134079A (ja) 分析プログラム、分析方法及び分析装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17887330

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17887330

Country of ref document: EP

Kind code of ref document: A1