[go: up one dir, main page]

CN116126704A - A mock automatic number creation method, device and medium based on semantic recognition - Google Patents

A mock automatic number creation method, device and medium based on semantic recognition Download PDF

Info

Publication number
CN116126704A
CN116126704A CN202310002089.4A CN202310002089A CN116126704A CN 116126704 A CN116126704 A CN 116126704A CN 202310002089 A CN202310002089 A CN 202310002089A CN 116126704 A CN116126704 A CN 116126704A
Authority
CN
China
Prior art keywords
mock
interface
information
request
field
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
CN202310002089.4A
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.)
Sichuan XW Bank Co Ltd
Original Assignee
Sichuan XW Bank 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 Sichuan XW Bank Co Ltd filed Critical Sichuan XW Bank Co Ltd
Priority to CN202310002089.4A priority Critical patent/CN116126704A/en
Publication of CN116126704A publication Critical patent/CN116126704A/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/3692Test management for test results analysis
    • 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/3698Environments for analysis, debugging or testing of software
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • 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
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

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

Abstract

本发明公开了一种基于语义识别的mock自动造数方法、装置及介质,包括获取接口的基础字段信息,将基础字段信息输入语义识别模型中,确定语义相似度;基于语义相似度生成字段数据,形成基础字段库;对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库;接收请求方的接口调用请求,获取调用报文信息;根据调用报文信息,匹配mock规则库中对应的mock规则;根据mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将响应报文返回请求方,完成响应。本发明数据可灵活变更,达到覆盖多场景的需求;同时减少了对响应字段生成规则逐个维护的人工成本,极大地提高造数效率,提高接口测试效率。

Figure 202310002089

The invention discloses a mock automatic number creation method, device and medium based on semantic recognition, including acquiring basic field information of an interface, inputting the basic field information into a semantic recognition model, and determining semantic similarity; generating field data based on semantic similarity , form the basic field library; configure the interface request information and the corresponding mock rules to form the mock rule library for the request interface to be created; receive the interface call request from the requesting party, and obtain the call message information; match the mock according to the call message information The corresponding mock rules in the rule base; according to the mock rules, determine the structure of the response message and the field values of the generated data to obtain the response message; and return the response message to the requester to complete the response. The data of the present invention can be flexibly changed to meet the requirement of covering multiple scenarios; at the same time, the labor cost of maintaining the generation rules of the response fields is reduced one by one, greatly improving the efficiency of number creation and the efficiency of interface testing.

Figure 202310002089

Description

一种基于语义识别的mock自动造数方法、装置及介质A mock automatic number generation method, device and medium based on semantic recognition

技术领域Technical Field

本发明涉及软件测试领域,主要应用于接口测试中通过mock方式进行造数来验证接口联通性和正确性的方法。具体涉及一种基于语义识别的mock自动造数方法、装置及介质。The present invention relates to the field of software testing, and is mainly applied to a method for verifying the connectivity and correctness of an interface by creating numbers in a mock manner in interface testing, and specifically relates to a mock automatic number creation method, device and medium based on semantic recognition.

背景技术Background Art

软件测试是软件开发领域的重要环节,其中接口测试用于验证系统交互的正确性。在接口测试中,由于第三方服务或系统的不稳定性,环境的复杂性,会导致使用真实服务进行测试的效率低下。因此,使用mock是一种常见的接口测试方法,通过造数模拟请求系统的数据返回,来验证接口的正确性,可去掉对对方服务的依赖,减少环境维护成本,有效提高测试效率,快速检查出接口缺陷。Software testing is an important part of software development, in which interface testing is used to verify the correctness of system interactions. In interface testing, the instability of third-party services or systems and the complexity of the environment will lead to low efficiency in testing using real services. Therefore, using mocks is a common interface testing method. By creating numbers to simulate the data return of the request system, the correctness of the interface can be verified, which can remove the dependence on the other party's services, reduce environmental maintenance costs, effectively improve testing efficiency, and quickly check interface defects.

现有mock技术中,主要的造数方法是以下两类:In the existing mock technology, the main number-generating methods are the following two categories:

1、通过人工方式造数。创建一个mock对象,人为配置响应信息等。1. Create numbers manually. Create a mock object and manually configure the response information.

2、通过自动化方式自动生成响应。测试人员在mock平台定义好结构体和响应字段类型后,通过配置化方式配置字段生成规则。在请求接口时,mock工具根据配置的规则自动生成响应报文。2. Generate responses automatically through automation. After the tester defines the structure and response field type on the mock platform, he configures the field generation rules through configuration. When requesting the interface, the mock tool automatically generates a response message according to the configured rules.

然而,以上两种方式均存在一些问题:However, both of the above methods have some problems:

1、依靠人工造数方式,通常一个mock对象仅对应一条mock响应数据,数据内容固定且难以灵活变更,若想覆盖多个测试场景,需手动多次调整mock数据,极大地影响测试效率。当涉及的期望结果报文体较为复杂时,人工方式维护成本较大。同时,由于数据人为模拟,数据真实性较低,难以做到真正替代调用方的实际返回内容。1. Relying on manual number creation, usually a mock object only corresponds to one mock response data, the data content is fixed and difficult to change flexibly. If you want to cover multiple test scenarios, you need to manually adjust the mock data multiple times, which greatly affects the test efficiency. When the expected result message body involved is more complex, the maintenance cost of the manual method is high. At the same time, due to the artificial simulation of the data, the data authenticity is low, and it is difficult to truly replace the actual return content of the caller.

2、通过可配置化自动生成响应的方式,在数据灵活性上有了提高,但另一方面数据的准确性依赖于配置的准确性,若要提高数据真实性,在配置上的工作成本增大,导致测试效率依然不高。尤其当涉及的响应报文结构复杂时,逐个维护每个字段生成规则的人工成本极大。2. The flexibility of data has been improved by automatically generating responses in a configurable way, but on the other hand, the accuracy of data depends on the accuracy of configuration. If the authenticity of data is to be improved, the cost of configuration will increase, resulting in low test efficiency. Especially when the structure of the response message involved is complex, the manual cost of maintaining the generation rules for each field one by one is extremely high.

发明内容Summary of the invention

本发明目的在于提供一种基于语义识别的mock自动造数方法、装置及介质,本发明可根据配置参数字段名称和字段类型等自动识别字段语义,再基于语义自动生成模拟数据。本发明数据可灵活变更,达到覆盖多场景的需求;同时减少了对响应字段生成规则逐个维护的人工成本,极大地提高造数效率,从而提高接口测试效率。The purpose of the present invention is to provide a mock automatic number generation method, device and medium based on semantic recognition. The present invention can automatically identify field semantics according to the configuration parameter field name and field type, and then automatically generate simulation data based on semantics. The data of the present invention can be flexibly changed to meet the needs of covering multiple scenarios; at the same time, it reduces the labor cost of maintaining the response field generation rules one by one, greatly improves the number generation efficiency, and thus improves the interface testing efficiency.

本发明通过下述技术方案实现:The present invention is achieved through the following technical solutions:

第一方面,本发明提供了一种基于语义识别的mock自动造数方法,该方法包括:In a first aspect, the present invention provides a mock automatic number generation method based on semantic recognition, the method comprising:

获取接口的基础字段信息,将基础字段信息输入语义识别模型中,确定语义相似度;基于语义相似度生成字段数据,形成基础字段库;Obtain basic field information of the interface, input the basic field information into the semantic recognition model, and determine the semantic similarity; generate field data based on the semantic similarity to form a basic field library;

对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库;mock规则中配置了接口的基础字段信息,生成字段数据后用于匹配接口的响应结果;For the request interface to be created, configure the interface request information and the corresponding mock rules to form a mock rule library; the basic field information of the interface is configured in the mock rules, and the generated field data is used to match the response result of the interface;

接收请求方的接口调用请求,获取调用报文信息;根据调用报文信息,匹配mock规则库中对应的mock规则;根据mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将响应报文返回请求方,完成响应。Receive the interface call request from the requester and obtain the call message information; match the corresponding mock rules in the mock rule library according to the call message information; determine the response message structure and the field values of the generated data according to the mock rules to obtain the response message; and return the response message to the requester to complete the response.

进一步地,所述的获取接口的基础字段信息,将基础字段信息输入语义识别模型中,确定语义相似度;基于语义相似度生成字段数据,形成基础字段库,包括:Furthermore, the basic field information of the acquisition interface is input into a semantic recognition model to determine semantic similarity; and field data is generated based on the semantic similarity to form a basic field library, including:

获取接口的基础字段信息;Get the basic field information of the interface;

将基础字段信息输入预先训练好的语义识别模型中,以得到基础字段语义向量和预期造数结果的语义向量;Input the basic field information into the pre-trained semantic recognition model to obtain the semantic vector of the basic field and the semantic vector of the expected number-making result;

根据基础字段语义向量和预期造数结果的语义向量,确定语义相似度;Determine semantic similarity based on the semantic vector of the basic field and the semantic vector of the expected number-making result;

基于语义相似度,生成字段数据,形成基础字段库。Based on semantic similarity, field data is generated to form a basic field library.

其中,语义相似度可以衡量各个基础字段语义向量与预期造数结果的语义向量的相似性和关联紧密程度。在后续获取的接口调用请求中,可基于该相似度生成接口字段的模拟数据,使得生成的结果与预期结果保持高度相似,是所需的期望造数结果。Among them, the semantic similarity can measure the similarity and closeness of the semantic vector of each basic field with the semantic vector of the expected number-making result. In the subsequent interface call request obtained, the simulated data of the interface field can be generated based on the similarity, so that the generated result is highly similar to the expected result and is the desired number-making result.

进一步地,基础字段信息包括字段名称、字段类型、字段长度以及预期结果值。Furthermore, the basic field information includes field name, field type, field length, and expected result value.

进一步地,对每一个待造数(需要生成测试数据)的接口,配置一条可唯一确定该接口的mock规则;从基础字段库中筛选所需要的接口返回字段数据,建立mock规则与字段数据的对应关系。Furthermore, for each interface to be created (needs to generate test data), configure a mock rule that can uniquely identify the interface; filter the required interface return field data from the basic field library, and establish a corresponding relationship between the mock rule and the field data.

进一步地,所述的对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库,包括:Furthermore, for the request interface to be created, the interface request information and the corresponding mock rules are configured to form a mock rule library, including:

对待造数的请求接口,获取接口的基本信息;Treat the request interface for number generation and obtain basic information of the interface;

根据接口的基本信息,配置对应的mock规则;mock规则包括接口请求信息和响应结果;mock规则的配置为:首先配置接口请求信息,接口请求信息包括接口名称和接口调用路径,接口名称用于唯一标识每个请求接口;调用路径用于发起接口调用请求时接收请求并唯一匹配对应mock规则;然后配置接口响应结果,响应结果支持json格式串,根据接口文档中预定义的响应格式,设置mock响应期望报文体格式。Configure the corresponding mock rules according to the basic information of the interface; the mock rules include interface request information and response results; the configuration of the mock rules is as follows: first configure the interface request information, which includes the interface name and interface call path. The interface name is used to uniquely identify each request interface; the call path is used to receive the request and uniquely match the corresponding mock rule when initiating an interface call request; then configure the interface response result. The response result supports json format string. According to the predefined response format in the interface document, set the mock response expected message format.

以上技术方案从基础字段库中筛选待造数(即需要进行造数)的字段名称,维护到接口响应内容中。在后续接口请求中,接口响应内容会根据语义识别模型生成的字段值,将响应结果中的基础字段替换为造数期望值,组装成响应报文返回给接口请求方。The above technical solution selects the field names to be created (i.e., the field names that need to be created) from the basic field library and maintains them in the interface response content. In subsequent interface requests, the interface response content will replace the basic fields in the response result with the expected value of the creation according to the field values generated by the semantic recognition model, and assemble them into a response message and return it to the interface requester.

进一步地,基本信息包括接口名称、调用地址和响应结果。Furthermore, the basic information includes the interface name, the calling address and the response result.

进一步地,所述的接收请求方的接口调用请求,获取调用报文信息;根据调用报文信息,匹配mock规则库中对应的mock规则;根据mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将响应报文返回请求方,完成响应,包括:Further, the receiving interface call request of the requesting party obtains the call message information; matches the corresponding mock rule in the mock rule library according to the call message information; determines the response message structure and the field value of the generated data according to the mock rule, and obtains the response message; and returns the response message to the requesting party to complete the response, including:

接收调用mock平台的请求方的外部http接口调用请求,根据外部http接口调用请求,获取调用报文信息;Receive the external http interface call request from the requester that calls the mock platform, and obtain the call message information according to the external http interface call request;

根据调用报文信息,获取请求报文信息中的调用路径;根据接收的请求地址匹配mock规则库中对应的mock规则,即根据接收的请求地址与mock规则库中配置的接口调用路径进行匹配,确定请求对应的接口及其对应的mock规则;According to the call message information, the call path in the request message information is obtained; according to the received request address, the corresponding mock rule in the mock rule library is matched, that is, according to the received request address, the interface call path configured in the mock rule library is matched to determine the interface corresponding to the request and its corresponding mock rule;

根据mock规则,确定响应信息,即响应报文结构;According to the mock rules, determine the response information, that is, the response message structure;

根据响应报文结构中配置的基础字段,基于语义识别模型自动生成数据的字段值;并将字段值组装到响应报文结构中;According to the basic fields configured in the response message structure, the field values of the data are automatically generated based on the semantic recognition model; and the field values are assembled into the response message structure;

响应请求接口,将组装完成的已有生成数据的mock响应报文对象返回给请求方。In response to the request interface, the assembled mock response message object with generated data is returned to the requester.

第二方面,本发明又提供了一种基于语义识别的mock自动造数装置,该装置支持所述的一种基于语义识别的mock自动造数方法;该装置包括:In a second aspect, the present invention further provides a mock automatic number generation device based on semantic recognition, which supports the mock automatic number generation method based on semantic recognition; the device comprises:

基础字段库形成单元,用于获取接口的基础字段信息,将基础字段信息输入语义识别模型中,确定语义相似度;基于语义相似度生成字段数据,形成基础字段库;A basic field library forming unit is used to obtain basic field information of an interface, input the basic field information into a semantic recognition model, determine semantic similarity; generate field data based on the semantic similarity, and form a basic field library;

mock规则库配置单元,用于对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库;mock规则中配置了接口的基础字段信息,生成字段数据后用于匹配接口的响应结果;The mock rule library configuration unit is used to configure the interface request information and the corresponding mock rules for the request interface to form a mock rule library; the basic field information of the interface is configured in the mock rule, and the field data is generated to match the response result of the interface;

接口请求及响应单元,用于接收请求方的接口调用请求,获取调用报文信息;根据调用报文信息,匹配mock规则库中对应的mock规则;根据mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将响应报文返回请求方,完成响应。The interface request and response unit is used to receive the interface call request from the requester and obtain the call message information; match the corresponding mock rules in the mock rule library according to the call message information; determine the response message structure and the field values of the generated data according to the mock rules to obtain the response message; and return the response message to the requester to complete the response.

第三方面,本发明又提供了一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现所述的一种基于语义识别的mock自动造数方法。In a third aspect, the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the mock automatic number generation method based on semantic recognition when executing the computer program.

第四方面,本发明又提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现所述的一种基于语义识别的mock自动造数方法。In a fourth aspect, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the mock automatic number generation method based on semantic recognition is implemented.

本发明与现有技术相比,具有如下的优点和有益效果:Compared with the prior art, the present invention has the following advantages and beneficial effects:

1、本发明一种基于语义识别的mock自动造数方法、装置及介质,本发明可根据配置参数字段名称和字段类型等自动识别字段语义,再基于语义自动生成模拟数据。本发明数据可灵活变更,达到覆盖多场景的需求;同时减少了对响应字段生成规则逐个维护的人工成本,极大地提高造数效率,从而提高接口测试效率。1. The present invention provides a mock automatic number generation method, device and medium based on semantic recognition. The present invention can automatically identify field semantics according to the configuration parameter field name and field type, and then automatically generate simulation data based on the semantics. The data of the present invention can be flexibly changed to meet the needs of covering multiple scenarios; at the same time, it reduces the labor cost of maintaining the response field generation rules one by one, greatly improves the number generation efficiency, and thus improves the interface testing efficiency.

2、本发明提高mock造数的真实性:由于mock数据是根据字段特征,基于语义识别模拟真实生成,更接近真实的外部系统实际响应。2. The present invention improves the authenticity of mock data generation: since mock data is generated based on field features and semantic recognition simulation, it is closer to the actual response of the real external system.

3、本发明提高mock造数的灵活性和多样性:所得到的响应结果基于每次的请求可以生成不同的字段值,而非固定不变的,保证请求方每次获取的响应结果内容不同,调用次数越多,实际得到的响应结果的值越丰富,有助于模拟测试场景使用不同的响应结果覆盖到更多的验证分支。3. The present invention improves the flexibility and diversity of mock number generation: the obtained response result can generate different field values based on each request, rather than being fixed, to ensure that the content of the response result obtained by the requester each time is different. The more times the call is made, the richer the value of the actual response result is, which helps to simulate the test scenario and use different response results to cover more verification branches.

4、本发明具有通用性,可以模拟所有http请求获取响应结果;mock规则中的响应数据结构支持灵活配置,可根据请求所需响应任意配置mock对象。4. The present invention is universal and can simulate all http requests to obtain response results; the response data structure in the mock rule supports flexible configuration, and the mock object can be arbitrarily configured according to the response required by the request.

5、本发明提高测试效率:基础字段库维护后字段变量可应用于多个mock规则中,使得mock规则配置也更加具有灵活性。完成一次基础字段库维护后,基础字段库可重复使用。区别于传统mock规则配置方式,无需对每个字段配置数据生成规则,减少mock配置复杂度,测试人员可专注于响应结果对测试场景的影响,提高测试效率。5. The present invention improves test efficiency: after the basic field library is maintained, the field variables can be applied to multiple mock rules, making the mock rule configuration more flexible. After completing the basic field library maintenance once, the basic field library can be reused. Different from the traditional mock rule configuration method, there is no need to configure data generation rules for each field, which reduces the complexity of mock configuration. Testers can focus on the impact of response results on test scenarios, improving test efficiency.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

此处所说明的附图用来提供对本发明实施例的进一步理解,构成本申请的一部分,并不构成对本发明实施例的限定。在附图中:The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:

图1为本发明一种基于语义识别的mock自动造数方法流程图。FIG1 is a flow chart of a mock automatic number generation method based on semantic recognition according to the present invention.

图2为本发明实施例步骤一的流程图。FIG. 2 is a flow chart of step 1 of an embodiment of the present invention.

图3为本发明实施例步骤二的流程图。FIG3 is a flow chart of step 2 of an embodiment of the present invention.

图4为本发明实施例步骤三的流程图。FIG. 4 is a flow chart of step three of the embodiment of the present invention.

图5为本发明一种基于语义识别的mock自动造数装置结构示意图。FIG5 is a schematic diagram of the structure of a mock automatic number-generating device based on semantic recognition according to the present invention.

具体实施方式DETAILED DESCRIPTION

为使本发明的目的、技术方案和优点更加清楚明白,下面结合实施例和附图,对本发明作进一步的详细说明,本发明的示意性实施方式及其说明仅用于解释本发明,并不作为对本发明的限定。In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary implementation modes of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.

实施例1Example 1

如图1所示,本发明一种基于语义识别的mock自动造数方法,该方法包括:As shown in FIG1 , the present invention provides a mock automatic number generation method based on semantic recognition, the method comprising:

步骤一,获取接口的基础字段信息,将基础字段信息输入语义识别模型中,确定语义相似度;基于语义相似度生成字段数据,形成基础字段库;具体包括:Step 1: Obtain basic field information of the interface, input the basic field information into the semantic recognition model, determine the semantic similarity; generate field data based on the semantic similarity to form a basic field library; specifically include:

获取接口的基础字段信息;基础字段信息包括字段名称、字段类型、字段长度以及预期结果值。Get the basic field information of the interface; the basic field information includes field name, field type, field length and expected result value.

将基础字段信息输入预先训练好的语义识别模型中,以得到基础字段语义向量和预期造数结果的语义向量;Input the basic field information into the pre-trained semantic recognition model to obtain the semantic vector of the basic field and the semantic vector of the expected number-making result;

根据基础字段语义向量和预期造数结果的语义向量,确定语义相似度;Determine semantic similarity based on the semantic vector of the basic field and the semantic vector of the expected number-making result;

基于语义相似度,生成字段数据,形成基础字段库。Based on semantic similarity, field data is generated to form a basic field library.

其中,语义相似度可以衡量各个基础字段语义向量与预期造数结果的语义向量的相似性和关联紧密程度。在后续获取的接口调用请求中,可基于该相似度生成接口字段的模拟数据,使得生成的结果与预期结果保持高度相似,是所需的期望造数结果。Among them, the semantic similarity can measure the similarity and closeness of the semantic vector of each basic field with the semantic vector of the expected number-making result. In the subsequent interface call request obtained, the simulated data of the interface field can be generated based on the similarity, so that the generated result is highly similar to the expected result and is the desired number-making result.

步骤二,对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库;mock规则中配置了接口的基础字段信息,生成字段数据后用于匹配接口的响应结果;对每一个待造数(需要生成测试数据)的接口,配置一条可唯一确定该接口的mock规则;从基础字段库中筛选所需要的接口返回字段数据,建立mock规则与字段数据的对应关系。具体包括:Step 2: For the request interface to be created, configure the interface request information and the corresponding mock rules to form a mock rule library; the basic field information of the interface is configured in the mock rule, and the field data is generated to match the response result of the interface; for each interface to be created (need to generate test data), configure a mock rule that can uniquely identify the interface; filter the required interface return field data from the basic field library, and establish the corresponding relationship between the mock rule and the field data. Specifically include:

对待造数的请求接口,获取接口的基本信息;基本信息包括接口名称、调用地址和响应结果。For the request interface to be created, obtain the basic information of the interface; the basic information includes the interface name, call address and response result.

根据接口的基本信息,配置对应的mock规则;mock规则包括接口请求信息和响应结果;mock规则的配置为:首先配置接口请求信息,接口请求信息包括接口名称和接口调用路径,接口名称用于唯一标识每个请求接口;调用路径用于发起接口调用请求时接收请求并唯一匹配对应mock规则;然后配置接口响应结果,响应结果支持json格式串,根据接口文档中预定义的响应格式,设置mock响应期望报文体格式。Configure the corresponding mock rules according to the basic information of the interface; the mock rules include interface request information and response results; the configuration of the mock rules is as follows: first configure the interface request information, which includes the interface name and interface call path. The interface name is used to uniquely identify each request interface; the call path is used to receive the request and uniquely match the corresponding mock rule when initiating an interface call request; then configure the interface response result. The response result supports json format string. According to the predefined response format in the interface document, set the mock response expected message format.

以上技术方案从基础字段库中筛选待造数(即需要进行造数)的字段名称,维护到接口响应内容中。在后续接口请求中,接口响应内容会根据语义识别模型生成的字段值,将响应结果中的基础字段替换为造数期望值,组装成响应报文返回给接口请求方。The above technical solution selects the field names to be created (i.e., the field names that need to be created) from the basic field library and maintains them in the interface response content. In subsequent interface requests, the interface response content will replace the basic fields in the response result with the expected value of the creation according to the field values generated by the semantic recognition model, and assemble them into a response message and return it to the interface requester.

