基於SOA架構的TDD測試驅動開發模式


  以需求用例為基,Case&Coding兩條線並行,服務(M)&消費(VC)分離,單元、接口、功能、集成四層質量管理,自動化集成、測試、交付全程支持。 3個大階段(需求分析階段、研發准備階段、研發測試階段)16個小歷程(*)確定好邊界,明確好對接產物,做好服務管理。

一、抽象接口

  根據拆分的需求,將本輪迭代所要實現的功能抽象出來。

public interface IUserInfoInterface{
    /**
     * 功能:校驗用戶是否綁定了手機號<br>
     * @param account 賬號(必填項),例如:admin@123456
     * @return 結果視圖
     * @version [0.0.1, 2016-07-12]
     */
    CommonResult<UserInfoEntity> checkHandphoneBindingByAccount(String account);
    /**
     * 校驗手機號是否已被綁定
     * @param handphone 手機號,例如:13999999999
     * @return 結果視圖
     * @version [0.0.1, 2016-07-26]
     */
    CommonResult<UserInfoEntity> checkHandphoneBinding(String handphone);
}

二、構建項目至Nexus(maven deploy)

  使用Jenkins持續集成,並提供pom三維坐標

<groupId>com.cnblogs</groupId>
<artifactId>user-interfaces</artifactId>
<version>1.1.2-SNAPSHOT</version>

三、Case&Coding倆條線並行

  case調用接,編寫用例

import com.*.*.interfaces.TUserInfoInterface.service.IOpenTestInterfaces;
import com.*.*.interfaces.user.inf.IUserInfoInterface;@Service("openTestInterfaces") public class OpenTest implements IOpenTestInterfaces { @Autowired private IUserInfoInterface tUserInfoInterface; @Override public String login(String account, String password, String identifyingCode,String loginChannel) { CommonResult<UserInfoEntity> login = tUserInfoInterface.login(account, password, identifyingCode,loginChannel);     // 操作碼     String optCode = login.getOptCode();     // 操作描述     String optDesc = login.getOptDesc();     // 結果碼     String resultCode = login.getResultCode();     // 結果描述     String resultDesc = login.getResultDesc();     // 返回數據     EsiUserInfoEntity data = login.getData();     // 系統碼     String module = login.getModule().getModuleCode();     // 業務碼     String bizCode = login.getBizCode();     //操作是否成功     Boolean isSuccess = login.isSuccess();     result = new TestResult(optCode, optDesc, resultCode, resultDesc, data, module, bizCode,isSuccess).toString();     return result; }

  coding實現接口

import com.*.*.user.service.inf.UserInfoService;
import com.*.*.interfaces.user.inf.IUserInfoInterface; @Service(
"UserInfoService") public class UserInfoServiceimpl implements UserInfoService{ @Override public CommonResult<UserInfoEntity> login(String account,String password,String identifyingCode,String loginChannel){ CommonResult<UserInfoEntity> cr = new EsiResult<>(); //賬戶非空校驗 if(StringUtils.isEmpty(account)){ cr.setResult(ResultCode.ACCOUNT_EMPTY_CODE); return cr; } try{ UserInfoEntity userInfoEntity_account = getUserInfoEntityByAccount(account); //校驗賬戶是否存在 if(userInfoEntity_account == null){ cr.setResult(EsiResultCode.ACCOUNT_NOT_EXISTS_CODE); return cr; }catch(Exception e){ log.error("登陸校驗發生錯誤", e); cr.setResult(ResultCode.UNKNOWN); return cr; } return cr; }

四、持續集成

  寫完用例后以消費者身份注冊zk等待提供者。

  研發完成服務(ws)后,使用Jenkins構建項目,集成到dubbo_zk管理中心。

  與此同時,dubbo管理台接口現實提供者並狀態顯示正常。

五、測試用例=API?

  頁面太丑,五臟俱全。

六、3個大階段(需求分析階段、研發准備階段、研發測試階段)16個小歷程(*)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM