Table of Contents
The development of the test platform based on springboot vue
1. Relationship between components
This part briefly introduces the content and functions of each component.
The function here is to provide an entry point for adding assertions. Currently, only JSONPath is true, and the other two are false.
Home Java javaTutorial How to implement interface assertion function in springboot+vue component development

How to implement interface assertion function in springboot+vue component development

May 14, 2023 pm 12:28 PM
vue springboot

The development of the test platform based on springboot vue

(practice project) continues to be updated.

Next, prepare to develop the request assertion function. Regarding what requirements this function needs to be implemented and what it looks like, I referred to other excellent industry tools, such as apifox, metersphere, etc.

So I decided to develop the most commonly used ones first: JSONPath, Response time, Text, and among these, JSONPath takes precedence.

Old rule, let’s take a look at the effect of this front-end component first.

How to implement interface assertion function in springboot+vue component development

1. Relationship between components

The above functional effects are actually completed by 3 components together. The position of

How to implement interface assertion function in springboot+vue component development

in the project code is as shown in the figure.

How to implement interface assertion function in springboot+vue component development

  • ApiAssertions: The outermost component, mainly the entrance to add assertions, and the place to integrate different types of assertion subcomponents.

  • ApiAssertionsEdit: Different assertion components need to provide editing functions. This is also the place to integrate different types of assertion editing sub-components.

  • ApiAssertionJsonPath: This component is the lowest-level component for assertions of the JSONPath type.

The inclusion relationship of these three components is: ApiAssertions -> ApiAssertionsEdit -> ApiAssertionJsonPath.

Since there is no ready-made solution in elementUI, it is still necessary to use scattered elementUI components to combine them, just like building blocks.

After taking stock, I probably used the following elementUI components. Interested children can go to the official website to learn more:

  • ##el-select Selector

  • ##el-row

    , el-col, this is the Layout

  • el-input

    , input box

  • el-tooltip

    , tips

  • el-button

    , button

  • The rest is the knowledge related to component development, which I have briefly organized in previous articles.

2. Component development

This part briefly introduces the content and functions of each component.

1. ApiAssertions

The function here is to provide an entry point for adding assertions. Currently, only JSONPath is true, and the other two are false.

How to implement interface assertion function in springboot+vue component development#Then add a button and make a control, that is, it is disabled and cannot be clicked when the type is not selected.

How to implement interface assertion function in springboot+vue component developmentThen this contains the sub-component

ApiAssertionJsonPath

, here v-if is used to determine the type, when the type value is # This component is only displayed when ##JSON_PATH is displayed.

Regarding component types, these are always on, so in order to be more standardized, I extracted these values ​​​​and put them into a separate How to implement interface assertion function in springboot+vue component developmentApiTestModel.js

In the file:

export const ASSERTION_TYPE = {
  TEXT: 'Text',
  JSON_PATH: 'JSONPath',
  DURATION: 'Duration'
}
Copy after login
Next, there is an editing component ApiAssertionsEdit

which is also its subcomponent, because after clicking Add, the list of corresponding JSONPath will be displayed, and it can continue to be edited. .

Notice that the above two sub-components are bound to custom attributes How to implement interface assertion function in springboot+vue component developmentassertions

. This attribute is used to receive external parameters. , so it must be defined first in

props:

  props: {
    assertions: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
Copy after login
2. ApiAssertionsEdit

This component is used to provide the editing function of the added JSONPath, and can provide assertions list display effect. In addition, there are functions such as deletion and disabling of assertions.

List display uses How to implement interface assertion function in springboot+vue component developmentv-for

, the JSONPath list in the variable assertion, and then takes out the data inside and displays it.

Here is a How to implement interface assertion function in springboot+vue component development:edit="true"

This attribute is required by the

ApiAssertionJsonPath component, its function is described below. 3. ApiAssertionJsonPath

This is the bottom component, and most of the content is here.

How to implement interface assertion function in springboot+vue component development

代码里用不同的elementUI组件把每列的内容定义好即可。

注意在上层组件传来的edit,在这里是用来判断当前是否为编辑状态的,是的话就显示删除和禁用的组件。

How to implement interface assertion function in springboot+vue component development

其他的代码就不具体截图了,有需要的童鞋可以获取源码对着看。

接下来就要开发对应的后端功能,就是如何把断言数据落到数据库里,也就是jsonpath这个对象里的这些字段。

    jsonPath: {
      type: Object,
      default: () => {
        return {
          type: ASSERTION_TYPE.JSON_PATH,
          expression: undefined,
          option: undefined,
          expect: undefined,
          description: undefined,
          enable: true
        }
      }
    },
Copy after login

The above is the detailed content of How to implement interface assertion function in springboot+vue component development. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue realizes marquee/text scrolling effect Vue realizes marquee/text scrolling effect Apr 07, 2025 pm 10:51 PM

Implement marquee/text scrolling effects in Vue, using CSS animations or third-party libraries. This article introduces how to use CSS animation: create scroll text and wrap text with <div>. Define CSS animations and set overflow: hidden, width, and animation. Define keyframes, set transform: translateX() at the beginning and end of the animation. Adjust animation properties such as duration, scroll speed, and direction.

What method is used to convert strings into objects in Vue.js? What method is used to convert strings into objects in Vue.js? Apr 07, 2025 pm 09:39 PM

When converting strings to objects in Vue.js, JSON.parse() is preferred for standard JSON strings. For non-standard JSON strings, the string can be processed by using regular expressions and reduce methods according to the format or decoded URL-encoded. Select the appropriate method according to the string format and pay attention to security and encoding issues to avoid bugs.

Is the request method (GET, POST, etc.) used correctly? Is the request method (GET, POST, etc.) used correctly? Apr 07, 2025 pm 10:09 PM

The use of Axios request method in Vue.js requires following these principles: GET: Obtain resources, do not modify data. POST: Create or submit data, add or modify data. PUT: Update or replace existing resources. DELETE: Delete the resource from the server.

How to reference js file with vue.js How to reference js file with vue.js Apr 07, 2025 pm 11:27 PM

There are three ways to refer to JS files in Vue.js: directly specify the path using the <script> tag;; dynamic import using the mounted() lifecycle hook; and importing through the Vuex state management library.

What does the vue component pass value mean? What does the vue component pass value mean? Apr 07, 2025 pm 11:51 PM

Vue component passing values ​​is a mechanism for passing data and information between components. It can be implemented through properties (props) or events: Props: Declare the data to be received in the component and pass the data in the parent component. Events: Use the $emit method to trigger an event and listen to it in the parent component using the v-on directive.

What does it mean to lazy load vue? What does it mean to lazy load vue? Apr 07, 2025 pm 11:54 PM

In Vue.js, lazy loading allows components or resources to be loaded dynamically as needed, reducing initial page loading time and improving performance. The specific implementation method includes using <keep-alive> and <component is> components. It should be noted that lazy loading can cause FOUC (splash screen) issues and should be used only for components that need lazy loading to avoid unnecessary performance overhead.

Vue.js How to convert an array of string type into an array of objects? Vue.js How to convert an array of string type into an array of objects? Apr 07, 2025 pm 09:36 PM

Summary: There are the following methods to convert Vue.js string arrays into object arrays: Basic method: Use map function to suit regular formatted data. Advanced gameplay: Using regular expressions can handle complex formats, but they need to be carefully written and considered. Performance optimization: Considering the large amount of data, asynchronous operations or efficient data processing libraries can be used. Best practice: Clear code style, use meaningful variable names and comments to keep the code concise.

What are the common solutions for Vue Axios &Network Error& What are the common solutions for Vue Axios &Network Error& Apr 07, 2025 pm 09:51 PM

Common ways to solve Vue Axios "Network Error": Check network connections. Verify the API endpoint URL. Check CORS settings. Handle error response. Check the firewall or proxy. Adjustment request timed out. Check the JSON format. Update the Axios library.

See all articles