步骤三,接收请求方的接口调用请求,获取调用报文信息;根据调用报文信息,匹配mock规则库中对应的mock规则;根据mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将响应报文返回请求方,完成响应;具体包括:Step 3: Receive the interface call request from the requester and obtain the call message information; match the corresponding mock rule in the mock rule library according to the call message information; determine the response message structure and the field value of the generated data according to the mock rule to obtain the response message; and return the response message to the requester to complete the response; specifically including:

接收调用mock平台的请求方的外部http接口调用请求,根据外部http接口调用请求,获取调用报文信息;Receive the external http interface call request from the requester that calls the mock platform, and obtain the call message information according to the external http interface call request;

根据调用报文信息,获取请求报文信息中的调用路径;根据接收的请求地址匹配mock规则库中对应的mock规则,即根据接收的请求地址与mock规则库中配置的接口调用路径进行匹配,确定请求对应的接口及其对应的mock规则;According to the call message information, the call path in the request message information is obtained; according to the received request address, the corresponding mock rule in the mock rule library is matched, that is, according to the received request address, the interface call path configured in the mock rule library is matched to determine the interface corresponding to the request and its corresponding mock rule;

根据mock规则,确定响应信息,即响应报文结构;According to the mock rules, determine the response information, that is, the response message structure;

根据响应报文结构中配置的基础字段,基于语义识别模型自动生成数据的字段值;并将字段值组装到响应报文结构中;According to the basic fields configured in the response message structure, the field values of the data are automatically generated based on the semantic recognition model; and the field values are assembled into the response message structure;

响应请求接口,将组装完成的已有生成数据的mock响应报文对象返回给请求方。In response to the request interface, the assembled mock response message object with generated data is returned to the requester.

以下结合一个案例,对以上本发明的方法进行详细描述。The method of the present invention is described in detail below with reference to a case.

本发明包括如下步骤:The present invention comprises the following steps:

1、获取并维护接口的基础字段信息,将待造数(即需要进行造数)的字段信息维护到mock平台的基础字段库中;1. Obtain and maintain the basic field information of the interface, and maintain the field information to be created (i.e., the field information that needs to be created) in the basic field library of the mock platform;

以下是期望生成模拟数据的接口文档信息,见表1:The following is the interface document information for generating simulation data, see Table 1:

表1期望生成模拟数据的接口文档信息表Table 1 Interface document information table for expected generation of simulation data

Figure BDA0004035503380000061
Figure BDA0004035503380000061

Figure BDA0004035503380000071
Figure BDA0004035503380000071

将待造数(即需要进行造数)的字段信息维护到mock平台的基础字段库中,需要维护的信息,见表2:Maintain the field information to be created (i.e., the field information that needs to be created) in the basic field library of the mock platform. The information that needs to be maintained is shown in Table 2:

Figure BDA0004035503380000072
Figure BDA0004035503380000072

2、基于语义识别模型,自动识别配置的基础字段语义,并生成字段值:2. Based on the semantic recognition model, automatically identify the basic field semantics of the configuration and generate field values:

基于提前训练好的语义识别模型,通过维护的字段信息基础字段、字段名称、数据类型、和字段长度,以及对预期字段值进行识别,得到基础字段语义向和预期字段值语义的相似度。根据该相似度,可用于生成与预期基础字段值高度相似的数据结果。如,语义识别模型识别CompanyAddress公司地址字段语义,随机生成的字段值有“浙江省杭州市西湖区毛家桥3001号”、“浙江省杭州市余杭区文一西路969号”、“四川凉山彝族自治州冕宁县泸沽镇11号”等。Based on the pre-trained semantic recognition model, the basic field information, field name, data type, and field length of the maintained field information are used to identify the expected field value, and the similarity between the basic field semantics and the expected field value semantics is obtained. Based on this similarity, it can be used to generate data results that are highly similar to the expected basic field value. For example, the semantic recognition model identifies the semantics of the CompanyAddress company address field, and the randomly generated field values include "No. 3001, Maojiaqiao, Xihu District, Hangzhou City, Zhejiang Province", "No. 969, Wenyi West Road, Yuhang District, Hangzhou City, Zhejiang Province", "No. 11, Lugu Town, Mianning County, Liangshan Yi Autonomous Prefecture, Sichuan Province", etc.

3、根据接口信息,配置mock规则,需要配置以下内容:3. Configure mock rules according to interface information. You need to configure the following:

接口名称:SearchCompanyInfoInterface name: SearchCompanyInfo

调用路径:/mock/test/SearchCompanyInfoCall path: /mock/test/SearchCompanyInfo

响应结果:Response result:

Figure BDA0004035503380000073
Figure BDA0004035503380000073

Figure BDA0004035503380000081
Figure BDA0004035503380000081

其中,“#字段名称#”标识从基础字段库中筛选出来需要进行造数字段变量名称。在后续进行接口调用时,生成的字段值替换响应内容中的变量,组装成完整的响应报文(即响应结果)返回给请求方。Among them, "#field name#" identifies the field variable name that needs to be created from the basic field library. When the interface is called later, the generated field value replaces the variable in the response content and is assembled into a complete response message (i.e., response result) and returned to the requester.

4、基于某测试场景,将请求目标系统的调用地址替换成mock平台地址,用于屏蔽第三方系统。例如,配置接口调用地址为http://(mock平台服务器ip地址)/mock/test/SearchCompanyInfo,发起http接口调用,mock平台接收到调用请求,获取请求路径和请求报文信息,4. Based on a certain test scenario, replace the call address of the target system with the mock platform address to shield the third-party system. For example, configure the interface call address as http://(mock platform server IP address)/mock/test/SearchCompanyInfo, initiate an http interface call, and the mock platform receives the call request and obtains the request path and request message information.

获取到的请求路径为:/mock/test/SearchCompanyInfo,The obtained request path is: /mock/test/SearchCompanyInfo,

