從0開始學習介面自動化測試 二)

2021-09-16 14:23:10 字數 4096 閱讀 7514

感興趣的小夥伴可以加入qq群:556029945

org.springframework.boot

spring-boot-starter-jdbc

2.1.0.release

org.springframework.boot

spring-boot-starter-web

2.1.0.release

org.springframework.boot

spring-boot-autoconfigure

2.1.0.release

4.先建api類,沒有嚴格遵循物件轉化設計這塊,除了寫入資料庫,所有物件都採用api類進行資料轉換。

package com.dsh.rest.api;

/** * profile

* @author dsh

*/public class profile

public void setname(string name)

public string getage()

public void setage(string age)

public string getbirthday()

public void setbirthday(string birthday)

public string getselfintroduction()

public void setselfintroduction(string selfintroduction)

public contact getcontact()

public void setcontact(contact contact)

public string getmarriagestatus()

public void setmarriagestatus(string marriagestatus)

public void setid(string id)

}

package com.dsh.rest.api;

public class contact

public void setphonenumber(string phonenumber)

public string getaddress()

public void setaddress(string address)

public string getemail()

public void setemail(string email)

public string getemergencycontact()

public void setemergencycontact(string emergencycontact)

public string getemergencycontactphonenumber()

public void setemergencycontactphonenumber(string emergencycontactphonenumber)

public string getemergencycontactaddress()

public void setemergencycontactaddress(string emergencycontactaddress)

}

package com.dsh.rest.api;

public class profileresponse

public void setresult(string result)

public string getid()

public void setid(string id)

}

5.資源類(乙個查詢,乙個寫入)

package com.dsh.rest.resource;

import com.dsh.rest.api.profile;

import com.dsh.rest.service.profilequeryservice;

import org.springframework.beans.factory.annotation.autowired;

import org.springframework.web.bind.annotation.requestparam;

import org.springframework.web.bind.annotation.restcontroller;

@restcontroller

public class profilequeryresource

}

package com.dsh.rest.resource;

import com.dsh.rest.api.profile;

import com.dsh.rest.api.profileresponse;

import com.dsh.rest.service.profileregisterservice;

import org.springframework.beans.factory.annotation.autowired;

import org.springframework.web.bind.annotation.requestbody;

import org.springframework.web.bind.annotation.restcontroller;

@restcontroller

public class profileregisterresource

return profileresponse;

}}

6. 服務層(先定義介面,再實現,無業務邏輯所以很簡單的一層)

package com.dsh.rest.service;

import com.dsh.rest.api.profile;

public inte***ce profilequeryservice

package com.dsh.rest.service.impl;

import com.dsh.rest.api.profile;

import com.dsh.rest.repository.profilerepository;

import com.dsh.rest.service.profilequeryservice;

import org.springframework.beans.factory.annotation.autowired;

import org.springframework.stereotype.service;

@service

public class profilequeryserviceimpl implements profilequeryservice

}

package com.dsh.rest.service;

import com.dsh.rest.api.profile;

public inte***ce profileregisterservice

package com.dsh.rest.service.impl;

import com.dsh.rest.api.profile;

import com.dsh.rest.repository.profilerepository;

import com.dsh.rest.service.profileregisterservice;

import org.springframework.beans.factory.annotation.autowired;

import org.springframework.stereotype.service;

@service

public class profileregisterserviceimpl implements profileregisterservice

}

收藏

從0開始學習介面自動化測試(一)

感興趣的小夥伴可以加入qq群 556029945 介面 硬體類介面 是指同一計算機不同功能層之間的通訊規則稱為介面。介面 軟體類介面 是指對協定進行定義的引用型別。其他型別實現介面,以保證它們支援某些操作。介面指定必須由類提供的成員或實現它的其他介面。與類相似,介面可以包含方法 屬性 索引器和事件作...

自動化測試 介面測試分類(二)

應用層,從認知上你可以看成是系統所提供的ui 層功能。對於web 系統來說,你可以認為是瀏覽器頁面上所提供的功能,登入 註冊 查詢 刪除等。service 層,可以理解為伺服器所提供資料和邏輯的處理。db 層,data base 資料庫主要用來存放資料,例如使用者的個人資訊,商品的資訊等。訪問物件,...

介面測試 介面自動化測試

1 介面自動化到底關注哪些點?a.關注函式 類 方法 所提供的介面的可靠性 b.關注介面之間銜接的可靠性 c.關注介面引數的校驗 2 介面有哪幾種型別?a.http協議中 get post put delete input方法 b.目前自動化工具提供的有get和post兩種方法 3 用介面實現自動化...