获取到的请求报文为:The request message obtained is:

{{

“CerditNo”:“XXXXXXX”"CerditNo":"XXXXXX"

}}

5、根据请求路径,mock平台查询已配置的mock规则,匹配与请求路径相一致的mock规则。找到mock平台上的对应接口为SearchCompanyInfo,并获取该接口对应的响应报文。5. According to the request path, the mock platform queries the configured mock rules and matches the mock rules that are consistent with the request path. The corresponding interface on the mock platform is found to be SearchCompanyInfo, and the response message corresponding to the interface is obtained.

6、根据接口响应报文,获取报文中的基础字段变量,并根据语义识别模型自动生成数据。6. According to the interface response message, obtain the basic field variables in the message and automatically generate data according to the semantic recognition model.

获取到的基础字段变量有:#Name#、#IDcard#、#PhoneNo#、#CompanyName#、#Address#The basic field variables obtained are: #Name#, #IDcard#, #PhoneNo#, #CompanyName#, #Address#

基于语义识别模型,上述基础字段可自动、随机生成数据值用于响应。每次调用生成数据不同,可用于批量接口调用请求数据生成。例如,测试中调用两次请求到mock平台该接口,分别生成两个响应报文内容如下:Based on the semantic recognition model, the above basic fields can automatically and randomly generate data values for response. The generated data is different for each call, which can be used to generate batch interface call request data. For example, in the test, two requests are called to the mock platform interface, and two response messages are generated respectively as follows:

Figure BDA0004035503380000082
Figure BDA0004035503380000082

Figure BDA0004035503380000091
Figure BDA0004035503380000091

7、mock平台响应请求方,将生成数据的响应报文返回。7. The mock platform responds to the requester and returns a response message with the generated data.

本发明一种基于语义识别的mock自动造数方法,具有以下优势:The mock automatic number generation method based on semantic recognition of the present invention has the following advantages:

第一,提高mock造数的真实性:由于mock数据是根据字段特征,基于语义识别模拟真实生成,更接近真实的外部系统实际响应;First, improve the authenticity of mock data: Since mock data is generated based on field features and semantic recognition, it is closer to the actual response of the real external system.

第二,提高mock造数的灵活性和多样性:所得到的响应结果基于每次的请求可以生成不同的字段值,而非固定不变的,保证请求方每次获取的响应结果内容不同,调用次数越多,实际得到的响应结果的值越丰富,有助于模拟测试场景使用不同的响应结果覆盖到更多的验证分支;Second, improve the flexibility and diversity of mock number generation: the response result can generate different field values based on each request, rather than being fixed, to ensure that the content of the response result obtained by the requester is different each time. The more times the call is made, the richer the value of the actual response result is, which helps to simulate the test scenario and use different response results to cover more verification branches;

第三,该方法具有通用性,可以模拟所有http请求获取响应结果;mock规则中的响应数据结构支持灵活配置,可根据请求所需响应任意配置mock对象;Third, this method is universal and can simulate all http requests to obtain response results; the response data structure in the mock rule supports flexible configuration, and the mock object can be arbitrarily configured according to the response required by the request;

第四,提高测试效率:基础字段库维护后字段变量可应用于多个mock规则中,使得mock规则配置也更加具有灵活性。完成一次基础字段库维护后,基础字段库可重复使用。区别于传统mock规则配置方式,无需对每个字段配置数据生成规则,减少mock配置复杂度,测试人员可专注于响应结果对测试场景的影响,提高测试效率。Fourth, improve test efficiency: After the basic field library is maintained, field variables can be applied to multiple mock rules, making mock rule configuration more flexible. After completing a basic field library maintenance, the basic field library can be reused. Different from the traditional mock rule configuration method, there is no need to configure data generation rules for each field, reducing the complexity of mock configuration. Testers can focus on the impact of response results on test scenarios and improve test efficiency.

实施例2Example 2

如图5所示,本实施例与实施例1的区别在于,本实施例提供了一种基于语义识别的mock自动造数装置,该装置支持实施例1所述的一种基于语义识别的mock自动造数方法;该装置包括:As shown in FIG5 , the difference between this embodiment and embodiment 1 is that this embodiment provides a mock automatic number generation device based on semantic recognition, and the device supports a mock automatic number generation method based on semantic recognition described in embodiment 1; the device includes:

基础字段库形成单元,用于获取接口的基础字段信息,将基础字段信息输入语义识别模型中,确定语义相似度;基于语义相似度生成字段数据,形成基础字段库;A basic field library forming unit is used to obtain basic field information of an interface, input the basic field information into a semantic recognition model, determine semantic similarity; generate field data based on the semantic similarity, and form a basic field library;

mock规则库配置单元,用于对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库;mock规则中配置了接口的基础字段信息,生成字段数据后用于匹配接口的响应结果;The mock rule library configuration unit is used to configure the interface request information and the corresponding mock rules for the request interface to form a mock rule library; the basic field information of the interface is configured in the mock rule, and the field data is generated to match the response result of the interface;

接口请求及响应单元,用于接收请求方的接口调用请求,获取调用报文信息;根据调用报文信息,匹配mock规则库中对应的mock规则;根据mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将响应报文返回请求方,完成响应。The interface request and response unit is used to receive the interface call request from the requester and obtain the call message information; match the corresponding mock rules in the mock rule library according to the call message information; determine the response message structure and the field values of the generated data according to the mock rules to obtain the response message; and return the response message to the requester to complete the response.

其中,各个单元的执行过程按照实施例1所述的一种基于语义识别的mock自动造数方法流程步骤执行即可,此实施例中不再一一赘述。Among them, the execution process of each unit can be executed according to the process steps of the mock automatic number generation method based on semantic recognition described in Example 1, and will not be repeated one by one in this embodiment.

同时,本发明又提供了一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现所述的一种基于语义识别的mock自动造数方法。At the same time, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the mock automatic number generation method based on semantic recognition when executing the computer program.

同时,本发明又提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时实现所述的一种基于语义识别的mock自动造数方法。At the same time, the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the mock automatic number generation method based on semantic recognition is implemented.

本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to the flowchart and/or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and/or box in the flowchart and/or block diagram, and the combination of the process and/or box in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.

以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims (10)

1.一种基于语义识别的mock自动造数方法,其特征在于,该方法包括:1. A mock automatic number generation method based on semantic recognition, characterized in that the method comprises: 获取接口的基础字段信息,将所述基础字段信息输入语义识别模型中,确定语义相似度;基于所述语义相似度生成字段数据,形成基础字段库;Obtaining basic field information of the interface, inputting the basic field information into a semantic recognition model, and determining semantic similarity; generating field data based on the semantic similarity to form a basic field library; 对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库;For the request interface to be created, configure the interface request information and the corresponding mock rules to form a mock rule library; 接收请求方的接口调用请求,获取调用报文信息;根据所述调用报文信息,匹配所述mock规则库中对应的mock规则;根据所述mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将所述响应报文返回请求方,完成响应。Receive the interface call request from the requester and obtain the call message information; match the corresponding mock rules in the mock rule library according to the call message information; determine the response message structure and the field values of the generated data according to the mock rules to obtain the response message; and return the response message to the requester to complete the response. 2.根据权利要求1所述的一种基于语义识别的mock自动造数方法,其特征在于,所述的获取接口的基础字段信息,将所述基础字段信息输入语义识别模型中,确定语义相似度;基于所述语义相似度生成字段数据,形成基础字段库,包括:2. According to claim 1, a mock automatic numbering method based on semantic recognition is characterized in that the basic field information of the interface is obtained, the basic field information is input into the semantic recognition model, and the semantic similarity is determined; based on the semantic similarity, field data is generated to form a basic field library, including: 获取接口的基础字段信息;Get the basic field information of the interface; 将所述基础字段信息输入预先训练好的语义识别模型中,以得到基础字段语义向量和预期造数结果的语义向量;Inputting the basic field information into a pre-trained semantic recognition model to obtain a basic field semantic vector and a semantic vector of an expected number-making result; 根据所述基础字段语义向量和预期造数结果的语义向量,确定语义相似度;Determining semantic similarity according to the semantic vector of the basic field and the semantic vector of the expected number-making result; 基于所述语义相似度,生成字段数据,形成基础字段库。Based on the semantic similarity, field data is generated to form a basic field library. 3.根据权利要求2所述的一种基于语义识别的mock自动造数方法,其特征在于,所述基础字段信息包括字段名称、字段类型、字段长度以及预期结果值。3. According to a semantic recognition-based mock automatic number generation method according to claim 2, it is characterized in that the basic field information includes field name, field type, field length and expected result value. 4.根据权利要求1所述的一种基于语义识别的mock自动造数方法,其特征在于,对每一个待造数的接口,配置一条唯一确定该接口的mock规则;从所述基础字段库中筛选所需要的接口返回字段数据,建立mock规则与字段数据的对应关系。4. According to a semantic recognition-based mock automatic number generation method according to claim 1, it is characterized in that for each interface to be generated, a mock rule that uniquely determines the interface is configured; the required interface return field data is screened from the basic field library, and a corresponding relationship between the mock rule and the field data is established. 5.根据权利要求4所述的一种基于语义识别的mock自动造数方法,其特征在于,所述的对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库,包括:5. According to the method of automatic mock number generation based on semantic recognition in claim 4, it is characterized in that the request interface to be generated configures interface request information and corresponding mock rules to form a mock rule library, including: 对待造数的请求接口,获取接口的基本信息;Treat the request interface for number generation and obtain basic information of the interface; 根据接口的基本信息,配置对应的mock规则;所述mock规则包括接口请求信息和响应结果;Configure corresponding mock rules according to the basic information of the interface; the mock rules include interface request information and response results; 所述mock规则的配置为:首先配置接口请求信息,所述接口请求信息包括接口名称和接口调用路径,所述接口名称用于唯一标识每个请求接口;所述调用路径用于发起接口调用请求时接收请求并唯一匹配对应mock规则;然后配置接口响应结果,所述响应结果支持json格式串,根据接口文档中预定义的响应格式,设置mock响应期望报文体格式。The configuration of the mock rule is as follows: first, configure the interface request information, which includes the interface name and the interface call path. The interface name is used to uniquely identify each request interface; the call path is used to receive the request and uniquely match the corresponding mock rule when initiating the interface call request; then configure the interface response result, which supports the json format string, and sets the mock response expected message format according to the predefined response format in the interface document. 6.根据权利要求5所述的一种基于语义识别的mock自动造数方法,其特征在于,所述基本信息包括接口名称、调用地址和响应结果。6. According to the semantic recognition-based mock automatic number generation method of claim 5, it is characterized in that the basic information includes the interface name, the call address and the response result. 7.根据权利要求1所述的一种基于语义识别的mock自动造数方法,其特征在于,所述的接收请求方的接口调用请求,获取调用报文信息;根据所述调用报文信息,匹配所述mock规则库中对应的mock规则;根据所述mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将所述响应报文返回请求方,完成响应,包括:7. According to the semantic recognition-based mock automatic number generation method of claim 1, it is characterized in that the receiving interface call request of the requesting party obtains the call message information; according to the call message information, matches the corresponding mock rule in the mock rule library; according to the mock rule, determines the response message structure and the field value of the generated data to obtain the response message; and returns the response message to the requesting party to complete the response, including: 接收调用mock平台的请求方的外部http接口调用请求,根据所述外部http接口调用请求,获取调用报文信息;Receive an external http interface call request from a requester that calls the mock platform, and obtain call message information according to the external http interface call request; 根据所述调用报文信息,获取请求报文信息中的调用路径;根据接收的请求地址匹配所述mock规则库中对应的mock规则,即根据接收的请求地址与所述mock规则库中配置的接口调用路径进行匹配,确定请求对应的接口及其对应的mock规则;According to the call message information, the call path in the request message information is obtained; according to the received request address, the corresponding mock rule in the mock rule library is matched, that is, according to the received request address, the interface call path configured in the mock rule library is matched to determine the interface corresponding to the request and its corresponding mock rule; 根据所述mock规则,确定响应信息,即响应报文结构;According to the mock rules, determine the response information, that is, the response message structure; 根据所述响应报文结构中配置的基础字段,基于语义识别模型自动生成数据的字段值;并将所述字段值组装到响应报文结构中;According to the basic fields configured in the response message structure, automatically generate field values of the data based on the semantic recognition model; and assemble the field values into the response message structure; 响应请求接口,将组装完成的已有生成数据的mock响应报文对象返回给请求方。In response to the request interface, the assembled mock response message object with generated data is returned to the requester. 8.一种基于语义识别的mock自动造数装置,其特征在于,该装置包括:8. A mock automatic number-generating device based on semantic recognition, characterized in that the device comprises: 基础字段库形成单元,用于获取接口的基础字段信息,将所述基础字段信息输入语义识别模型中,确定语义相似度;基于所述语义相似度生成字段数据,形成基础字段库;A basic field library forming unit is used to obtain basic field information of an interface, input the basic field information into a semantic recognition model, determine semantic similarity; generate field data based on the semantic similarity, and form a basic field library; mock规则库配置单元,用于对待造数的请求接口,配置接口请求信息及对应的mock规则,形成mock规则库;The mock rule library configuration unit is used to configure the interface request information and corresponding mock rules for the request interface to form a mock rule library; 接口请求及响应单元,用于接收请求方的接口调用请求,获取调用报文信息;根据所述调用报文信息,匹配所述mock规则库中对应的mock规则;根据所述mock规则,确定响应报文结构和生成数据的字段值,得到响应报文;并将所述响应报文返回请求方,完成响应。The interface request and response unit is used to receive the interface call request of the requester and obtain the call message information; match the corresponding mock rules in the mock rule library according to the call message information; determine the response message structure and the field values of the generated data according to the mock rules to obtain the response message; and return the response message to the requester to complete the response. 9.一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至7任一项所述的一种基于语义识别的mock自动造数方法。9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the mock automatic number generation method based on semantic recognition as described in any one of claims 1 to 7 is implemented. 10.一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述的一种基于语义识别的mock自动造数方法。10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements a mock automatic number generation method based on semantic recognition as described in any one of claims 1 to 7.
CN202310002089.4A 2023-01-03 2023-01-03 A mock automatic number creation method, device and medium based on semantic recognition Pending CN116126704A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310002089.4A CN116126704A (en) 2023-01-03 2023-01-03 A mock automatic number creation method, device and medium based on semantic recognition

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310002089.4A CN116126704A (en) 2023-01-03 2023-01-03 A mock automatic number creation method, device and medium based on semantic recognition

Publications (1)

Publication Number Publication Date
CN116126704A true CN116126704A (en) 2023-05-16

Family

ID=86296771

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310002089.4A Pending CN116126704A (en) 2023-01-03 2023-01-03 A mock automatic number creation method, device and medium based on semantic recognition

Country Status (1)

Country Link
CN (1) CN116126704A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140229917A1 (en) * 2013-02-13 2014-08-14 International Business Machines Corporation Generating Input Values for a Test Dataset from a Datastore Based on Semantic Annotations
CN111428251A (en) * 2020-03-18 2020-07-17 北京明略软件系统有限公司 Data processing method and device
CN114218114A (en) * 2021-12-22 2022-03-22 四川启睿克科技有限公司 Full-automatic test data generation method based on interface flow arrangement
CN115380281A (en) * 2020-02-26 2022-11-22 起元技术有限责任公司 Generating rules for data processing values for data fields based on semantic tags of the data fields

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140229917A1 (en) * 2013-02-13 2014-08-14 International Business Machines Corporation Generating Input Values for a Test Dataset from a Datastore Based on Semantic Annotations
CN115380281A (en) * 2020-02-26 2022-11-22 起元技术有限责任公司 Generating rules for data processing values for data fields based on semantic tags of the data fields
CN111428251A (en) * 2020-03-18 2020-07-17 北京明略软件系统有限公司 Data processing method and device
CN114218114A (en) * 2021-12-22 2022-03-22 四川启睿克科技有限公司 Full-automatic test data generation method based on interface flow arrangement

Similar Documents

Publication Publication Date Title
CN110008113B (en) Test method and device and electronic equipment
CN110334021B (en) Interface test case generation method, device, equipment and storage medium
CN109101415A (en) Interface test method, system, equipment and the storage medium compared based on database
CN110597730B (en) Automatic test case generation method and system based on scene method
CN109359045B (en) Test method, device, equipment and storage medium
CN105760292B (en) A kind of assertion verification method and apparatus for unit testing
CN110750433A (en) Interface testing method and device
CN112511384B (en) Flow data processing method and device, computer equipment and storage medium
CN114610619A (en) Test method, device, equipment and storage medium for business process
CN112256672B (en) Database change approval method and device
CN112632391A (en) Data processing method, device and storage medium
CN113157551A (en) ROS-oriented differential fuzzy test method
CN120596356A (en) AI application program tuning method, device, and computing device
CN116126704A (en) A mock automatic number creation method, device and medium based on semantic recognition
CN114185758B (en) System fault simulation method, device, computer equipment and medium
CN118114064A (en) Evaluation method, device, equipment and storage medium for large language model
CN117827670A (en) Test case generation method and equipment
CN115857896A (en) A rule engine online generation method, rule engine system and related equipment
CN108628750B (en) Test code processing method and device
JP2585460B2 (en) Test data creation method
CN105630679A (en) Code testing method and apparatus
CN116795723B (en) Chain unit test processing method and device and computer equipment
CN111736806A (en) Control injection method, device and terminal device
CN111400181A (en) Object testing method and device and server
CN106815136B (en) Unit testing method and device

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